Networking Forums

Networking Forums > Computer Networking > Linux Networking > C code for CIDR comparison

Reply
Thread Tools Display Modes

C code for CIDR comparison

 
 
Jem Berkes
Guest
Posts: n/a

 
      02-13-2004, 03:31 AM
I wrote a C function for one of my projects in order to compare an IP
address to a CIDR-style net specification (e.g. 66.54.64.0/19). Thought I'd
post the code here, in case anyone needs it.

It's in the form of a small utility that can be used as a stream filter,
for extracting IPs from a list that match a CIDR specification.

http://www.pc-tools.net/beta/cidr/cidr.c

Cheers,

--
Jem Berkes
http://www.sysdesign.ca/
 
Reply With Quote
 
 
 
 
Jem Berkes
Guest
Posts: n/a

 
      02-14-2004, 07:04 AM
> I wrote a C function for one of my projects in order to compare an IP
> address to a CIDR-style net specification (e.g. 66.54.64.0/19).
> Thought I'd post the code here, in case anyone needs it.
>
> It's in the form of a small utility that can be used as a stream
> filter, for extracting IPs from a list that match a CIDR
> specification.


An update, I've converted it into a more useful complete application:
http://www.pc-tools.net/unix/grepcidr/

grepcidr can be used as a stream filter when you need to compare a list of
IP addresses against one or more Classless Inter-Domain Routing (CIDR) mask
specifications. Think of grepcidr as a CIDR-aware grep; instead of using
'grep 1.2.3.4' you can use 'grepcidr 1.2.3.4/30', for example. Multiple
specifications, of arbitrary mask lengths, can be specified both on the
command line or loaded from a file.

--
Jem Berkes
http://www.sysdesign.ca/
 
Reply With Quote
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DNS -- reverse zone delegation on a CIDR subnet Vwaju Linux Networking 9 11-21-2008 11:06 AM
CIDR Shorthand Question Michael Ruebner Linux Networking 4 03-18-2006 11:38 PM
route add don't support CIDR route add �支�CIDR Windows Networking 2 02-15-2006 02:05 AM
Subnet, supernet and cidr calculator Clive Network Routers 3 11-03-2004 04:03 PM
Help with CIDR notation Siddharth Mathur Linux Networking 2 09-08-2003 04:10 PM



1 2 3 4 5 6 7 8 9 10 11