Forwarding SOCKS traffic from LAN to another physical interface

Hi everyone,

My router (D-Link DWR-921) has a SIM card modem built in. I used this guide to configure it, and everything works well.

I want to receive SOCKS4/5 packets through the LAN interface on some port, unpack the SOCKS packets, and then forward the raw TCP/UDP packets to another physical interface (wwan0 in my case). I do not want my router to act as a general device to access the internet via the SIM card, but just as a proxy server inside of my local network. I was wondering if there is a premade SOCKS server that I could use for this task, or I need to write my own to accomplish this.