3 # Script for generation "oui.h" file (netdiscover program at
4 # http://nixgeneration.com/~jaime/netdiscover/
6 # Obtain data from internet source at:
7 # lynx -source http://standards.ieee.org/regauth/oui/oui.txt >oui.txt
9 # Syntax: oui.txt2oui.h_netdiscover
11 # Script generate src/oui.h file.
13 # 16-May-2009 Frantisek Hanzlik <franta@hanzlici.cz> (Original author)
14 # 07-Jun-2001 Larry Reznick <lreznick@rezfam.com> (fixes & code clean)
15 #**********************************************************************
17 # This program is free software; you can redistribute it and/or modify
18 # it under the terms of the GNU General Public License as published by
19 # the Free Software Foundation; either version 3 of the License, or
20 # (at your option) any later version.
24 DATE
=$
(date +'%Y%m%d')
28 URL
="http://standards.ieee.org/regauth/oui/oui.txt"
34 [ -d "$DSTD" ] ||
{ echo "$JA: Destdir \"$DSTD\" not exist!"; exit 1; }
35 #if ! [ -f "$TMPF" -a -s "$TMPF" ]; then
36 # echo "Trying download \"$ORIGF\" with lynx..."
37 # if ! lynx -source $URL >"$TMPF"; then
38 # echo "Trying download \"$ORIGF\" with elinks..."
39 # if ! elinks -source $URL >"$TMPF"; then
40 # echo "Trying download \"$ORIGF\" with wget..."
41 # if ! wget --quiet --output-document="$TMPF" $URL; then
42 # echo "$JA: Cann't obtain \"$URL\"!"
48 # echo "\"$TMPF\" already exist, skipping download..."
50 if ! [ -f "$TMPF" -a -s "$TMPF" ]; then
51 echo -n "Trying download \"$ORIGF\" with lynx..."
52 if [[ -x /usr
/bin
/lynx
]]; then
53 lynx
-source $URL >"$TMPF"
55 echo -n " with elinks..."
56 if [[ -x /usr
/bin
/elinks
]]; then
57 elinks
-source $URL >"$TMPF"
60 if [[ -x /usr
/bin
/wget
]]; then
61 wget
--quiet --output-document="$TMPF" $URL
63 echo "$JA: Can't obtain \"$URL\"!"
69 echo -n "\"$TMPF\" already exist, skipping download..."
73 echo "Process oui.txt (\"$TMPF\")..."
75 # if RS is null string, then records are separated by blank lines...
76 # but this isn't true in oui.txt
78 LANG
=C
$AWK --re-interval --assign URL
="$URL" '
80 RS = "\n([[:blank:]]*\n)+";
86 " * Organizationally Unique Identifier list at date %s\n" \
87 " * Automatically generated from %s\n" \
88 " * For Netdiscover by Jaime Penalba\n" \
93 " char *prefix; /* 24 bit global prefix */\n" \
94 " char *vendor; /* Vendor id string */\n" \
97 "struct oui oui_table[] = {\n", strftime("%d-%b-%Y"), URL);
100 (/[[:xdigit:]]{6}/) {
101 N1 = split($1,A1,/\t+/);
102 N2 = split($2,A2,/\t+/);
103 N3 = split(A2[1],PN,/ +/);
104 # printf("%i,%i,%i>%s<>%s<>%s< $1=%s<, $2=%s<, $3=%s<.\n",N1,N2,N3,PN[1],A1[2],A2[2],$1,$2,$3);
105 # V1 = gensub(/^[[:punct:]]+/,"",1,A1[2]);
106 # V2 = gensub(/^[[:punct:]]+/,"",1,A2[2]);
107 V1 = gensub(/^[[:blank:]]+/,"",1,A1[2]);
108 V2 = gensub(/^[[:blank:]]+/,"",1,A2[2]);
110 if (V0 ~ /^[[:blank:]]*$/) {
113 V = gensub(/\"/,"\\\\\"","g",V0);
115 printf(" { \"%s\", \"%s\" },\n", MI, MV);
123 " { \"%s\", \"%s\" },\n" \
124 " { NULL, NULL }\n" \
127 "// Total %i items.\n", MI, MV, NN);
128 }' <"$TMPF" >"$DSTD/$DSTF"
130 if [ $?
-ne 0 ]; then
131 echo "$JA: $TMPF parsing error !"
135 ls -oh oui.txt-
* src
/oui.h