netmask and route address check in busybox

Posted on March 21, 2009. Filed under: Linux |

http://sources.busybox.net/index.py/trunk/busybox/networking/route.c?view=log

http://www.cdncast.net/weibo/?p=702

/* sanity checks.. */
if (mask_in_addr(rt)) {
uint32_t mask = mask_in_addr(rt);

mask = ~ntohl(mask);
if ((rt.rt_flags & RTF_HOST) && mask != 0xffffffff) {
bb_error_msg_and_die(“netmask %.8x and host route conflict”,
(unsigned int) mask);
}
if (mask & (mask + 1)) {
bb_error_msg_and_die(“bogus netmask %s”, netmask);
}
mask = ((struct sockaddr_in *) &rt.rt_dst)->sin_addr.s_addr;
if (mask & ~(uint32_t)mask_in_addr(rt)) {
bb_error_msg_and_die(“netmask and route address conflict”);
}
}

/* Fill out netmask if still unset */
if ((action == RTACTION_ADD) && (rt.rt_flags & RTF_HOST)) {
mask_in_addr(rt) = 0xffffffff;
}

Advertisements

Make a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Liked it here?
Why not try sites on the blogroll...

%d bloggers like this: