Hello there, I need to mangle rtp packets in kernel space. So far I am new in kernel module programming. I am trying to implement a module for netfilter hooks. For the first time as exercise, I am trying to write smaller modules. Let me explain what I am actually doing now.
I have an echo client and server. The server runs on port 6000. Both are on different machines (May be VMs in bridge filter mode). The client sends udp message and the server just echoes it back. Let us suppose the client sends "some message" as data. Then now I am trying to write a module for the client machine that will append "12345" after the data so that the server will get "some message12345" and echo it back. Now there are various things I did faced. I relied on the NF_IP_POST_ROUTING hook. At first, I copied the data to a temporary storage, and then add 12345 with that. Then I increase skb->tail using skb_put(). Then I memset() 0 to the packet data, and copy the temporary storage with that. Then as the procedure, NF_ACCEPT is returned. There are certain checking points like the udph->dest == 6000 etc. etc. When I use skb_put(), my system hangs out after two or three minutes. When I dmesg to be certain that everything goes right, I find it OK. But, suppose once I send a message like "This is a pretty big message" and another time I send "small message" then I get just "small message12345g message" that means, the bigger message is stored somewhere I don't understand. I tried with skb_add_data() but that works incorrectly here, I understand it's my fault. I just can't figure it out. Now, one thing came in my mind, if it's not possible, should I create new packets for that data appending? I find skb->end - skb->tail is not so big. But ultimately I have to merge two or three packets into one packet and then skb_put() will not suffice for me. Then the point comes, I can use alloc_skb(), skb_reserve(), skb_header_pointer() and other skb manipulation functions, but I don't understand how can I drop the packet got (should I return NF_DROP?) and how can I route my created packets in the packet flowing path? I saw in the xtables_addons for help (file xt_ECHO.c) but found they used ip_route_me_harder() for it. But the function they used is quite different, it is their own. Then I need suggestions about how to route the newly created packet in kernel space. This is the point I am stuck for a few days. If anyone can help me, I will be highly grateful. I understand my knowledge is poor about Linux kernel, but I need a definite way to understand, otherwise the code is not helping me much. Thanks in advance. -- Rifat Rahman
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies