| Author |
Message |
|
| epteflo |
Posted: Wed Aug 16, 2006 2:49 pm |
|
|
|
Joined: 16 Aug 2006
Posts: 5
|
Hi,
I would like to write an IP packet handler program in Erlang, which would be able to grab IP packets from an interface, modify it, and send forward. Could you help me find the best way to do it?
Thanks
Peter |
|
|
| Back to top |
|
| Mazen |
Posted: Thu Aug 17, 2006 9:50 am |
|
|
|
User
Joined: 20 Jul 2006
Posts: 164
Location: London
|
Hi
I would suggest you take a look at the inet and gen_tcp modules in the documentation. they provide some nice interfaces, however i dont think you are able to pick up any package received at a specific network interface though (eth1.. etc) but Im not sure. I took a look at it once and didnt see anything that provided an interface for it but if anyone else knows how that would be great to know.
if you want you could do a C driver for accessing the stack directly but in that case you might as well do it in C? Reading the IP packages cant be that hard, however I dont know if you are allowed to manipulate them without the right user in *nix systems (I have a very strong feeling that Windows is even worse but I could be wrong).
Hope some of this jibbersh help  |
|
|
| Back to top |
|
| epteflo |
Posted: Thu Aug 17, 2006 10:54 am |
|
|
|
Joined: 16 Aug 2006
Posts: 5
|
Thanks for the advice!
In fact I have already wrote this functionality in C using other existing codes, but in that way the system is too complex, complicated, and big, you know, it seems to be "hacked". I would like to find an easier way, to have a simplier code. That is why I turned to Erlang.
I would like to run this code on Unix OS, but It would be very cool, when it would be runable on Win (but I dont see any chance for it ).
So, Ok, Im going to take a look into the modules you mentioned. Thanks again. |
|
|
| Back to top |
|
| epteflo |
Posted: Thu Aug 17, 2006 11:44 am |
|
|
|
Joined: 16 Aug 2006
Posts: 5
|
Thanks for the advice!
In fact I have already wrote this functionality in C using other existing codes, but in that way the system is too complex, complicated, and big, you know, it seems to be "hacked". I would like to find an easier way, to have a simplier code. That is why I turned to Erlang.
I would like to run this code on Unix OS, but It would be very cool, when it would be runable on Win (but I dont see any chance for it ).
So, Ok, Im going to take a look into the modules you mentioned. Thanks again. |
|
|
| Back to top |
|
| epteflo |
Posted: Thu Aug 17, 2006 12:37 pm |
|
|
|
Joined: 16 Aug 2006
Posts: 5
|
Thanks for the advice!
In fact I have already wrote this functionality in C using other existing codes, but in that way the system is too complex, complicated, and big, you know, it seems to be "hacked". I would like to find an easier way, to have a simplier code. That is why I turned to Erlang.
I would like to run this code on Unix OS, but It would be very cool, when it would be runable on Win (but I dont see any chance for it ).
So, Ok, Im going to take a look into the modules you mentioned. Thanks again. |
|
|
| Back to top |
|
| epteflo |
Posted: Thu Aug 17, 2006 12:40 pm |
|
|
|
Joined: 16 Aug 2006
Posts: 5
|
| Sorry for that many reply.... it was my microsoft explorer...no comment.... |
|
|
| Back to top |
|
| Mazen |
Posted: Fri Aug 18, 2006 10:40 am |
|
|
|
User
Joined: 20 Jul 2006
Posts: 164
Location: London
|
|
| Back to top |
|
| francesco |
Posted: Mon Aug 21, 2006 9:09 am |
|
|
|
User
Joined: 07 Jul 2006
Posts: 249
Location: London
|
You should be using the bit syntax when writing your application. Parsing an IP header is as easy as:
<<4:4/integer, % Ip Version
Hd_Len:4/integer, % Header Length
Tos:8/integer, % Tos
Len:16/big-integer, % Packet Length
Frg_Id:16/big-integer, % Fragment Id
_:2/integer, % Two first flags... bah
Mf:1/integer, % More Fragments flag
Offset:13/big-integer, % Fragment Offset
TTL:8/integer, % TTL
Protocol:8/integer, % Upper layer protocol
Checksum:16/big-integer, % Checksum
Src_Ip:32/big-integer, % Where this pile of shit came from...
Dst_Ip:32/big-integer, % Should check this against our Ip
Options/binary>> = Ip_Header, % Options
This would be for a rfc791 Ip packet. (The example was taken from the erlang mailing list).
Francesco |
|
|
| Back to top |
|
|
|