[erlang-questions] UDP Headers
Tue Jul 8 23:53:18 CEST 2014
Thanks for responding. I was actually just looking through your repositories to see if you had written something to work with this.
What I’d like to do is to be able to set the DF or TTL flags. What would you suggest for such things?
On 8 Jul 2014, at 22:47, Michael Santos <michael.santos@REDACTED> wrote:
> On Tue, Jul 08, 2014 at 07:04:12PM +0100, Lee Sylvester wrote:
>> Hey guys,
>> So, I’m using gen_udp for a server I’m building, but I really need to be able to update the headers of incoming packets. Does anyone know how I can do this with gen_udp without having to resort to using raw sockets?
> It depends which header needs to be changed:
> * for UDP (source/destination port, length, checksum), the simplest
> method is to receive and resend the packet
> * for IPv4/IPv6, some of the headers may be able to be influenced by setting
> socket options. For example, by using inet:setopts/2 or by using
> setsockopt(2) from an NIF.
> * otherwise, there's the raw socket interface.
> For IPv4, the socket can be opened in raw mode and passed back into
> For IPv6 headers, if the headers can be changed, you generally have to
> use sendmsg(2)/recvmsg(2) which means using a port or an NIF.
> * for ethernet, it will depend on the OS: PF_PACKET for linux, BPF for
> the BSDs
> * another option is routing the packets through a tun/tap device and
> having some erlang code re-write the headers
> erlang-questions mailing list
More information about the erlang-questions