Fast conversion of IPv4 ranges into CIDR form

Timothy Rice db03541c74 Add licence 6 лет назад
.gitignore 2a1d0d9c06 Initial commit 6 лет назад
LICENSE.md db03541c74 Add licence 6 лет назад
Makefile 2a1d0d9c06 Initial commit 6 лет назад
README.md 9386fe3157 Add README 6 лет назад
args.h 2a1d0d9c06 Initial commit 6 лет назад
cider.c 2a1d0d9c06 Initial commit 6 лет назад
io.c 2a1d0d9c06 Initial commit 6 лет назад
io.h 2a1d0d9c06 Initial commit 6 лет назад
parse.c 2a1d0d9c06 Initial commit 6 лет назад
parse.h 2a1d0d9c06 Initial commit 6 лет назад

README.md

Cider

Convert IPv4 ranges into CIDR form.

A faster and more script-friendly version of ipcalc's deaggregation function.

Usage

cider [-?hvV] [--help] [--help] [--usage] [--version] [--version] [file]

  -?, --help                 Give this help list
  -h, --help                 Print this help message.
      --usage                Give a short usage message
  -v, --version              Print version information.
  -V, --version              Print program version

If [file] is omitted, Cider will read from stdin.

Examples

Read from stdin:

$ cider <<< 192.168.0.128-192.168.1.255
192.168.0.128/25
192.168.1.0/24

Read from a file:

$ cat > /tmp/10.x.x.x << EOF
> 10.0.0.0-10.255.255.255
> EOF
$ cider /tmp/10.x.x.x
10.0.0.0/8

Convert all Australian ranges:

$ curl -s https://www.nirsoft.net/countryip/au.csv | awk -F, '{OFS="-"; print $1, $2}' | cider
1.40.0.0/14
1.44.0.0/16
1.120.0.0/13
1.128.0.0/11
1.178.0.0/16
1.179.0.0/17
14.2.0.0/16
14.137.0.0/17
14.137.128.0/18
... (truncated)

Dependencies

Gnu C Library

Other libcs may or may not work, depending on whether they ship with their own variants of sys/socket.h, netinet/in.h and arpa/inet.h.