Ok I am moving forward. It is very easy to send udp data using udp_send() in InterNiche, it does everything You need, but I want to prepare UDP data in hardware, so I want to use ip_write only.
That is also pretty easy, but I face some problems:
I prepare the packet same as I would use in udp_send(), but it forms a packet without src/dest ip adresses and I don't know how to set them? The other parts (except adresses and payload) of the packets are OK.
Another problem that the payload is always 10 bytes, no matter if I set the payload length 26 and add required octets to the packet. Maybe someone also had such problems?
here (
http://pastebin.com/d1a4qtjg) is the source code.
EDIT: SOLVED ->
Need to add src and dest ip addresses through ip struct:
own_address = ip_mymach(pkt->fhost);
pip = (struct ip *)(pkt->nb_prot - sizeof(struct ip));
pip->ip_src = own_address;
pip->ip_dest = pkt->fhost;
----------------------------------------
Now moving towards to add DMA to move payload from hardware to pkt buffer.