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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
04-09-2005, 02:19 AM
|
#1
|
|
Member
Registered: Oct 2004
Location: USA
Distribution: Fedora Core 3, Red Hat 9, CentOS 4.2, Mandriva, Ret Hat Enterprise Linux 4.0
Posts: 116
Rep:
|
Packet Transmission in the Kernel
Dear All,
I'm doing linux kernel programming for my senior year project at college. I've studied the tcp/ip implementation in kernel 2.4 to some extent, since i'm working on 2.4. So i was trying to transmit a test IP packet from scratch. This is being done as an extension to the kernel, in a file of my own. My implementation follows the way a packet is being transmitted in the kernel, specifically in the ip_output.c file. The problem i'm having is that when i try to find out the route for my destination using the ip_route_output() function i always get a null and hence the packet transmission doesn't occur. Here's where the problem occurs:
/* Get dst_entry if not present */
ip_route_output(&rt, dest, src, 0, dev-ifindex);
if(rt == NULL)
{
// some error and exit code
}
It turns out that rt is null. src and dest are the source and destination ip addresses in network byte order in hex. rt is defined as struct rtable* and dev is the transmitting device..that is eth0 in this case.
Does anyone have any clue about why rt is turning out to be null?
|
|
|
|
04-10-2005, 02:20 PM
|
#2
|
|
Member
Registered: Aug 2004
Location: India
Distribution: Redhat 9.0,FC3,FC5,FC10
Posts: 257
Rep:
|
Hi
Just guessing here...but you have initialized all your pointers..right and there are no "null" fields in the call itself?.For the last parameter check if you are using the right interface ; coz that parameter does look like an interface.Print out individual fields and isolate the problem and see what field is printing out as null.
gud luck
Arvind
|
|
|
|
04-10-2005, 04:18 PM
|
#3
|
|
Member
Registered: Oct 2004
Location: USA
Distribution: Fedora Core 3, Red Hat 9, CentOS 4.2, Mandriva, Ret Hat Enterprise Linux 4.0
Posts: 116
Original Poster
Rep:
|
Yea, i did initialize the fields as such:
__u32 src, dest; and then equated them to the hex values in net byte order
struct rtable* rt = NULL; and also tried not equating it to NULL...either way it doesn't make a difference.
rt has a lot many fields....i'll try the printing out approach. Thanks.
|
|
|
|
04-17-2005, 10:48 AM
|
#4
|
|
Member
Registered: Oct 2004
Location: USA
Distribution: Fedora Core 3, Red Hat 9, CentOS 4.2, Mandriva, Ret Hat Enterprise Linux 4.0
Posts: 116
Original Poster
Rep:
|
Didn't work. rt is coming out to be NULL persistently. It might be a network byte order issue, i dunno. Does this seem right:
I tried printing out rt->rt_src and rt->rt_dest but they send the kernel in panic!
__u32 src = 0xc0a80204; // for 192.168.2.4 i.e. the source address
__u32 dest = 0xc0a80203; // for 192.168.2.3 i.e. the destination address
I think this is in network byte order, am i wrong. So then isn't it correct if i pass it as this in:
ip_route_output( &rt, dest, src, 0, dev->ifindex);
Any one please tell me....i really need to get this done. Thanks in advance.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 04:19 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|