Changeset 1453435
- Timestamp:
- 01/06/12 16:43:16 (9 years ago)
- Branches:
- 4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
- Children:
- cb64286
- Parents:
- f46f7f4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/libtrace.h.in
rf46f7f4 r1453435 765 765 typedef struct libtrace_ospf_v2_t 766 766 { 767 uint8_t ospf_v; 768 uint8_t type; 769 uint16_t len; 770 struct in_addr router; 771 struct in_addr area; 772 uint16_t sum; 773 uint16_t au_type; 774 uint16_t zero; 775 uint8_t au_key_id; 776 uint8_t au_data_len; 777 uint32_t au_seq_num; 767 uint8_t ospf_v; /**< OSPF Version, should be 2 */ 768 uint8_t type; /**< OSPF Packet Type */ 769 uint16_t len; /**< Packet length, including OSPF header */ 770 struct in_addr router; /**< Router ID of the packet source */ 771 struct in_addr area; /**< Area the packet belongs to */ 772 uint16_t sum; /**< Checksum */ 773 uint16_t au_type; /**< Authentication procedure */ 774 uint16_t zero; /**< Always zero */ 775 uint8_t au_key_id; /**< Authentication Key ID */ 776 uint8_t au_data_len; /**< Authentication Data Length */ 777 uint32_t au_seq_num; /**< Cryptographic Sequence Number */ 778 778 } PACKED libtrace_ospf_v2_t; 779 779 780 /** Options Field present in some OSPFv2 packets */ 780 781 typedef struct libtrace_ospf_options_t { 781 782 #if BYTE_ORDER == LITTLE_ENDIAN … … 798 799 } PACKED libtrace_ospf_options_t; 799 800 801 /* LSA Header for OSPFv2 */ 800 802 typedef struct libtrace_ospf_lsa_v2_t 801 803 { 802 uint16_t age; 803 libtrace_ospf_options_t lsa_options; 804 uint8_t lsa_type; 805 struct in_addr ls_id; 806 struct in_addr adv_router; 807 uint32_t seq; 808 uint16_t checksum; 809 uint16_t length; 804 uint16_t age; /**< Time in seconds since LSA originated */ 805 libtrace_ospf_options_t lsa_options; /**< Options */ 806 uint8_t lsa_type; /**< LSA type */ 807 struct in_addr ls_id; /**< Link State ID */ 808 struct in_addr adv_router; /**< Router that originated this LSA */ 809 uint32_t seq; /**< LS sequence number */ 810 uint16_t checksum; /**< Checksum */ 811 uint16_t length; /**< Length of the LSA including LSA header */ 810 812 } PACKED libtrace_ospf_lsa_v2_t; 811 813 814 /** OSPFv2 Hello Packet */ 812 815 typedef struct libtrace_ospf_hello_v2_t 813 816 { 814 struct in_addr mask; 815 uint16_t interval; 816 libtrace_ospf_options_t hello_options; 817 uint8_t priority; 818 uint32_t deadint; 819 struct in_addr designated; 820 struct in_addr backup; 821 struct in_addr neighbor; 817 struct in_addr mask; /**< Network mask for this interface */ 818 uint16_t interval; /**< Interval between Hello packets (secs) */ 819 libtrace_ospf_options_t hello_options; /**< Options */ 820 uint8_t priority; /**< Router Priority */ 821 uint32_t deadint; /**< Interval before declaring a router down */ 822 struct in_addr designated; /**< Designated router for the network */ 823 struct in_addr backup; /**< Backup designated router */ 824 825 /** Neighbors follow from here, but there can be anywhere from 1 to N 826 * neighbors so I can't include that here */ 822 827 } PACKED libtrace_ospf_hello_v2_t; 823 828 829 /** OSPFv2 Database Description packet */ 824 830 typedef struct libtrace_ospf_db_desc_v2_t 825 831 { 826 uint16_t mtu; 827 uint8_t db_desc_options;832 uint16_t mtu; /**< Interface MTU */ 833 libtrace_ospf_options_t db_desc_options; /**< Options */ 828 834 #if BYTE_ORDER == LITTLE_ENDIAN 829 LT_BITFIELD8 db_desc_ms:1; 830 LT_BITFIELD8 db_desc_m:1; 831 LT_BITFIELD8 db_desc_i:1; 835 LT_BITFIELD8 db_desc_ms:1; /**< If set, this router is the master */ 836 LT_BITFIELD8 db_desc_m:1; /**< If set, more packets to follow */ 837 LT_BITFIELD8 db_desc_i:1; /**< If set, this is the first packet in sequence */ 832 838 LT_BITFIELD8 zero:5; 833 839 #elif BYTE_ORDER == BIG_ENDIAN 834 840 LT_BITFIELD8 zero:5; 835 LT_BITFIELD8 db_desc_i:1; 836 LT_BITFIELD8 db_desc_m:1; 837 LT_BITFIELD8 db_desc_ms:1; 841 LT_BITFIELD8 db_desc_i:1; /**< If set, this is the first packet in sequence */ 842 LT_BITFIELD8 db_desc_m:1; /**< If set, more packets to follow */ 843 LT_BITFIELD8 db_desc_ms:1; /**< If set, this router is the master */ 838 844 #endif 839 uint32_t seq; 845 uint32_t seq; /**< Sequence number for DD packets */ 840 846 } PACKED libtrace_ospf_db_desc_v2_t; 841 847 848 /** OSPF Link State Request Packet */ 842 849 typedef struct libtrace_ospf_ls_req_t 843 850 { 844 uint32_t ls_type; 845 uint32_t ls_id; 846 uint32_t advertising_router; 851 uint32_t ls_type; /**< Link State Type */ 852 uint32_t ls_id; /**< Link State Id */ 853 uint32_t advertising_router; /**< Advertising Router */ 847 854 } PACKED libtrace_ospf_ls_req_t; 848 855 856 /** OSPF Link State Update Packet */ 849 857 typedef struct libtrace_ospf_ls_update_t 850 858 { 851 uint32_t ls_num_adv; 859 uint32_t ls_num_adv; /**< Number of LSAs in this packet */ 860 861 /* Followed by LSAs, use API functions to access these */ 852 862 } PACKED libtrace_ospf_ls_update_t; 853 863 864 /** OSPFv2 AS External LSA Body */ 854 865 typedef struct libtrace_ospf_as_external_lsa_t 855 866 { 856 struct in_addr netmask; 867 struct in_addr netmask; /**< Netmask for the destination */ 857 868 #if BYTE_ORDER == LITTLE_ENDIAN 858 869 LT_BITFIELD8 tos:7; 859 LT_BITFIELD8 e:1; 870 LT_BITFIELD8 e:1; /**< If set, metric is Type 2. Else, Type 1 */ 860 871 #elif BYTE_ORDER == BIG_ENDIAN 861 LT_BITFIELD8 e:1; 872 LT_BITFIELD8 e:1; /**< If set, metric is Type 2. Else, Type 1 */ 862 873 LT_BITFIELD8 tos:7; 863 874 #endif 864 uint8_t metric_a; 865 uint8_t metric_b; 866 uint8_t metric_c; 867 struct in_addr forwarding; 868 uint32_t external_tag; 875 uint8_t metric_a; /**< Byte 1 of the Metric field */ 876 uint8_t metric_b; /**< Byte 2 of the Metric field */ 877 uint8_t metric_c; /**< Byte 3 of the Metric field */ 878 struct in_addr forwarding; /**< Forwarding address */ 879 uint32_t external_tag; /**< External Route Tag */ 869 880 } PACKED libtrace_ospf_as_external_lsa_v2_t; 870 881 882 /** OSPFv2 Summary LSA Body */ 871 883 typedef struct libtrace_ospf_summary_lsa 872 884 { 873 struct in_addr netmask; 874 uint8_t zero; 875 uint8_t metric_a; 876 uint8_t metric_b; 877 uint8_t metric_c; 885 struct in_addr netmask; /**< Netmask for the destination */ 886 uint8_t zero; /**< Always zero */ 887 uint8_t metric_a; /**< Byte 1 of the Metric field */ 888 uint8_t metric_b; /**< Byte 2 of the Metric field */ 889 uint8_t metric_c; /**< Byte 3 of the Metric field */ 878 890 879 891 } PACKED libtrace_ospf_summary_lsa_v2_t; 880 892 893 /** OSPFv2 Network LSA Body */ 881 894 typedef struct libtrace_ospf_network_lsa_t 882 895 { 883 struct in_addr netmask; 896 struct in_addr netmask; /**< Netmask for the network */ 897 /* Followed by IDs of attached routers */ 884 898 } PACKED libtrace_ospf_network_lsa_v2_t; 885 899 900 /** OSPFv2 Router Link structure */ 886 901 typedef struct libtrace_ospf_link_t 887 902 { 888 struct in_addr link_id; 889 struct in_addr link_data; 890 uint8_t type; 891 uint8_t num_tos; 892 uint16_t tos_metric; 903 struct in_addr link_id; /**< Object that link connects to */ 904 struct in_addr link_data; /**< Link Data field */ 905 uint8_t type; /**< Link Type */ 906 uint8_t num_tos; /**< Number of TOS metrics */ 907 uint16_t tos_metric; /**< Cost of router link */ 893 908 } PACKED libtrace_ospf_link_v2_t; 894 909 910 /** OSPFv2 Router LSA */ 895 911 typedef struct libtrace_ospf_router_lsa_t 896 912 { 897 913 #if BYTE_ORDER == LITTLE_ENDIAN 898 LT_BITFIELD8 b:1; 899 LT_BITFIELD8 e:1; 900 LT_BITFIELD8 v:1; 914 LT_BITFIELD8 b:1; /**< Area Border Router Flag */ 915 LT_BITFIELD8 e:1; /**< External Router Flag */ 916 LT_BITFIELD8 v:1; /**< Virtual Endpoint Flag */ 901 917 LT_BITFIELD8 zero:5; 902 918 #elif BYTE_ORDER == BIG_ENDIAN 903 919 LT_BITFIELD8 zero:5; 904 LT_BITFIELD8 v:1; 905 LT_BITFIELD8 e:1; 906 LT_BITFIELD8 b:1; 920 LT_BITFIELD8 v:1; /**< Virtual Endpoint Flag */ 921 LT_BITFIELD8 e:1; /**< External Router Flag */ 922 LT_BITFIELD8 b:1; /**< Area Border Router Flag */ 907 923 #endif 908 uint8_t zero2; 909 uint16_t num_links; 924 uint8_t zero2; /**< Always zero */ 925 uint16_t num_links; /**< Number of links in LSA */ 910 926 } PACKED libtrace_ospf_router_lsa_v2_t; 911 927 912 928 typedef enum { 913 TRACE_OSPF_HELLO = 1, 914 TRACE_OSPF_DATADESC = 2, 915 TRACE_OSPF_LSREQ = 3, 916 TRACE_OSPF_LSUPDATE = 4, 917 TRACE_OSPF_LSACK = 5 929 TRACE_OSPF_HELLO = 1, /**< OSPF Hello */ 930 TRACE_OSPF_DATADESC = 2, /**< OSPF Database Description */ 931 TRACE_OSPF_LSREQ = 3, /**< OSPF Link State Request */ 932 TRACE_OSPF_LSUPDATE = 4, /**< OSPF Link State Update */ 933 TRACE_OSPF_LSACK = 5 /**< OSPF Link State Acknowledgement */ 918 934 } libtrace_ospf_types_t; 919 935 920 936 typedef enum { 921 TRACE_OSPF_LS_ROUTER = 1, 922 TRACE_OSPF_LS_NETWORK = 2, 923 TRACE_OSPF_LS_SUMMARY = 3, 924 TRACE_OSPF_LS_ASBR_SUMMARY = 4, 925 TRACE_OSPF_LS_EXTERNAL = 5 937 TRACE_OSPF_LS_ROUTER = 1, /**< OSPF Router LSA */ 938 TRACE_OSPF_LS_NETWORK = 2, /**< OSPF Network LSA */ 939 TRACE_OSPF_LS_SUMMARY = 3, /**< OSPF Summary LSA */ 940 TRACE_OSPF_LS_ASBR_SUMMARY = 4, /**< OSPF Summary LSA (ASBR) */ 941 TRACE_OSPF_LS_EXTERNAL = 5 /**< OSPF AS External LSA */ 926 942 } libtrace_ospf_ls_types_t; 927 943 -
libpacketdump/ospf2_1.c
re224862 r1453435 10 10 11 11 libtrace_ospf_hello_v2_t *hello = (libtrace_ospf_hello_v2_t *)packet; 12 12 struct in_addr *neigh; 13 13 14 if (len < 4) 14 15 return; … … 53 54 return; 54 55 55 printf(" OSPF Hello: Designated Router :%s\n", inet_ntoa(hello->designated));56 printf(" OSPF Hello: Designated Router %s\n", inet_ntoa(hello->designated)); 56 57 57 58 if (len < 20) 58 59 return; 59 60 60 printf(" OSPF Hello: Backup Designated Router :%s\n", inet_ntoa(hello->backup));61 printf(" OSPF Hello: Backup Designated Router %s\n", inet_ntoa(hello->backup)); 61 62 62 if (len < 24) 63 return; 64 65 printf(" OSPF Hello: Neighbour: %s\n", inet_ntoa(hello->backup)); 63 neigh = (struct in_addr *)(packet + sizeof(libtrace_ospf_hello_v2_t)); 64 len -= sizeof(libtrace_ospf_hello_v2_t); 65 while (len >= 4) { 66 printf(" OSPF Hello: Neighbour %s\n", inet_ntoa(*neigh)); 67 neigh++; 68 len -= sizeof(struct in_addr); 69 } 70 71 66 72 67 73 return;
Note: See TracChangeset
for help on using the changeset viewer.