| 1 |
#include <stdio.h> |
| 2 |
#include <sys/socket.h> |
| 3 |
#include <sys/types.h> |
| 4 |
#include <netinet/in.h> |
| 5 |
#include <arpa/inet.h> |
| 6 |
|
| 7 |
#include "listen.h" |
| 8 |
|
| 9 |
void rspf_dump(unsigned char *data, int length) |
| 10 |
{ |
| 11 |
int bptr, nodes, links, adjs; |
| 12 |
|
| 13 |
lprintf(T_IPHDR, "RSPF: version %u ", data[0]); |
| 14 |
|
| 15 |
switch (data[1]) { |
| 16 |
case 3: /* RRH */ |
| 17 |
lprintf(T_IPHDR, "type RRH seq %#04x flags %d\n", |
| 18 |
ntohs(*((u_short *) (&data[8]))), data[10]); |
| 19 |
bptr = 11; |
| 20 |
while (bptr < length) |
| 21 |
lprintf(T_IPHDR, "%c", data[bptr++]); |
| 22 |
lprintf(T_IPHDR, "\n"); |
| 23 |
break; |
| 24 |
case 1: /*Routing update */ |
| 25 |
lprintf(T_IPHDR, "type ROUTING UPDATE "); |
| 26 |
lprintf(T_IPHDR, |
| 27 |
"fragment %u frag total %u sync %u #nodes %u env_id %u\n", |
| 28 |
data[2], data[3], data[6], data[7], |
| 29 |
ntohs(*((u_short *) (&data[8])))); |
| 30 |
|
| 31 |
bptr = data[6] + 6; |
| 32 |
nodes = data[7]; |
| 33 |
while (nodes-- && (length - bptr) > 7) { |
| 34 |
lprintf(T_DATA, |
| 35 |
" Reporting Router: %s Seq %u Subseq %u #links %u\n", |
| 36 |
inet_ntoa(* |
| 37 |
((struct in_addr |
| 38 |
*) (&data[bptr]))), |
| 39 |
ntohs(*((u_short *) (&data[bptr + 4]))), |
| 40 |
data[bptr + 6], data[bptr + 7]); |
| 41 |
links = data[bptr + 7]; |
| 42 |
bptr += 8; |
| 43 |
while (links-- && (length - bptr) > 4) { |
| 44 |
lprintf(T_DATA, |
| 45 |
" horizon %u ERP factor %u cost %u #adjacencies %u\n", |
| 46 |
data[bptr], data[bptr + 1], |
| 47 |
data[bptr + 2], data[bptr + 3]); |
| 48 |
adjs = data[bptr + 3]; |
| 49 |
bptr += 4; |
| 50 |
while (adjs-- && (length - bptr) > 4) { |
| 51 |
lprintf(T_DATA, |
| 52 |
" %s/%d \n", |
| 53 |
inet_ntoa(* |
| 54 |
((struct in_addr |
| 55 |
*) (&data[bptr |
| 56 |
+ |
| 57 |
1]))), |
| 58 |
data[bptr] & 0x3f); |
| 59 |
bptr += 5; |
| 60 |
} |
| 61 |
} |
| 62 |
} |
| 63 |
break; |
| 64 |
default: |
| 65 |
lprintf(T_ERROR, "Unknown packet type %d\n", data[1]); |
| 66 |
break; |
| 67 |
} |
| 68 |
} |