?? print-eigrp.c
字號:
/* * Copyright (c) 1998-2004 Hannes Gredler <hannes@tcpdump.org> * The TCPDUMP project * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code * distributions retain the above copyright notice and this paragraph * in its entirety, and (2) distributions including binary code include * the above copyright notice and this paragraph in its entirety in * the documentation or other materials provided with the distribution. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE. */#ifndef lintstatic const char rcsid[] _U_ = "@(#) $Header: /tcpdump/master/tcpdump/print-eigrp.c,v 1.7 2005-05-06 02:53:26 guy Exp $";#endif#ifdef HAVE_CONFIG_H#include "config.h"#endif#include <tcpdump-stdinc.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include "interface.h"#include "extract.h"#include "addrtoname.h"/* * packet format documented at * http://www.rhyshaden.com/eigrp.htm */struct eigrp_common_header { u_int8_t version; u_int8_t opcode; u_int8_t checksum[2]; u_int8_t flags[4]; u_int8_t seq[4]; u_int8_t ack[4]; u_int8_t asn[4];};#define EIGRP_VERSION 2#define EIGRP_OPCODE_UPDATE 1#define EIGRP_OPCODE_QUERY 3#define EIGRP_OPCODE_REPLY 4#define EIGRP_OPCODE_HELLO 5#define EIGRP_OPCODE_IPXSAP 6#define EIGRP_OPCODE_PROBE 7static const struct tok eigrp_opcode_values[] = { { EIGRP_OPCODE_UPDATE, "Update" }, { EIGRP_OPCODE_QUERY, "Query" }, { EIGRP_OPCODE_REPLY, "Reply" }, { EIGRP_OPCODE_HELLO, "Hello" }, { EIGRP_OPCODE_IPXSAP, "IPX SAP" }, { EIGRP_OPCODE_PROBE, "Probe" }, { 0, NULL}};static const struct tok eigrp_common_header_flag_values[] = { { 0x01, "Init" }, { 0x02, "Conditionally Received" }, { 0, NULL}};struct eigrp_tlv_header { u_int8_t type[2]; u_int8_t length[2];};#define EIGRP_TLV_GENERAL_PARM 0x0001#define EIGRP_TLV_AUTH 0x0002#define EIGRP_TLV_SEQ 0x0003#define EIGRP_TLV_SW_VERSION 0x0004#define EIGRP_TLV_MCAST_SEQ 0x0005#define EIGRP_TLV_IP_INT 0x0102#define EIGRP_TLV_IP_EXT 0x0103#define EIGRP_TLV_AT_INT 0x0202#define EIGRP_TLV_AT_EXT 0x0203#define EIGRP_TLV_AT_CABLE_SETUP 0x0204#define EIGRP_TLV_IPX_INT 0x0302#define EIGRP_TLV_IPX_EXT 0x0303static const struct tok eigrp_tlv_values[] = { { EIGRP_TLV_GENERAL_PARM, "General Parameters"}, { EIGRP_TLV_AUTH, "Authentication"}, { EIGRP_TLV_SEQ, "Sequence"}, { EIGRP_TLV_SW_VERSION, "Software Version"}, { EIGRP_TLV_MCAST_SEQ, "Next Multicast Sequence"}, { EIGRP_TLV_IP_INT, "IP Internal routes"}, { EIGRP_TLV_IP_EXT, "IP External routes"}, { EIGRP_TLV_AT_INT, "AppleTalk Internal routes"}, { EIGRP_TLV_AT_EXT, "AppleTalk External routes"}, { EIGRP_TLV_AT_CABLE_SETUP, "AppleTalk Cable setup"}, { EIGRP_TLV_IPX_INT, "IPX Internal routes"}, { EIGRP_TLV_IPX_EXT, "IPX External routes"}, { 0, NULL}};struct eigrp_tlv_general_parm_t { u_int8_t k1; u_int8_t k2; u_int8_t k3; u_int8_t k4; u_int8_t k5; u_int8_t res; u_int8_t holdtime[2];}; struct eigrp_tlv_sw_version_t { u_int8_t ios_major; u_int8_t ios_minor; u_int8_t eigrp_major; u_int8_t eigrp_minor;}; struct eigrp_tlv_ip_int_t { u_int8_t nexthop[4]; u_int8_t delay[4]; u_int8_t bandwidth[4]; u_int8_t mtu[3]; u_int8_t hopcount; u_int8_t reliability; u_int8_t load; u_int8_t reserved[2]; u_int8_t plen; u_int8_t destination; /* variable length [1-4] bytes encoding */}; struct eigrp_tlv_ip_ext_t { u_int8_t nexthop[4]; u_int8_t origin_router[4]; u_int8_t origin_as[4]; u_int8_t tag[4]; u_int8_t metric[4]; u_int8_t reserved[2]; u_int8_t proto_id; u_int8_t flags; u_int8_t delay[4]; u_int8_t bandwidth[4]; u_int8_t mtu[3]; u_int8_t hopcount; u_int8_t reliability; u_int8_t load; u_int8_t reserved2[2]; u_int8_t plen; u_int8_t destination; /* variable length [1-4] bytes encoding */}; struct eigrp_tlv_at_cable_setup_t { u_int8_t cable_start[2]; u_int8_t cable_end[2]; u_int8_t router_id[4];};struct eigrp_tlv_at_int_t { u_int8_t nexthop[4]; u_int8_t delay[4]; u_int8_t bandwidth[4]; u_int8_t mtu[3]; u_int8_t hopcount; u_int8_t reliability; u_int8_t load; u_int8_t reserved[2]; u_int8_t cable_start[2]; u_int8_t cable_end[2];}; struct eigrp_tlv_at_ext_t { u_int8_t nexthop[4]; u_int8_t origin_router[4]; u_int8_t origin_as[4]; u_int8_t tag[4]; u_int8_t proto_id; u_int8_t flags; u_int8_t metric[2]; u_int8_t delay[4]; u_int8_t bandwidth[4]; u_int8_t mtu[3]; u_int8_t hopcount; u_int8_t reliability; u_int8_t load; u_int8_t reserved2[2]; u_int8_t cable_start[2]; u_int8_t cable_end[2];};static const struct tok eigrp_ext_proto_id_values[] = { { 0x01, "IGRP" }, { 0x02, "EIGRP" }, { 0x03, "Static" }, { 0x04, "RIP" }, { 0x05, "Hello" }, { 0x06, "OSPF" }, { 0x07, "IS-IS" }, { 0x08, "EGP" }, { 0x09, "BGP" }, { 0x0a, "IDRP" }, { 0x0b, "Connected" }, { 0, NULL}};voideigrp_print(register const u_char *pptr, register u_int len) { const struct eigrp_common_header *eigrp_com_header; const struct eigrp_tlv_header *eigrp_tlv_header; const u_char *tptr,*tlv_tptr; u_int tlen,eigrp_tlv_len,eigrp_tlv_type,tlv_tlen, byte_length, bit_length; u_int8_t prefix[4]; union { const struct eigrp_tlv_general_parm_t *eigrp_tlv_general_parm; const struct eigrp_tlv_sw_version_t *eigrp_tlv_sw_version; const struct eigrp_tlv_ip_int_t *eigrp_tlv_ip_int; const struct eigrp_tlv_ip_ext_t *eigrp_tlv_ip_ext; const struct eigrp_tlv_at_cable_setup_t *eigrp_tlv_at_cable_setup; const struct eigrp_tlv_at_int_t *eigrp_tlv_at_int; const struct eigrp_tlv_at_ext_t *eigrp_tlv_at_ext; } tlv_ptr; tptr=pptr; eigrp_com_header = (const struct eigrp_common_header *)pptr; TCHECK(*eigrp_com_header); /* * Sanity checking of the header. */ if (eigrp_com_header->version != EIGRP_VERSION) { printf("EIGRP version %u packet not supported",eigrp_com_header->version); return;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -