GithubHelp home page GithubHelp logo

wikimedia-incubator / libcidr Goto Github PK

View Code? Open in Web Editor NEW
2.0 5.0 1.0 1.63 MB

libcidr is a library that provides a number of functions to input, output, manipulate, compare, multilate, and otherwise play with, IP addresses and netblocks.

Home Page: http://www.over-yonder.net/~fullermd/projects/libcidr

License: Other

Perl 9.32% Shell 2.15% C 88.53%

libcidr's Introduction

NOTE! This repository has moved to:

https://github.com/wikimedia/analytics-libcidr

Overview

This is libcidr, a library to handle manipulating CIDR netblocks in IPv4 and IPv6 in a host of ways. It's useful for parsing textual representations of addresses and blocks, comparing blocks in various ways, and outputting them in different formats.

History

This repository was cloned from Matthew Fullers main bazaar repository using git-bzr-ng. The upstream branch is how the upstream repository looked at bzr revno 243 as of July 13 2012.

To bring in upstream changes:

# create a local bzr/libcidr branch from the upstream bazaar repository.
git-bzr import http://bzr.over-yonder.net/~fullermd/libcidr

# checkout master and merge the local branch into it.  There might be conflicts.
git checkout master
git merge bzr/libcidr

# resolve any conflicts.
git push

NOTE: I have not actually tried this, but I think it should work :)

Installation

To install from a release tarball, all you should need to do is a standard "make ; make install" procedure.

To install from a raw source tree, you'll need to either build the docs manually, or set NO_DOCS in your install environment. You may also need to run the mkgmake.sh script to generate GNU make Makefiles, if you use GNU make (this should be already done on released tarballs).

The Makefiles are written with the assumption that you're using gcc. There is, however, to my knowledge, nothing in the code that requires gcc specifically. The code is aimed at C99-compliant systems (with a few extremely common POSIX/SUS extensions in sample programs), but should work on most C89 systems as well. If you're using a compiler other than gcc, you may need to adjust the flags given to the compiler.

This library requires the POSIX/C99 uintX_t types, as well as basic IPv6 header file support. If your system lacks either of these, you can probably get the system to build by typedef'ing uint8_t as an unsigned char in the former case, and by removing the cidr_{from,to}_in6addr() functions in the latter. I've not tested this, and neither should be necessary on a reasonably modern system.

In both cases, there are a few variables you can tweak to determine where things get installed. Generally, you should only need to set PREFIX, and the other variables will be set based on that. See the beginning of the Makefile for more details if you need them.

PREFIX defaults to /usr/local, which is probably the right choice for most sites. Installation will install several things:

  • The shared library itself, in ${PREFIX}/lib,
  • The global header file libcidr.h, in ${PREFIX}/include,
  • The compiled cidrcalc example program, in ${PREFIX}/bin,
  • The libcidr(3) manpage, in ${PREFIX}/man/man3,
  • Several useful extra bits, under ${PREFIX}/share/libcidr:
    • The reference manual in various formats, under docs/
    • The source and Make infrastructure for the cidrcalc and acl example programs, under examples/

Roadmap

Here's a quick overview of the pieces of this dist. See README files in the various subdirs for more information about them.

  • docs/ - The documentation for libcidr, in various formats. See the README in here for more info.
  • include/ - The public header file which will be installed for programs using libcidr to #include, defining the various interfaces and flags.
  • src/ - The actual source for libcidr, as well as various examples and test programs. Particularly, the test and example programs are invaluable in understanding how the functions are meant to be used, and should certainly be perused by anybody looking at the functionality libcidr offers.
  • tools/ - Various bits&pieces of things used to build libcidr. No user-serviceable parts inside.

Support

libcidr is intended to be pretty self-explanatory, particularly with the aid of the example programs. And don't neglect the programs in test/; they're intended for me to use to test the functions when I write or change them, but because of that, they show how the functions work fairly cleanly. The mkstr program in particular, for its ability to exercise all the different flags to cidr_to_str(), is invaluable. libcidr is also very well documented, with the full reference manual explaining the calling conventions and usage of the various functions. And, I like to think the source is generally pretty readable in extremis.

However, if you have further questions or suggestions, please feel free to email me. See the project homepage at http://www.over-yonder.net/~fullermd/projects/libcidr for updates.

-- Matthew Fuller [email protected]

http://www.over-yonder.net/~fullermd/

To Do

Update to 1.2.1. Matthew recently updated his upstream libcidr to 1.2.1.
This includes changes in the build process that should make building packages easier.

libcidr's People

Contributors

fullermd avatar ottomata avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

karlpilkington

libcidr's Issues

added support for building libcidr.a :)

Hello Andrew,

I've just added static building of libcidr in the added_static_building_libcidr branch.
This is in order for us to be able to build a completely independent udp-filters binary(this is in order for us
to easily test and develop our udp-filters tommorow, because building the udp-filters debian package takes a bit of time
and in order to take development time as close as possible to zero I consider a static build of udp-filters to be appropriate).

Please review this and perhaps merge it with the debian/ branch (of course as you know, you can ignore the GNUMakefile* as they are automatically generated).

If review is succesful, please dpkg-buildpackage and upload the new packages to the debian repo.

Best regards,
Stefan

UPDATE: I've just built the udp-filters using libcidr.a , it produced a 1.2MB binary which works fine and we can
copy it around as we're testing stuff.

make error

(cd src && make all)
cc -fpic -DPIC -c -g -O2 -pipe -Wall -Wstrict-prototypes -Wredundant-decls -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-align -Wcast-qual -Wchar-subscripts -Winline -Wnested-externs -Wmissing-declarations -Wsign-compare -pedantic -I../include -Iinclude -std=c99 -D_XOPEN_SOURCE=600 -o cidr_addr.So cidr_addr.c
cc -fpic -DPIC -c -g -O2 -pipe -Wall -Wstrict-prototypes -Wredundant-decls -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-align -Wcast-qual -Wchar-subscripts -Winline -Wnested-externs -Wmissing-declarations -Wsign-compare -pedantic -I../include -Iinclude -std=c99 -D_XOPEN_SOURCE=600 -o cidr_compare.So cidr_compare.c
cc -fpic -DPIC -c -g -O2 -pipe -Wall -Wstrict-prototypes -Wredundant-decls -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-align -Wcast-qual -Wchar-subscripts -Winline -Wnested-externs -Wmissing-declarations -Wsign-compare -pedantic -I../include -Iinclude -std=c99 -D_XOPEN_SOURCE=600 -o cidr_from_str.So cidr_from_str.c
cc -fpic -DPIC -c -g -O2 -pipe -Wall -Wstrict-prototypes -Wredundant-decls -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-align -Wcast-qual -Wchar-subscripts -Winline -Wnested-externs -Wmissing-declarations -Wsign-compare -pedantic -I../include -Iinclude -std=c99 -D_XOPEN_SOURCE=600 -o cidr_get.So cidr_get.c
cc -fpic -DPIC -c -g -O2 -pipe -Wall -Wstrict-prototypes -Wredundant-decls -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-align -Wcast-qual -Wchar-subscripts -Winline -Wnested-externs -Wmissing-declarations -Wsign-compare -pedantic -I../include -Iinclude -std=c99 -D_XOPEN_SOURCE=600 -o cidr_inaddr.So cidr_inaddr.c
cc -fpic -DPIC -c -g -O2 -pipe -Wall -Wstrict-prototypes -Wredundant-decls -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-align -Wcast-qual -Wchar-subscripts -Winline -Wnested-externs -Wmissing-declarations -Wsign-compare -pedantic -I../include -Iinclude -std=c99 -D_XOPEN_SOURCE=600 -o cidr_mem.So cidr_mem.c
cc -fpic -DPIC -c -g -O2 -pipe -Wall -Wstrict-prototypes -Wredundant-decls -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-align -Wcast-qual -Wchar-subscripts -Winline -Wnested-externs -Wmissing-declarations -Wsign-compare -pedantic -I../include -Iinclude -std=c99 -D_XOPEN_SOURCE=600 -o cidr_misc.So cidr_misc.c
cc -fpic -DPIC -c -g -O2 -pipe -Wall -Wstrict-prototypes -Wredundant-decls -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-align -Wcast-qual -Wchar-subscripts -Winline -Wnested-externs -Wmissing-declarations -Wsign-compare -pedantic -I../include -Iinclude -std=c99 -D_XOPEN_SOURCE=600 -o cidr_net.So cidr_net.c
cc -fpic -DPIC -c -g -O2 -pipe -Wall -Wstrict-prototypes -Wredundant-decls -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-align -Wcast-qual -Wchar-subscripts -Winline -Wnested-externs -Wmissing-declarations -Wsign-compare -pedantic -I../include -Iinclude -std=c99 -D_XOPEN_SOURCE=600 -o cidr_num.So cidr_num.c
cc -fpic -DPIC -c -g -O2 -pipe -Wall -Wstrict-prototypes -Wredundant-decls -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-align -Wcast-qual -Wchar-subscripts -Winline -Wnested-externs -Wmissing-declarations -Wsign-compare -pedantic -I../include -Iinclude -std=c99 -D_XOPEN_SOURCE=600 -o cidr_to_str.So cidr_to_str.c
Linking libcidr.so.0...
cc -shared -Wl,-x -o libcidr.so.0 -Wl,-soname,libcidr.so.0
../tools/lorder cidr_addr.So cidr_compare.So cidr_from_str.So cidr_get.So cidr_inaddr.So cidr_mem.So cidr_misc.So cidr_net.So cidr_num.So cidr_to_str.So | tsort
usage: join [-a fileno | -v fileno ] [-e string] [-1 field] [-2 field]
[-o list] [-t char] file1 file2
ld: unknown option: -soname
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [libcidr.so.0] Error 1
make: *** [all] Error 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.