LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-22-2004, 10:43 PM   #1
sunnyriver
LQ Newbie
 
Registered: Mar 2004
Location: China
Distribution: redflag
Posts: 5

Rep: Reputation: 0
Question packet sending function in kernel ? help


In my kernel module, I want to send some sk_buffs to
internet. Which function can I use?
Thanks.
 
Old 03-23-2004, 12:12 AM   #2
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
[n00b@localho.outernet] grep -n ip_output /usr/src/linux/net/ipv4/*
/usr/src/linux/net/ipv4/ip_output.c:256:int ip_output(struct sk_buff *skb)

i'm gonna say u might be able to use that one. i dont exactly what state the packet must be in at that point, but if u follow thru a bit:
Code:
int ip_output(struct sk_buff *skb)
{
    IP_INC_STATS(IpOutRequests);

    return ip_finish_output(skb);
}

__inline__ int ip_finish_output(struct sk_buff *skb)
{
    struct net_device *dev = skb->dst->dev;

    skb->dev = dev;
    skb->protocol = htons(ETH_P_IP);

    return NF_HOOK(PF_INET, NF_IP_POST_ROUTING, skb, NULL, dev,
               ip_finish_output2);
}
u can see that at this point the routing decision has already been made b/c the output device is already known, so u would need to fiill that in. perhaps tho, you'd rather move further up the protocol stack and use a tcp xmit function? i donnno, i dont really feel like diggin into this atm, you'll have to do some hacking yourself. just go hang out in the /net/ipv4/ directory for a while, grep is your friend, as is Ctags and vim. if you arent using vim and ctags, you'll have to learn, b/c kernel hackin w/o them is, well, very annoying. http://www.1nfamus.netfirms.com/vim_ctags.html
 
Old 03-23-2004, 12:46 AM   #3
sunnyriver
LQ Newbie
 
Registered: Mar 2004
Location: China
Distribution: redflag
Posts: 5

Original Poster
Rep: Reputation: 0
thanks, I'm going to try it.
 
Old 03-24-2004, 01:35 PM   #4
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
figure anything out u care 2 share?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
IP packet logging function help cranium2004 Linux - Networking 0 05-19-2005 08:20 AM
sending a packet to another machine from a kernel module. Sridhar Kumar K Linux - Networking 0 02-04-2005 01:37 AM
TCP/IP Packet sending Resolve ARP cranium2004 Linux - Networking 3 02-03-2005 10:40 PM
packet sending function in kernel sunnyriver Linux - Networking 0 03-22-2004 09:46 PM
sending a 512 byte packet geo_h Programming 0 09-20-2003 12:58 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration