"compile" problem

  • Thread starter Alexander Bartzas
  • Start date
A

Alexander Bartzas

I'm trying to compile route.cpp part of the NetBench Suite (UCLA) and...:
cc packet.c radix.c route.c -o route

There is no problem in the compilation of the code but when I try to run
it...

Segmentation fault (core dumped)

I've located where the problem is... It is part of the following function's
code:

int rtrequest(int req, struct sockaddr *Dst, struct sockaddr *Gateway,
struct sockaddr *Netmask, int flags, class rtentry **ret_nrt)
{
register class rtentry *rt;
register class radix_node *rn;
register class radix_node_head *rnh;
struct ifaddr *ifa;
struct sockaddr *Ndst;
....

rt->rt_ifp = (struct ifnet *) ifa->ifa_ifp;

....}

rt_ifp is of type struct ifnet *

I don't what to do to overcome the problem.
Any help is welcomed.
Thanks in advance
Alexander Bartzas
 
D

Default User

Alexander Bartzas wrote:

register class rtentry *rt;

What is this supposed to be? You haven't defined the terms class or
rtentry.

rt->rt_ifp = (struct ifnet *) ifa->ifa_ifp;


Where was the pointer rt set to point to a valid object? Since you
skipped part of the code we can't tell. Why did you do that? If you knew
what the problem was, then you wouldn't need help.




Brian Rodenborn
 
D

Derk Gwen

# Segmentation fault (core dumped)

# rt->rt_ifp = (struct ifnet *) ifa->ifa_ifp;

# I don't what to do to overcome the problem.

Did you verify rt and ifa are valid pointers? You can do something like
fprintf(stderr,"rt=%p ifa=%p\n",rt,ifa);
on most machines they will be nonzeros and even numbers, perhaps multiples
of four. (Most machines represent null with zeros. Many machines require
pointers to be aligned; even if not aligned pointers can still be more
efficient and preferred.)
 
B

Barry Schwarz

# Segmentation fault (core dumped)

# rt->rt_ifp = (struct ifnet *) ifa->ifa_ifp;

# I don't what to do to overcome the problem.

Did you verify rt and ifa are valid pointers? You can do something like
fprintf(stderr,"rt=%p ifa=%p\n",rt,ifa);

You need to cast each of the pointers to void* to insure that fprintf
can process them correctly.
on most machines they will be nonzeros and even numbers, perhaps multiples
of four. (Most machines represent null with zeros. Many machines require
pointers to be aligned; even if not aligned pointers can still be more
efficient and preferred.)



<<Remove the del for email>>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top