How to assign incoming packet's source port to outgoing packet destination port — TCP C Linux

感情迁移 提交于 2021-01-07 03:10:17

问题


I like to know the source port of packet in tcphdr can be assigned to destination port of ip like this

       source_ip_tcph->source= dest_ip_tcph->dest;
       source_ip_tcph->dest  = dest_ip_tcph->source;

above are source and destination (pointer to memory) of tcphdr type

I am trying to create a server everytime I respond to client from server the destination port is different. I assigned it like above

Edit Above I am using raw sockets. trying to make raw socket based tcp implementation as a server

来源:https://stackoverflow.com/questions/65378401/how-to-assign-incoming-packets-source-port-to-outgoing-packet-destination-port

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!