JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1 | /* NetBSD: print-juniper.c,v 1.2 2007/07/24 11:53:45 drochner Exp */ |
| 2 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 3 | /* |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that: (1) source code |
| 6 | * distributions retain the above copyright notice and this paragraph |
| 7 | * in its entirety, and (2) distributions including binary code include |
| 8 | * the above copyright notice and this paragraph in its entirety in |
| 9 | * the documentation or other materials provided with the distribution. |
| 10 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND |
| 11 | * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT |
| 12 | * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 13 | * FOR A PARTICULAR PURPOSE. |
| 14 | * |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 15 | * Original code by Hannes Gredler (hannes@gredler.at) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 16 | */ |
| 17 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 18 | /* \summary: DLT_JUNIPER_* printers */ |
| 19 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 20 | #ifndef lint |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 21 | #else |
| 22 | __RCSID("NetBSD: print-juniper.c,v 1.3 2007/07/25 06:31:32 dogcow Exp "); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 23 | #endif |
| 24 | |
| 25 | #ifdef HAVE_CONFIG_H |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 26 | #include <config.h> |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 27 | #endif |
| 28 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 29 | #include "netdissect-stdinc.h" |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 30 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 31 | #include <string.h> |
| 32 | |
| 33 | #include "netdissect.h" |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 34 | #include "addrtoname.h" |
| 35 | #include "extract.h" |
| 36 | #include "ppp.h" |
| 37 | #include "llc.h" |
| 38 | #include "nlpid.h" |
| 39 | #include "ethertype.h" |
| 40 | #include "atm.h" |
| 41 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 42 | /* |
| 43 | * If none of the Juniper DLT_s are defined, there's nothing to do. |
| 44 | */ |
| 45 | #if defined(DLT_JUNIPER_GGSN) || defined(DLT_JUNIPER_ES) || \ |
| 46 | defined(DLT_JUNIPER_MONITOR) || defined(DLT_JUNIPER_SERVICES) || \ |
| 47 | defined(DLT_JUNIPER_PPPOE) || defined(DLT_JUNIPER_ETHER) || \ |
| 48 | defined(DLT_JUNIPER_PPP) || defined(DLT_JUNIPER_FRELAY) || \ |
| 49 | defined(DLT_JUNIPER_CHDLC) || defined(DLT_JUNIPER_PPPOE_ATM) || \ |
| 50 | defined(DLT_JUNIPER_MLPPP) || defined(DLT_JUNIPER_MFR) || \ |
| 51 | defined(DLT_JUNIPER_MLFR) || defined(DLT_JUNIPER_ATM1) || \ |
| 52 | defined(DLT_JUNIPER_ATM2) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 53 | #define JUNIPER_BPF_OUT 0 /* Outgoing packet */ |
| 54 | #define JUNIPER_BPF_IN 1 /* Incoming packet */ |
| 55 | #define JUNIPER_BPF_PKT_IN 0x1 /* Incoming packet */ |
| 56 | #define JUNIPER_BPF_NO_L2 0x2 /* L2 header stripped */ |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 57 | #define JUNIPER_BPF_IIF 0x4 /* IIF is valid */ |
| 58 | #define JUNIPER_BPF_FILTER 0x40 /* BPF filtering is supported */ |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 59 | #define JUNIPER_BPF_EXT 0x80 /* extensions present */ |
| 60 | #define JUNIPER_MGC_NUMBER 0x4d4743 /* = "MGC" */ |
| 61 | |
| 62 | #define JUNIPER_LSQ_COOKIE_RE (1 << 3) |
| 63 | #define JUNIPER_LSQ_COOKIE_DIR (1 << 2) |
| 64 | #define JUNIPER_LSQ_L3_PROTO_SHIFT 4 |
| 65 | #define JUNIPER_LSQ_L3_PROTO_MASK (0x17 << JUNIPER_LSQ_L3_PROTO_SHIFT) |
| 66 | #define JUNIPER_LSQ_L3_PROTO_IPV4 (0 << JUNIPER_LSQ_L3_PROTO_SHIFT) |
| 67 | #define JUNIPER_LSQ_L3_PROTO_IPV6 (1 << JUNIPER_LSQ_L3_PROTO_SHIFT) |
| 68 | #define JUNIPER_LSQ_L3_PROTO_MPLS (2 << JUNIPER_LSQ_L3_PROTO_SHIFT) |
| 69 | #define JUNIPER_LSQ_L3_PROTO_ISO (3 << JUNIPER_LSQ_L3_PROTO_SHIFT) |
| 70 | #define AS_PIC_COOKIE_LEN 8 |
| 71 | |
| 72 | #define JUNIPER_IPSEC_O_ESP_ENCRYPT_ESP_AUTHEN_TYPE 1 |
| 73 | #define JUNIPER_IPSEC_O_ESP_ENCRYPT_AH_AUTHEN_TYPE 2 |
| 74 | #define JUNIPER_IPSEC_O_ESP_AUTHENTICATION_TYPE 3 |
| 75 | #define JUNIPER_IPSEC_O_AH_AUTHENTICATION_TYPE 4 |
| 76 | #define JUNIPER_IPSEC_O_ESP_ENCRYPTION_TYPE 5 |
| 77 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 78 | #ifdef DLT_JUNIPER_ES |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 79 | static const struct tok juniper_ipsec_type_values[] = { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 80 | { JUNIPER_IPSEC_O_ESP_ENCRYPT_ESP_AUTHEN_TYPE, "ESP ENCR-AUTH" }, |
| 81 | { JUNIPER_IPSEC_O_ESP_ENCRYPT_AH_AUTHEN_TYPE, "ESP ENCR-AH AUTH" }, |
| 82 | { JUNIPER_IPSEC_O_ESP_AUTHENTICATION_TYPE, "ESP AUTH" }, |
| 83 | { JUNIPER_IPSEC_O_AH_AUTHENTICATION_TYPE, "AH AUTH" }, |
| 84 | { JUNIPER_IPSEC_O_ESP_ENCRYPTION_TYPE, "ESP ENCR" }, |
| 85 | { 0, NULL} |
| 86 | }; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 87 | #endif |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 88 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 89 | static const struct tok juniper_direction_values[] = { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 90 | { JUNIPER_BPF_IN, "In"}, |
| 91 | { JUNIPER_BPF_OUT, "Out"}, |
| 92 | { 0, NULL} |
| 93 | }; |
| 94 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 95 | /* codepoints for encoding extensions to a .pcap file */ |
| 96 | enum { |
| 97 | JUNIPER_EXT_TLV_IFD_IDX = 1, |
| 98 | JUNIPER_EXT_TLV_IFD_NAME = 2, |
| 99 | JUNIPER_EXT_TLV_IFD_MEDIATYPE = 3, |
| 100 | JUNIPER_EXT_TLV_IFL_IDX = 4, |
| 101 | JUNIPER_EXT_TLV_IFL_UNIT = 5, |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 102 | JUNIPER_EXT_TLV_IFL_ENCAPS = 6, |
| 103 | JUNIPER_EXT_TLV_TTP_IFD_MEDIATYPE = 7, |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 104 | JUNIPER_EXT_TLV_TTP_IFL_ENCAPS = 8 |
| 105 | }; |
| 106 | |
| 107 | /* 1 byte type and 1-byte length */ |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 108 | #define JUNIPER_EXT_TLV_OVERHEAD 2U |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 109 | |
| 110 | static const struct tok jnx_ext_tlv_values[] = { |
| 111 | { JUNIPER_EXT_TLV_IFD_IDX, "Device Interface Index" }, |
| 112 | { JUNIPER_EXT_TLV_IFD_NAME,"Device Interface Name" }, |
| 113 | { JUNIPER_EXT_TLV_IFD_MEDIATYPE, "Device Media Type" }, |
| 114 | { JUNIPER_EXT_TLV_IFL_IDX, "Logical Interface Index" }, |
| 115 | { JUNIPER_EXT_TLV_IFL_UNIT,"Logical Unit Number" }, |
| 116 | { JUNIPER_EXT_TLV_IFL_ENCAPS, "Logical Interface Encapsulation" }, |
| 117 | { JUNIPER_EXT_TLV_TTP_IFD_MEDIATYPE, "TTP derived Device Media Type" }, |
| 118 | { JUNIPER_EXT_TLV_TTP_IFL_ENCAPS, "TTP derived Logical Interface Encapsulation" }, |
| 119 | { 0, NULL } |
| 120 | }; |
| 121 | |
| 122 | static const struct tok jnx_flag_values[] = { |
| 123 | { JUNIPER_BPF_EXT, "Ext" }, |
| 124 | { JUNIPER_BPF_FILTER, "Filter" }, |
| 125 | { JUNIPER_BPF_IIF, "IIF" }, |
| 126 | { JUNIPER_BPF_NO_L2, "no-L2" }, |
| 127 | { JUNIPER_BPF_PKT_IN, "In" }, |
| 128 | { 0, NULL } |
| 129 | }; |
| 130 | |
| 131 | #define JUNIPER_IFML_ETHER 1 |
| 132 | #define JUNIPER_IFML_FDDI 2 |
| 133 | #define JUNIPER_IFML_TOKENRING 3 |
| 134 | #define JUNIPER_IFML_PPP 4 |
| 135 | #define JUNIPER_IFML_FRAMERELAY 5 |
| 136 | #define JUNIPER_IFML_CISCOHDLC 6 |
| 137 | #define JUNIPER_IFML_SMDSDXI 7 |
| 138 | #define JUNIPER_IFML_ATMPVC 8 |
| 139 | #define JUNIPER_IFML_PPP_CCC 9 |
| 140 | #define JUNIPER_IFML_FRAMERELAY_CCC 10 |
| 141 | #define JUNIPER_IFML_IPIP 11 |
| 142 | #define JUNIPER_IFML_GRE 12 |
| 143 | #define JUNIPER_IFML_PIM 13 |
| 144 | #define JUNIPER_IFML_PIMD 14 |
| 145 | #define JUNIPER_IFML_CISCOHDLC_CCC 15 |
| 146 | #define JUNIPER_IFML_VLAN_CCC 16 |
| 147 | #define JUNIPER_IFML_MLPPP 17 |
| 148 | #define JUNIPER_IFML_MLFR 18 |
| 149 | #define JUNIPER_IFML_ML 19 |
| 150 | #define JUNIPER_IFML_LSI 20 |
| 151 | #define JUNIPER_IFML_DFE 21 |
| 152 | #define JUNIPER_IFML_ATM_CELLRELAY_CCC 22 |
| 153 | #define JUNIPER_IFML_CRYPTO 23 |
| 154 | #define JUNIPER_IFML_GGSN 24 |
| 155 | #define JUNIPER_IFML_LSI_PPP 25 |
| 156 | #define JUNIPER_IFML_LSI_CISCOHDLC 26 |
| 157 | #define JUNIPER_IFML_PPP_TCC 27 |
| 158 | #define JUNIPER_IFML_FRAMERELAY_TCC 28 |
| 159 | #define JUNIPER_IFML_CISCOHDLC_TCC 29 |
| 160 | #define JUNIPER_IFML_ETHERNET_CCC 30 |
| 161 | #define JUNIPER_IFML_VT 31 |
| 162 | #define JUNIPER_IFML_EXTENDED_VLAN_CCC 32 |
| 163 | #define JUNIPER_IFML_ETHER_OVER_ATM 33 |
| 164 | #define JUNIPER_IFML_MONITOR 34 |
| 165 | #define JUNIPER_IFML_ETHERNET_TCC 35 |
| 166 | #define JUNIPER_IFML_VLAN_TCC 36 |
| 167 | #define JUNIPER_IFML_EXTENDED_VLAN_TCC 37 |
| 168 | #define JUNIPER_IFML_CONTROLLER 38 |
| 169 | #define JUNIPER_IFML_MFR 39 |
| 170 | #define JUNIPER_IFML_LS 40 |
| 171 | #define JUNIPER_IFML_ETHERNET_VPLS 41 |
| 172 | #define JUNIPER_IFML_ETHERNET_VLAN_VPLS 42 |
| 173 | #define JUNIPER_IFML_ETHERNET_EXTENDED_VLAN_VPLS 43 |
| 174 | #define JUNIPER_IFML_LT 44 |
| 175 | #define JUNIPER_IFML_SERVICES 45 |
| 176 | #define JUNIPER_IFML_ETHER_VPLS_OVER_ATM 46 |
| 177 | #define JUNIPER_IFML_FR_PORT_CCC 47 |
| 178 | #define JUNIPER_IFML_FRAMERELAY_EXT_CCC 48 |
| 179 | #define JUNIPER_IFML_FRAMERELAY_EXT_TCC 49 |
| 180 | #define JUNIPER_IFML_FRAMERELAY_FLEX 50 |
| 181 | #define JUNIPER_IFML_GGSNI 51 |
| 182 | #define JUNIPER_IFML_ETHERNET_FLEX 52 |
| 183 | #define JUNIPER_IFML_COLLECTOR 53 |
| 184 | #define JUNIPER_IFML_AGGREGATOR 54 |
| 185 | #define JUNIPER_IFML_LAPD 55 |
| 186 | #define JUNIPER_IFML_PPPOE 56 |
| 187 | #define JUNIPER_IFML_PPP_SUBORDINATE 57 |
| 188 | #define JUNIPER_IFML_CISCOHDLC_SUBORDINATE 58 |
| 189 | #define JUNIPER_IFML_DFC 59 |
| 190 | #define JUNIPER_IFML_PICPEER 60 |
| 191 | |
| 192 | static const struct tok juniper_ifmt_values[] = { |
| 193 | { JUNIPER_IFML_ETHER, "Ethernet" }, |
| 194 | { JUNIPER_IFML_FDDI, "FDDI" }, |
| 195 | { JUNIPER_IFML_TOKENRING, "Token-Ring" }, |
| 196 | { JUNIPER_IFML_PPP, "PPP" }, |
| 197 | { JUNIPER_IFML_PPP_SUBORDINATE, "PPP-Subordinate" }, |
| 198 | { JUNIPER_IFML_FRAMERELAY, "Frame-Relay" }, |
| 199 | { JUNIPER_IFML_CISCOHDLC, "Cisco-HDLC" }, |
| 200 | { JUNIPER_IFML_SMDSDXI, "SMDS-DXI" }, |
| 201 | { JUNIPER_IFML_ATMPVC, "ATM-PVC" }, |
| 202 | { JUNIPER_IFML_PPP_CCC, "PPP-CCC" }, |
| 203 | { JUNIPER_IFML_FRAMERELAY_CCC, "Frame-Relay-CCC" }, |
| 204 | { JUNIPER_IFML_FRAMERELAY_EXT_CCC, "Extended FR-CCC" }, |
| 205 | { JUNIPER_IFML_IPIP, "IP-over-IP" }, |
| 206 | { JUNIPER_IFML_GRE, "GRE" }, |
| 207 | { JUNIPER_IFML_PIM, "PIM-Encapsulator" }, |
| 208 | { JUNIPER_IFML_PIMD, "PIM-Decapsulator" }, |
| 209 | { JUNIPER_IFML_CISCOHDLC_CCC, "Cisco-HDLC-CCC" }, |
| 210 | { JUNIPER_IFML_VLAN_CCC, "VLAN-CCC" }, |
| 211 | { JUNIPER_IFML_EXTENDED_VLAN_CCC, "Extended-VLAN-CCC" }, |
| 212 | { JUNIPER_IFML_MLPPP, "Multilink-PPP" }, |
| 213 | { JUNIPER_IFML_MLFR, "Multilink-FR" }, |
| 214 | { JUNIPER_IFML_MFR, "Multilink-FR-UNI-NNI" }, |
| 215 | { JUNIPER_IFML_ML, "Multilink" }, |
| 216 | { JUNIPER_IFML_LS, "LinkService" }, |
| 217 | { JUNIPER_IFML_LSI, "LSI" }, |
| 218 | { JUNIPER_IFML_ATM_CELLRELAY_CCC, "ATM-CCC-Cell-Relay" }, |
| 219 | { JUNIPER_IFML_CRYPTO, "IPSEC-over-IP" }, |
| 220 | { JUNIPER_IFML_GGSN, "GGSN" }, |
| 221 | { JUNIPER_IFML_PPP_TCC, "PPP-TCC" }, |
| 222 | { JUNIPER_IFML_FRAMERELAY_TCC, "Frame-Relay-TCC" }, |
| 223 | { JUNIPER_IFML_FRAMERELAY_EXT_TCC, "Extended FR-TCC" }, |
| 224 | { JUNIPER_IFML_CISCOHDLC_TCC, "Cisco-HDLC-TCC" }, |
| 225 | { JUNIPER_IFML_ETHERNET_CCC, "Ethernet-CCC" }, |
| 226 | { JUNIPER_IFML_VT, "VPN-Loopback-tunnel" }, |
| 227 | { JUNIPER_IFML_ETHER_OVER_ATM, "Ethernet-over-ATM" }, |
| 228 | { JUNIPER_IFML_ETHER_VPLS_OVER_ATM, "Ethernet-VPLS-over-ATM" }, |
| 229 | { JUNIPER_IFML_MONITOR, "Monitor" }, |
| 230 | { JUNIPER_IFML_ETHERNET_TCC, "Ethernet-TCC" }, |
| 231 | { JUNIPER_IFML_VLAN_TCC, "VLAN-TCC" }, |
| 232 | { JUNIPER_IFML_EXTENDED_VLAN_TCC, "Extended-VLAN-TCC" }, |
| 233 | { JUNIPER_IFML_CONTROLLER, "Controller" }, |
| 234 | { JUNIPER_IFML_ETHERNET_VPLS, "VPLS" }, |
| 235 | { JUNIPER_IFML_ETHERNET_VLAN_VPLS, "VLAN-VPLS" }, |
| 236 | { JUNIPER_IFML_ETHERNET_EXTENDED_VLAN_VPLS, "Extended-VLAN-VPLS" }, |
| 237 | { JUNIPER_IFML_LT, "Logical-tunnel" }, |
| 238 | { JUNIPER_IFML_SERVICES, "General-Services" }, |
| 239 | { JUNIPER_IFML_PPPOE, "PPPoE" }, |
| 240 | { JUNIPER_IFML_ETHERNET_FLEX, "Flexible-Ethernet-Services" }, |
| 241 | { JUNIPER_IFML_FRAMERELAY_FLEX, "Flexible-FrameRelay" }, |
| 242 | { JUNIPER_IFML_COLLECTOR, "Flow-collection" }, |
| 243 | { JUNIPER_IFML_PICPEER, "PIC Peer" }, |
| 244 | { JUNIPER_IFML_DFC, "Dynamic-Flow-Capture" }, |
| 245 | {0, NULL} |
| 246 | }; |
| 247 | |
| 248 | #define JUNIPER_IFLE_ATM_SNAP 2 |
| 249 | #define JUNIPER_IFLE_ATM_NLPID 3 |
| 250 | #define JUNIPER_IFLE_ATM_VCMUX 4 |
| 251 | #define JUNIPER_IFLE_ATM_LLC 5 |
| 252 | #define JUNIPER_IFLE_ATM_PPP_VCMUX 6 |
| 253 | #define JUNIPER_IFLE_ATM_PPP_LLC 7 |
| 254 | #define JUNIPER_IFLE_ATM_PPP_FUNI 8 |
| 255 | #define JUNIPER_IFLE_ATM_CCC 9 |
| 256 | #define JUNIPER_IFLE_FR_NLPID 10 |
| 257 | #define JUNIPER_IFLE_FR_SNAP 11 |
| 258 | #define JUNIPER_IFLE_FR_PPP 12 |
| 259 | #define JUNIPER_IFLE_FR_CCC 13 |
| 260 | #define JUNIPER_IFLE_ENET2 14 |
| 261 | #define JUNIPER_IFLE_IEEE8023_SNAP 15 |
| 262 | #define JUNIPER_IFLE_IEEE8023_LLC 16 |
| 263 | #define JUNIPER_IFLE_PPP 17 |
| 264 | #define JUNIPER_IFLE_CISCOHDLC 18 |
| 265 | #define JUNIPER_IFLE_PPP_CCC 19 |
| 266 | #define JUNIPER_IFLE_IPIP_NULL 20 |
| 267 | #define JUNIPER_IFLE_PIM_NULL 21 |
| 268 | #define JUNIPER_IFLE_GRE_NULL 22 |
| 269 | #define JUNIPER_IFLE_GRE_PPP 23 |
| 270 | #define JUNIPER_IFLE_PIMD_DECAPS 24 |
| 271 | #define JUNIPER_IFLE_CISCOHDLC_CCC 25 |
| 272 | #define JUNIPER_IFLE_ATM_CISCO_NLPID 26 |
| 273 | #define JUNIPER_IFLE_VLAN_CCC 27 |
| 274 | #define JUNIPER_IFLE_MLPPP 28 |
| 275 | #define JUNIPER_IFLE_MLFR 29 |
| 276 | #define JUNIPER_IFLE_LSI_NULL 30 |
| 277 | #define JUNIPER_IFLE_AGGREGATE_UNUSED 31 |
| 278 | #define JUNIPER_IFLE_ATM_CELLRELAY_CCC 32 |
| 279 | #define JUNIPER_IFLE_CRYPTO 33 |
| 280 | #define JUNIPER_IFLE_GGSN 34 |
| 281 | #define JUNIPER_IFLE_ATM_TCC 35 |
| 282 | #define JUNIPER_IFLE_FR_TCC 36 |
| 283 | #define JUNIPER_IFLE_PPP_TCC 37 |
| 284 | #define JUNIPER_IFLE_CISCOHDLC_TCC 38 |
| 285 | #define JUNIPER_IFLE_ETHERNET_CCC 39 |
| 286 | #define JUNIPER_IFLE_VT 40 |
| 287 | #define JUNIPER_IFLE_ATM_EOA_LLC 41 |
| 288 | #define JUNIPER_IFLE_EXTENDED_VLAN_CCC 42 |
| 289 | #define JUNIPER_IFLE_ATM_SNAP_TCC 43 |
| 290 | #define JUNIPER_IFLE_MONITOR 44 |
| 291 | #define JUNIPER_IFLE_ETHERNET_TCC 45 |
| 292 | #define JUNIPER_IFLE_VLAN_TCC 46 |
| 293 | #define JUNIPER_IFLE_EXTENDED_VLAN_TCC 47 |
| 294 | #define JUNIPER_IFLE_MFR 48 |
| 295 | #define JUNIPER_IFLE_ETHERNET_VPLS 49 |
| 296 | #define JUNIPER_IFLE_ETHERNET_VLAN_VPLS 50 |
| 297 | #define JUNIPER_IFLE_ETHERNET_EXTENDED_VLAN_VPLS 51 |
| 298 | #define JUNIPER_IFLE_SERVICES 52 |
| 299 | #define JUNIPER_IFLE_ATM_ETHER_VPLS_ATM_LLC 53 |
| 300 | #define JUNIPER_IFLE_FR_PORT_CCC 54 |
| 301 | #define JUNIPER_IFLE_ATM_MLPPP_LLC 55 |
| 302 | #define JUNIPER_IFLE_ATM_EOA_CCC 56 |
| 303 | #define JUNIPER_IFLE_LT_VLAN 57 |
| 304 | #define JUNIPER_IFLE_COLLECTOR 58 |
| 305 | #define JUNIPER_IFLE_AGGREGATOR 59 |
| 306 | #define JUNIPER_IFLE_LAPD 60 |
| 307 | #define JUNIPER_IFLE_ATM_PPPOE_LLC 61 |
| 308 | #define JUNIPER_IFLE_ETHERNET_PPPOE 62 |
| 309 | #define JUNIPER_IFLE_PPPOE 63 |
| 310 | #define JUNIPER_IFLE_PPP_SUBORDINATE 64 |
| 311 | #define JUNIPER_IFLE_CISCOHDLC_SUBORDINATE 65 |
| 312 | #define JUNIPER_IFLE_DFC 66 |
| 313 | #define JUNIPER_IFLE_PICPEER 67 |
| 314 | |
| 315 | static const struct tok juniper_ifle_values[] = { |
| 316 | { JUNIPER_IFLE_AGGREGATOR, "Aggregator" }, |
| 317 | { JUNIPER_IFLE_ATM_CCC, "CCC over ATM" }, |
| 318 | { JUNIPER_IFLE_ATM_CELLRELAY_CCC, "ATM CCC Cell Relay" }, |
| 319 | { JUNIPER_IFLE_ATM_CISCO_NLPID, "CISCO compatible NLPID" }, |
| 320 | { JUNIPER_IFLE_ATM_EOA_CCC, "Ethernet over ATM CCC" }, |
| 321 | { JUNIPER_IFLE_ATM_EOA_LLC, "Ethernet over ATM LLC" }, |
| 322 | { JUNIPER_IFLE_ATM_ETHER_VPLS_ATM_LLC, "Ethernet VPLS over ATM LLC" }, |
| 323 | { JUNIPER_IFLE_ATM_LLC, "ATM LLC" }, |
| 324 | { JUNIPER_IFLE_ATM_MLPPP_LLC, "MLPPP over ATM LLC" }, |
| 325 | { JUNIPER_IFLE_ATM_NLPID, "ATM NLPID" }, |
| 326 | { JUNIPER_IFLE_ATM_PPPOE_LLC, "PPPoE over ATM LLC" }, |
| 327 | { JUNIPER_IFLE_ATM_PPP_FUNI, "PPP over FUNI" }, |
| 328 | { JUNIPER_IFLE_ATM_PPP_LLC, "PPP over ATM LLC" }, |
| 329 | { JUNIPER_IFLE_ATM_PPP_VCMUX, "PPP over ATM VCMUX" }, |
| 330 | { JUNIPER_IFLE_ATM_SNAP, "ATM SNAP" }, |
| 331 | { JUNIPER_IFLE_ATM_SNAP_TCC, "ATM SNAP TCC" }, |
| 332 | { JUNIPER_IFLE_ATM_TCC, "ATM VCMUX TCC" }, |
| 333 | { JUNIPER_IFLE_ATM_VCMUX, "ATM VCMUX" }, |
| 334 | { JUNIPER_IFLE_CISCOHDLC, "C-HDLC" }, |
| 335 | { JUNIPER_IFLE_CISCOHDLC_CCC, "C-HDLC CCC" }, |
| 336 | { JUNIPER_IFLE_CISCOHDLC_SUBORDINATE, "C-HDLC via dialer" }, |
| 337 | { JUNIPER_IFLE_CISCOHDLC_TCC, "C-HDLC TCC" }, |
| 338 | { JUNIPER_IFLE_COLLECTOR, "Collector" }, |
| 339 | { JUNIPER_IFLE_CRYPTO, "Crypto" }, |
| 340 | { JUNIPER_IFLE_ENET2, "Ethernet" }, |
| 341 | { JUNIPER_IFLE_ETHERNET_CCC, "Ethernet CCC" }, |
| 342 | { JUNIPER_IFLE_ETHERNET_EXTENDED_VLAN_VPLS, "Extended VLAN VPLS" }, |
| 343 | { JUNIPER_IFLE_ETHERNET_PPPOE, "PPPoE over Ethernet" }, |
| 344 | { JUNIPER_IFLE_ETHERNET_TCC, "Ethernet TCC" }, |
| 345 | { JUNIPER_IFLE_ETHERNET_VLAN_VPLS, "VLAN VPLS" }, |
| 346 | { JUNIPER_IFLE_ETHERNET_VPLS, "VPLS" }, |
| 347 | { JUNIPER_IFLE_EXTENDED_VLAN_CCC, "Extended VLAN CCC" }, |
| 348 | { JUNIPER_IFLE_EXTENDED_VLAN_TCC, "Extended VLAN TCC" }, |
| 349 | { JUNIPER_IFLE_FR_CCC, "FR CCC" }, |
| 350 | { JUNIPER_IFLE_FR_NLPID, "FR NLPID" }, |
| 351 | { JUNIPER_IFLE_FR_PORT_CCC, "FR CCC" }, |
| 352 | { JUNIPER_IFLE_FR_PPP, "FR PPP" }, |
| 353 | { JUNIPER_IFLE_FR_SNAP, "FR SNAP" }, |
| 354 | { JUNIPER_IFLE_FR_TCC, "FR TCC" }, |
| 355 | { JUNIPER_IFLE_GGSN, "GGSN" }, |
| 356 | { JUNIPER_IFLE_GRE_NULL, "GRE NULL" }, |
| 357 | { JUNIPER_IFLE_GRE_PPP, "PPP over GRE" }, |
| 358 | { JUNIPER_IFLE_IPIP_NULL, "IPIP" }, |
| 359 | { JUNIPER_IFLE_LAPD, "LAPD" }, |
| 360 | { JUNIPER_IFLE_LSI_NULL, "LSI Null" }, |
| 361 | { JUNIPER_IFLE_LT_VLAN, "LT VLAN" }, |
| 362 | { JUNIPER_IFLE_MFR, "MFR" }, |
| 363 | { JUNIPER_IFLE_MLFR, "MLFR" }, |
| 364 | { JUNIPER_IFLE_MLPPP, "MLPPP" }, |
| 365 | { JUNIPER_IFLE_MONITOR, "Monitor" }, |
| 366 | { JUNIPER_IFLE_PIMD_DECAPS, "PIMd" }, |
| 367 | { JUNIPER_IFLE_PIM_NULL, "PIM Null" }, |
| 368 | { JUNIPER_IFLE_PPP, "PPP" }, |
| 369 | { JUNIPER_IFLE_PPPOE, "PPPoE" }, |
| 370 | { JUNIPER_IFLE_PPP_CCC, "PPP CCC" }, |
| 371 | { JUNIPER_IFLE_PPP_SUBORDINATE, "" }, |
| 372 | { JUNIPER_IFLE_PPP_TCC, "PPP TCC" }, |
| 373 | { JUNIPER_IFLE_SERVICES, "General Services" }, |
| 374 | { JUNIPER_IFLE_VLAN_CCC, "VLAN CCC" }, |
| 375 | { JUNIPER_IFLE_VLAN_TCC, "VLAN TCC" }, |
| 376 | { JUNIPER_IFLE_VT, "VT" }, |
| 377 | {0, NULL} |
| 378 | }; |
| 379 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 380 | struct juniper_cookie_table_t { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 381 | uint32_t pictype; /* pic type */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 382 | uint8_t cookie_len; /* cookie len */ |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 383 | const char *s; /* pic name */ |
| 384 | }; |
| 385 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 386 | static const struct juniper_cookie_table_t juniper_cookie_table[] = { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 387 | #ifdef DLT_JUNIPER_ATM1 |
| 388 | { DLT_JUNIPER_ATM1, 4, "ATM1"}, |
| 389 | #endif |
| 390 | #ifdef DLT_JUNIPER_ATM2 |
| 391 | { DLT_JUNIPER_ATM2, 8, "ATM2"}, |
| 392 | #endif |
| 393 | #ifdef DLT_JUNIPER_MLPPP |
| 394 | { DLT_JUNIPER_MLPPP, 2, "MLPPP"}, |
| 395 | #endif |
| 396 | #ifdef DLT_JUNIPER_MLFR |
| 397 | { DLT_JUNIPER_MLFR, 2, "MLFR"}, |
| 398 | #endif |
| 399 | #ifdef DLT_JUNIPER_MFR |
| 400 | { DLT_JUNIPER_MFR, 4, "MFR"}, |
| 401 | #endif |
| 402 | #ifdef DLT_JUNIPER_PPPOE |
| 403 | { DLT_JUNIPER_PPPOE, 0, "PPPoE"}, |
| 404 | #endif |
| 405 | #ifdef DLT_JUNIPER_PPPOE_ATM |
| 406 | { DLT_JUNIPER_PPPOE_ATM, 0, "PPPoE ATM"}, |
| 407 | #endif |
| 408 | #ifdef DLT_JUNIPER_GGSN |
| 409 | { DLT_JUNIPER_GGSN, 8, "GGSN"}, |
| 410 | #endif |
| 411 | #ifdef DLT_JUNIPER_MONITOR |
| 412 | { DLT_JUNIPER_MONITOR, 8, "MONITOR"}, |
| 413 | #endif |
| 414 | #ifdef DLT_JUNIPER_SERVICES |
| 415 | { DLT_JUNIPER_SERVICES, 8, "AS"}, |
| 416 | #endif |
| 417 | #ifdef DLT_JUNIPER_ES |
| 418 | { DLT_JUNIPER_ES, 0, "ES"}, |
| 419 | #endif |
| 420 | { 0, 0, NULL } |
| 421 | }; |
| 422 | |
| 423 | struct juniper_l2info_t { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 424 | uint32_t length; |
| 425 | uint32_t caplen; |
| 426 | uint32_t pictype; |
| 427 | uint8_t direction; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 428 | u_int header_len; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 429 | uint8_t cookie_len; |
| 430 | uint8_t cookie_type; |
| 431 | uint8_t cookie[8]; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 432 | u_int bundle; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 433 | uint16_t proto; |
| 434 | uint8_t flags; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 435 | }; |
| 436 | |
| 437 | #define LS_COOKIE_ID 0x54 |
| 438 | #define AS_COOKIE_ID 0x47 |
| 439 | #define LS_MLFR_COOKIE_LEN 4 |
| 440 | #define ML_MLFR_COOKIE_LEN 2 |
| 441 | #define LS_MFR_COOKIE_LEN 6 |
| 442 | #define ATM1_COOKIE_LEN 4 |
| 443 | #define ATM2_COOKIE_LEN 8 |
| 444 | |
| 445 | #define ATM2_PKT_TYPE_MASK 0x70 |
| 446 | #define ATM2_GAP_COUNT_MASK 0x3F |
| 447 | |
| 448 | #define JUNIPER_PROTO_NULL 1 |
| 449 | #define JUNIPER_PROTO_IPV4 2 |
| 450 | #define JUNIPER_PROTO_IPV6 6 |
| 451 | |
| 452 | #define MFR_BE_MASK 0xc0 |
| 453 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 454 | #ifdef DLT_JUNIPER_GGSN |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 455 | static const struct tok juniper_protocol_values[] = { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 456 | { JUNIPER_PROTO_NULL, "Null" }, |
| 457 | { JUNIPER_PROTO_IPV4, "IPv4" }, |
| 458 | { JUNIPER_PROTO_IPV6, "IPv6" }, |
| 459 | { 0, NULL} |
| 460 | }; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 461 | #endif |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 462 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 463 | static int ip_heuristic_guess(netdissect_options *, const u_char *, u_int); |
| 464 | #ifdef DLT_JUNIPER_ATM2 |
| 465 | static int juniper_ppp_heuristic_guess(netdissect_options *, const u_char *, u_int); |
| 466 | #endif |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 467 | static int juniper_parse_header(netdissect_options *, const u_char *, const struct pcap_pkthdr *, struct juniper_l2info_t *); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 468 | |
| 469 | #ifdef DLT_JUNIPER_GGSN |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 470 | void |
| 471 | juniper_ggsn_if_print(netdissect_options *ndo, |
| 472 | const struct pcap_pkthdr *h, const u_char *p) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 473 | { |
| 474 | struct juniper_l2info_t l2info; |
| 475 | struct juniper_ggsn_header { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 476 | nd_uint8_t svc_id; |
| 477 | nd_uint8_t flags_len; |
| 478 | nd_uint8_t proto; |
| 479 | nd_uint8_t flags; |
| 480 | nd_uint16_t vlan_id; |
| 481 | nd_byte res[2]; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 482 | }; |
| 483 | const struct juniper_ggsn_header *gh; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 484 | uint8_t proto; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 485 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 486 | ndo->ndo_protocol = "juniper_ggsn"; |
| 487 | memset(&l2info, 0, sizeof(l2info)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 488 | l2info.pictype = DLT_JUNIPER_GGSN; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 489 | if (juniper_parse_header(ndo, p, h, &l2info) == 0) { |
| 490 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 491 | return; |
| 492 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 493 | |
| 494 | p+=l2info.header_len; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 495 | gh = (struct juniper_ggsn_header *)&l2info.cookie; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 496 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 497 | ND_TCHECK_SIZE(gh); |
| 498 | proto = GET_U_1(gh->proto); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 499 | if (ndo->ndo_eflag) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 500 | ND_PRINT("proto %s (%u), vlan %u: ", |
| 501 | tok2str(juniper_protocol_values,"Unknown",proto), |
| 502 | proto, |
| 503 | GET_BE_U_2(gh->vlan_id)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 504 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 505 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 506 | switch (proto) { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 507 | case JUNIPER_PROTO_IPV4: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 508 | ip_print(ndo, p, l2info.length); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 509 | break; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 510 | case JUNIPER_PROTO_IPV6: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 511 | ip6_print(ndo, p, l2info.length); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 512 | break; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 513 | default: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 514 | if (!ndo->ndo_eflag) |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 515 | ND_PRINT("unknown GGSN proto (%u)", proto); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 516 | } |
| 517 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 518 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 519 | return; |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 520 | |
| 521 | trunc: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 522 | nd_print_trunc(ndo); |
| 523 | ndo->ndo_ll_hdr_len += l2info.header_len; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 524 | } |
| 525 | #endif |
| 526 | |
| 527 | #ifdef DLT_JUNIPER_ES |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 528 | void |
| 529 | juniper_es_if_print(netdissect_options *ndo, |
| 530 | const struct pcap_pkthdr *h, const u_char *p) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 531 | { |
| 532 | struct juniper_l2info_t l2info; |
| 533 | struct juniper_ipsec_header { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 534 | nd_uint16_t sa_index; |
| 535 | nd_uint8_t ttl; |
| 536 | nd_uint8_t type; |
| 537 | nd_uint32_t spi; |
| 538 | nd_ipv4 src_ip; |
| 539 | nd_ipv4 dst_ip; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 540 | }; |
| 541 | u_int rewrite_len,es_type_bundle; |
| 542 | const struct juniper_ipsec_header *ih; |
| 543 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 544 | ndo->ndo_protocol = "juniper_es"; |
| 545 | memset(&l2info, 0, sizeof(l2info)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 546 | l2info.pictype = DLT_JUNIPER_ES; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 547 | if (juniper_parse_header(ndo, p, h, &l2info) == 0) { |
| 548 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 549 | return; |
| 550 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 551 | |
| 552 | p+=l2info.header_len; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 553 | ih = (const struct juniper_ipsec_header *)p; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 554 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 555 | ND_TCHECK_SIZE(ih); |
| 556 | switch (GET_U_1(ih->type)) { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 557 | case JUNIPER_IPSEC_O_ESP_ENCRYPT_ESP_AUTHEN_TYPE: |
| 558 | case JUNIPER_IPSEC_O_ESP_ENCRYPT_AH_AUTHEN_TYPE: |
| 559 | rewrite_len = 0; |
| 560 | es_type_bundle = 1; |
| 561 | break; |
| 562 | case JUNIPER_IPSEC_O_ESP_AUTHENTICATION_TYPE: |
| 563 | case JUNIPER_IPSEC_O_AH_AUTHENTICATION_TYPE: |
| 564 | case JUNIPER_IPSEC_O_ESP_ENCRYPTION_TYPE: |
| 565 | rewrite_len = 16; |
| 566 | es_type_bundle = 0; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 567 | break; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 568 | default: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 569 | ND_PRINT("ES Invalid type %u, length %u", |
| 570 | GET_U_1(ih->type), |
| 571 | l2info.length); |
| 572 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 573 | return; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 574 | } |
| 575 | |
| 576 | l2info.length-=rewrite_len; |
| 577 | p+=rewrite_len; |
| 578 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 579 | if (ndo->ndo_eflag) { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 580 | if (!es_type_bundle) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 581 | ND_PRINT("ES SA, index %u, ttl %u type %s (%u), spi %u, Tunnel %s > %s, length %u\n", |
| 582 | GET_BE_U_2(ih->sa_index), |
| 583 | GET_U_1(ih->ttl), |
| 584 | tok2str(juniper_ipsec_type_values,"Unknown",GET_U_1(ih->type)), |
| 585 | GET_U_1(ih->type), |
| 586 | GET_BE_U_4(ih->spi), |
| 587 | GET_IPADDR_STRING(ih->src_ip), |
| 588 | GET_IPADDR_STRING(ih->dst_ip), |
| 589 | l2info.length); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 590 | } else { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 591 | ND_PRINT("ES SA, index %u, ttl %u type %s (%u), length %u\n", |
| 592 | GET_BE_U_2(ih->sa_index), |
| 593 | GET_U_1(ih->ttl), |
| 594 | tok2str(juniper_ipsec_type_values,"Unknown",GET_U_1(ih->type)), |
| 595 | GET_U_1(ih->type), |
| 596 | l2info.length); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 597 | } |
| 598 | } |
| 599 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 600 | ip_print(ndo, p, l2info.length); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 601 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 602 | return; |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 603 | |
| 604 | trunc: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 605 | nd_print_trunc(ndo); |
| 606 | ndo->ndo_ll_hdr_len += l2info.header_len; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 607 | } |
| 608 | #endif |
| 609 | |
| 610 | #ifdef DLT_JUNIPER_MONITOR |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 611 | void |
| 612 | juniper_monitor_if_print(netdissect_options *ndo, |
| 613 | const struct pcap_pkthdr *h, const u_char *p) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 614 | { |
| 615 | struct juniper_l2info_t l2info; |
| 616 | struct juniper_monitor_header { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 617 | nd_uint8_t pkt_type; |
| 618 | nd_byte padding; |
| 619 | nd_uint16_t iif; |
| 620 | nd_uint32_t service_id; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 621 | }; |
| 622 | const struct juniper_monitor_header *mh; |
| 623 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 624 | ndo->ndo_protocol = "juniper_monitor"; |
| 625 | memset(&l2info, 0, sizeof(l2info)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 626 | l2info.pictype = DLT_JUNIPER_MONITOR; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 627 | if (juniper_parse_header(ndo, p, h, &l2info) == 0) { |
| 628 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 629 | return; |
| 630 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 631 | |
| 632 | p+=l2info.header_len; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 633 | mh = (const struct juniper_monitor_header *)p; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 634 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 635 | ND_TCHECK_SIZE(mh); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 636 | if (ndo->ndo_eflag) |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 637 | ND_PRINT("service-id %u, iif %u, pkt-type %u: ", |
| 638 | GET_BE_U_4(mh->service_id), |
| 639 | GET_BE_U_2(mh->iif), |
| 640 | GET_U_1(mh->pkt_type)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 641 | |
| 642 | /* no proto field - lets guess by first byte of IP header*/ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 643 | ip_heuristic_guess (ndo, p, l2info.length); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 644 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 645 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 646 | return; |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 647 | |
| 648 | trunc: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 649 | nd_print_trunc(ndo); |
| 650 | ndo->ndo_ll_hdr_len += l2info.header_len; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 651 | } |
| 652 | #endif |
| 653 | |
| 654 | #ifdef DLT_JUNIPER_SERVICES |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 655 | void |
| 656 | juniper_services_if_print(netdissect_options *ndo, |
| 657 | const struct pcap_pkthdr *h, const u_char *p) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 658 | { |
| 659 | struct juniper_l2info_t l2info; |
| 660 | struct juniper_services_header { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 661 | nd_uint8_t svc_id; |
| 662 | nd_uint8_t flags_len; |
| 663 | nd_uint16_t svc_set_id; |
| 664 | nd_byte pad; |
| 665 | nd_uint24_t dir_iif; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 666 | }; |
| 667 | const struct juniper_services_header *sh; |
| 668 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 669 | ndo->ndo_protocol = "juniper_services"; |
| 670 | memset(&l2info, 0, sizeof(l2info)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 671 | l2info.pictype = DLT_JUNIPER_SERVICES; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 672 | if (juniper_parse_header(ndo, p, h, &l2info) == 0) { |
| 673 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 674 | return; |
| 675 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 676 | |
| 677 | p+=l2info.header_len; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 678 | sh = (const struct juniper_services_header *)p; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 679 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 680 | ND_TCHECK_SIZE(sh); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 681 | if (ndo->ndo_eflag) |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 682 | ND_PRINT("service-id %u flags 0x%02x service-set-id 0x%04x iif %u: ", |
| 683 | GET_U_1(sh->svc_id), |
| 684 | GET_U_1(sh->flags_len), |
| 685 | GET_BE_U_2(sh->svc_set_id), |
| 686 | GET_BE_U_3(sh->dir_iif)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 687 | |
| 688 | /* no proto field - lets guess by first byte of IP header*/ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 689 | ip_heuristic_guess (ndo, p, l2info.length); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 690 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 691 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 692 | return; |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 693 | |
| 694 | trunc: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 695 | nd_print_trunc(ndo); |
| 696 | ndo->ndo_ll_hdr_len += l2info.header_len; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 697 | } |
| 698 | #endif |
| 699 | |
| 700 | #ifdef DLT_JUNIPER_PPPOE |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 701 | void |
| 702 | juniper_pppoe_if_print(netdissect_options *ndo, |
| 703 | const struct pcap_pkthdr *h, const u_char *p) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 704 | { |
| 705 | struct juniper_l2info_t l2info; |
| 706 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 707 | ndo->ndo_protocol = "juniper_pppoe"; |
| 708 | memset(&l2info, 0, sizeof(l2info)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 709 | l2info.pictype = DLT_JUNIPER_PPPOE; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 710 | if (juniper_parse_header(ndo, p, h, &l2info) == 0) { |
| 711 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 712 | return; |
| 713 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 714 | |
| 715 | p+=l2info.header_len; |
| 716 | /* this DLT contains nothing but raw ethernet frames */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 717 | ether_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 718 | ndo->ndo_ll_hdr_len += l2info.header_len; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 719 | } |
| 720 | #endif |
| 721 | |
| 722 | #ifdef DLT_JUNIPER_ETHER |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 723 | void |
| 724 | juniper_ether_if_print(netdissect_options *ndo, |
| 725 | const struct pcap_pkthdr *h, const u_char *p) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 726 | { |
| 727 | struct juniper_l2info_t l2info; |
| 728 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 729 | ndo->ndo_protocol = "juniper_ether"; |
| 730 | memset(&l2info, 0, sizeof(l2info)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 731 | l2info.pictype = DLT_JUNIPER_ETHER; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 732 | if (juniper_parse_header(ndo, p, h, &l2info) == 0) { |
| 733 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 734 | return; |
| 735 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 736 | |
| 737 | p+=l2info.header_len; |
| 738 | /* this DLT contains nothing but raw Ethernet frames */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 739 | ndo->ndo_ll_hdr_len += |
| 740 | l2info.header_len + |
| 741 | ether_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 742 | } |
| 743 | #endif |
| 744 | |
| 745 | #ifdef DLT_JUNIPER_PPP |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 746 | void |
| 747 | juniper_ppp_if_print(netdissect_options *ndo, |
| 748 | const struct pcap_pkthdr *h, const u_char *p) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 749 | { |
| 750 | struct juniper_l2info_t l2info; |
| 751 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 752 | ndo->ndo_protocol = "juniper_ppp"; |
| 753 | memset(&l2info, 0, sizeof(l2info)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 754 | l2info.pictype = DLT_JUNIPER_PPP; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 755 | if (juniper_parse_header(ndo, p, h, &l2info) == 0) { |
| 756 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 757 | return; |
| 758 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 759 | |
| 760 | p+=l2info.header_len; |
| 761 | /* this DLT contains nothing but raw ppp frames */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 762 | ppp_print(ndo, p, l2info.length); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 763 | ndo->ndo_ll_hdr_len += l2info.header_len; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 764 | } |
| 765 | #endif |
| 766 | |
| 767 | #ifdef DLT_JUNIPER_FRELAY |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 768 | void |
| 769 | juniper_frelay_if_print(netdissect_options *ndo, |
| 770 | const struct pcap_pkthdr *h, const u_char *p) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 771 | { |
| 772 | struct juniper_l2info_t l2info; |
| 773 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 774 | ndo->ndo_protocol = "juniper_frelay"; |
| 775 | memset(&l2info, 0, sizeof(l2info)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 776 | l2info.pictype = DLT_JUNIPER_FRELAY; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 777 | if (juniper_parse_header(ndo, p, h, &l2info) == 0) { |
| 778 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 779 | return; |
| 780 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 781 | |
| 782 | p+=l2info.header_len; |
| 783 | /* this DLT contains nothing but raw frame-relay frames */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 784 | fr_print(ndo, p, l2info.length); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 785 | ndo->ndo_ll_hdr_len += l2info.header_len; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 786 | } |
| 787 | #endif |
| 788 | |
| 789 | #ifdef DLT_JUNIPER_CHDLC |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 790 | void |
| 791 | juniper_chdlc_if_print(netdissect_options *ndo, |
| 792 | const struct pcap_pkthdr *h, const u_char *p) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 793 | { |
| 794 | struct juniper_l2info_t l2info; |
| 795 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 796 | ndo->ndo_protocol = "juniper_chdlc"; |
| 797 | memset(&l2info, 0, sizeof(l2info)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 798 | l2info.pictype = DLT_JUNIPER_CHDLC; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 799 | if (juniper_parse_header(ndo, p, h, &l2info) == 0) { |
| 800 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 801 | return; |
| 802 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 803 | |
| 804 | p+=l2info.header_len; |
| 805 | /* this DLT contains nothing but raw c-hdlc frames */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 806 | chdlc_print(ndo, p, l2info.length); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 807 | ndo->ndo_ll_hdr_len += l2info.header_len; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 808 | } |
| 809 | #endif |
| 810 | |
| 811 | #ifdef DLT_JUNIPER_PPPOE_ATM |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 812 | void |
| 813 | juniper_pppoe_atm_if_print(netdissect_options *ndo, |
| 814 | const struct pcap_pkthdr *h, const u_char *p) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 815 | { |
| 816 | struct juniper_l2info_t l2info; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 817 | uint16_t extracted_ethertype; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 818 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 819 | ndo->ndo_protocol = "juniper_pppoe_atm"; |
| 820 | memset(&l2info, 0, sizeof(l2info)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 821 | l2info.pictype = DLT_JUNIPER_PPPOE_ATM; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 822 | if (juniper_parse_header(ndo, p, h, &l2info) == 0) { |
| 823 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 824 | return; |
| 825 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 826 | |
| 827 | p+=l2info.header_len; |
| 828 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 829 | extracted_ethertype = GET_BE_U_2(p); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 830 | /* this DLT contains nothing but raw PPPoE frames, |
| 831 | * prepended with a type field*/ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 832 | if (ethertype_print(ndo, extracted_ethertype, |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 833 | p+ETHERTYPE_LEN, |
| 834 | l2info.length-ETHERTYPE_LEN, |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 835 | l2info.caplen-ETHERTYPE_LEN, |
| 836 | NULL, NULL) == 0) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 837 | /* ether_type not known, probably it wasn't one */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 838 | ND_PRINT("unknown ethertype 0x%04x", extracted_ethertype); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 839 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 840 | ndo->ndo_ll_hdr_len += l2info.header_len; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 841 | } |
| 842 | #endif |
| 843 | |
| 844 | #ifdef DLT_JUNIPER_MLPPP |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 845 | void |
| 846 | juniper_mlppp_if_print(netdissect_options *ndo, |
| 847 | const struct pcap_pkthdr *h, const u_char *p) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 848 | { |
| 849 | struct juniper_l2info_t l2info; |
| 850 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 851 | ndo->ndo_protocol = "juniper_mlppp"; |
| 852 | memset(&l2info, 0, sizeof(l2info)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 853 | l2info.pictype = DLT_JUNIPER_MLPPP; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 854 | if (juniper_parse_header(ndo, p, h, &l2info) == 0) { |
| 855 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 856 | return; |
| 857 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 858 | |
| 859 | /* suppress Bundle-ID if frame was captured on a child-link |
| 860 | * best indicator if the cookie looks like a proto */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 861 | if (ndo->ndo_eflag && |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 862 | /* use EXTRACT_, not GET_ (not packet buffer pointer) */ |
| 863 | EXTRACT_BE_U_2(&l2info.cookie) != PPP_OSI && |
| 864 | /* use EXTRACT_, not GET_ (not packet buffer pointer) */ |
| 865 | EXTRACT_BE_U_2(&l2info.cookie) != (PPP_ADDRESS << 8 | PPP_CONTROL)) |
| 866 | ND_PRINT("Bundle-ID %u: ", l2info.bundle); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 867 | |
| 868 | p+=l2info.header_len; |
| 869 | |
| 870 | /* first try the LSQ protos */ |
| 871 | switch(l2info.proto) { |
| 872 | case JUNIPER_LSQ_L3_PROTO_IPV4: |
| 873 | /* IP traffic going to the RE would not have a cookie |
| 874 | * -> this must be incoming IS-IS over PPP |
| 875 | */ |
| 876 | if (l2info.cookie[4] == (JUNIPER_LSQ_COOKIE_RE|JUNIPER_LSQ_COOKIE_DIR)) |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 877 | ppp_print(ndo, p, l2info.length); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 878 | else |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 879 | ip_print(ndo, p, l2info.length); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 880 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 881 | return; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 882 | case JUNIPER_LSQ_L3_PROTO_IPV6: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 883 | ip6_print(ndo, p,l2info.length); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 884 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 885 | return; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 886 | case JUNIPER_LSQ_L3_PROTO_MPLS: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 887 | mpls_print(ndo, p, l2info.length); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 888 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 889 | return; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 890 | case JUNIPER_LSQ_L3_PROTO_ISO: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 891 | isoclns_print(ndo, p, l2info.length); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 892 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 893 | return; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 894 | default: |
| 895 | break; |
| 896 | } |
| 897 | |
| 898 | /* zero length cookie ? */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 899 | /* use EXTRACT_, not GET_ (not packet buffer pointer) */ |
| 900 | switch (EXTRACT_BE_U_2(&l2info.cookie)) { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 901 | case PPP_OSI: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 902 | ppp_print(ndo, p - 2, l2info.length + 2); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 903 | break; |
| 904 | case (PPP_ADDRESS << 8 | PPP_CONTROL): /* fall through */ |
| 905 | default: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 906 | ppp_print(ndo, p, l2info.length); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 907 | break; |
| 908 | } |
| 909 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 910 | ndo->ndo_ll_hdr_len += l2info.header_len; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 911 | } |
| 912 | #endif |
| 913 | |
| 914 | |
| 915 | #ifdef DLT_JUNIPER_MFR |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 916 | void |
| 917 | juniper_mfr_if_print(netdissect_options *ndo, |
| 918 | const struct pcap_pkthdr *h, const u_char *p) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 919 | { |
| 920 | struct juniper_l2info_t l2info; |
| 921 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 922 | ndo->ndo_protocol = "juniper_mfr"; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 923 | memset(&l2info, 0, sizeof(l2info)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 924 | l2info.pictype = DLT_JUNIPER_MFR; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 925 | if (juniper_parse_header(ndo, p, h, &l2info) == 0) { |
| 926 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 927 | return; |
| 928 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 929 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 930 | p+=l2info.header_len; |
| 931 | |
| 932 | /* child-link ? */ |
| 933 | if (l2info.cookie_len == 0) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 934 | mfr_print(ndo, p, l2info.length); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 935 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 936 | return; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 937 | } |
| 938 | |
| 939 | /* first try the LSQ protos */ |
| 940 | if (l2info.cookie_len == AS_PIC_COOKIE_LEN) { |
| 941 | switch(l2info.proto) { |
| 942 | case JUNIPER_LSQ_L3_PROTO_IPV4: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 943 | ip_print(ndo, p, l2info.length); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 944 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 945 | return; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 946 | case JUNIPER_LSQ_L3_PROTO_IPV6: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 947 | ip6_print(ndo, p,l2info.length); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 948 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 949 | return; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 950 | case JUNIPER_LSQ_L3_PROTO_MPLS: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 951 | mpls_print(ndo, p, l2info.length); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 952 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 953 | return; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 954 | case JUNIPER_LSQ_L3_PROTO_ISO: |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 955 | isoclns_print(ndo, p, l2info.length); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 956 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 957 | return; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 958 | default: |
| 959 | break; |
| 960 | } |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 961 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 962 | return; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 963 | } |
| 964 | |
| 965 | /* suppress Bundle-ID if frame was captured on a child-link */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 966 | /* use EXTRACT_, not GET_ (not packet buffer pointer) */ |
| 967 | if (ndo->ndo_eflag && EXTRACT_BE_U_4(l2info.cookie) != 1) |
| 968 | ND_PRINT("Bundle-ID %u, ", l2info.bundle); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 969 | switch (l2info.proto) { |
| 970 | case (LLCSAP_ISONS<<8 | LLCSAP_ISONS): |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 971 | isoclns_print(ndo, p + 1, l2info.length - 1); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 972 | break; |
| 973 | case (LLC_UI<<8 | NLPID_Q933): |
| 974 | case (LLC_UI<<8 | NLPID_IP): |
| 975 | case (LLC_UI<<8 | NLPID_IP6): |
| 976 | /* pass IP{4,6} to the OSI layer for proper link-layer printing */ |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 977 | isoclns_print(ndo, p - 1, l2info.length + 1); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 978 | break; |
| 979 | default: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 980 | ND_PRINT("unknown protocol 0x%04x, length %u", l2info.proto, l2info.length); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 981 | } |
| 982 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 983 | ndo->ndo_ll_hdr_len += l2info.header_len; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 984 | } |
| 985 | #endif |
| 986 | |
| 987 | #ifdef DLT_JUNIPER_MLFR |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 988 | void |
| 989 | juniper_mlfr_if_print(netdissect_options *ndo, |
| 990 | const struct pcap_pkthdr *h, const u_char *p) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 991 | { |
| 992 | struct juniper_l2info_t l2info; |
| 993 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 994 | ndo->ndo_protocol = "juniper_mlfr"; |
| 995 | memset(&l2info, 0, sizeof(l2info)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 996 | l2info.pictype = DLT_JUNIPER_MLFR; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 997 | if (juniper_parse_header(ndo, p, h, &l2info) == 0) { |
| 998 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 999 | return; |
| 1000 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1001 | |
| 1002 | p+=l2info.header_len; |
| 1003 | |
| 1004 | /* suppress Bundle-ID if frame was captured on a child-link */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1005 | /* use EXTRACT_, not GET_ (not packet buffer pointer) */ |
| 1006 | if (ndo->ndo_eflag && EXTRACT_BE_U_4(l2info.cookie) != 1) |
| 1007 | ND_PRINT("Bundle-ID %u, ", l2info.bundle); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1008 | switch (l2info.proto) { |
| 1009 | case (LLC_UI): |
| 1010 | case (LLC_UI<<8): |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 1011 | isoclns_print(ndo, p, l2info.length); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1012 | break; |
| 1013 | case (LLC_UI<<8 | NLPID_Q933): |
| 1014 | case (LLC_UI<<8 | NLPID_IP): |
| 1015 | case (LLC_UI<<8 | NLPID_IP6): |
| 1016 | /* pass IP{4,6} to the OSI layer for proper link-layer printing */ |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 1017 | isoclns_print(ndo, p - 1, l2info.length + 1); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1018 | break; |
| 1019 | default: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1020 | ND_PRINT("unknown protocol 0x%04x, length %u", l2info.proto, l2info.length); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1021 | } |
| 1022 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1023 | ndo->ndo_ll_hdr_len += l2info.header_len; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1024 | } |
| 1025 | #endif |
| 1026 | |
| 1027 | /* |
| 1028 | * ATM1 PIC cookie format |
| 1029 | * |
| 1030 | * +-----+-------------------------+-------------------------------+ |
| 1031 | * |fmtid| vc index | channel ID | |
| 1032 | * +-----+-------------------------+-------------------------------+ |
| 1033 | */ |
| 1034 | |
| 1035 | #ifdef DLT_JUNIPER_ATM1 |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1036 | void |
| 1037 | juniper_atm1_if_print(netdissect_options *ndo, |
| 1038 | const struct pcap_pkthdr *h, const u_char *p) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1039 | { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 1040 | int llc_hdrlen; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1041 | |
| 1042 | struct juniper_l2info_t l2info; |
| 1043 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1044 | ndo->ndo_protocol = "juniper_atm1"; |
| 1045 | memset(&l2info, 0, sizeof(l2info)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1046 | l2info.pictype = DLT_JUNIPER_ATM1; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1047 | if (juniper_parse_header(ndo, p, h, &l2info) == 0) { |
| 1048 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 1049 | return; |
| 1050 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1051 | |
| 1052 | p+=l2info.header_len; |
| 1053 | |
| 1054 | if (l2info.cookie[0] == 0x80) { /* OAM cell ? */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1055 | oam_print(ndo, p, l2info.length, ATM_OAM_NOHEC); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1056 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 1057 | return; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1058 | } |
| 1059 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1060 | if (GET_BE_U_3(p) == 0xfefe03 || /* NLPID encaps ? */ |
| 1061 | GET_BE_U_3(p) == 0xaaaa03) { /* SNAP encaps ? */ |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1062 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 1063 | llc_hdrlen = llc_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1064 | if (llc_hdrlen > 0) { |
| 1065 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 1066 | return; |
| 1067 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1068 | } |
| 1069 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1070 | if (GET_U_1(p) == 0x03) { /* Cisco style NLPID encaps ? */ |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 1071 | isoclns_print(ndo, p + 1, l2info.length - 1); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1072 | /* FIXME check if frame was recognized */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1073 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 1074 | return; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1075 | } |
| 1076 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1077 | if (ip_heuristic_guess(ndo, p, l2info.length) != 0) { /* last try - vcmux encaps ? */ |
| 1078 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 1079 | return; |
| 1080 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1081 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1082 | ndo->ndo_ll_hdr_len += l2info.header_len; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1083 | } |
| 1084 | #endif |
| 1085 | |
| 1086 | /* |
| 1087 | * ATM2 PIC cookie format |
| 1088 | * |
| 1089 | * +-------------------------------+---------+---+-----+-----------+ |
| 1090 | * | channel ID | reserv |AAL| CCRQ| gap cnt | |
| 1091 | * +-------------------------------+---------+---+-----+-----------+ |
| 1092 | */ |
| 1093 | |
| 1094 | #ifdef DLT_JUNIPER_ATM2 |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1095 | void |
| 1096 | juniper_atm2_if_print(netdissect_options *ndo, |
| 1097 | const struct pcap_pkthdr *h, const u_char *p) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1098 | { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 1099 | int llc_hdrlen; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1100 | |
| 1101 | struct juniper_l2info_t l2info; |
| 1102 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1103 | ndo->ndo_protocol = "juniper_atm2"; |
| 1104 | memset(&l2info, 0, sizeof(l2info)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1105 | l2info.pictype = DLT_JUNIPER_ATM2; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1106 | if (juniper_parse_header(ndo, p, h, &l2info) == 0) { |
| 1107 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 1108 | return; |
| 1109 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1110 | |
| 1111 | p+=l2info.header_len; |
| 1112 | |
| 1113 | if (l2info.cookie[7] & ATM2_PKT_TYPE_MASK) { /* OAM cell ? */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1114 | oam_print(ndo, p, l2info.length, ATM_OAM_NOHEC); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1115 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 1116 | return; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1117 | } |
| 1118 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1119 | if (GET_BE_U_3(p) == 0xfefe03 || /* NLPID encaps ? */ |
| 1120 | GET_BE_U_3(p) == 0xaaaa03) { /* SNAP encaps ? */ |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1121 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 1122 | llc_hdrlen = llc_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1123 | if (llc_hdrlen > 0) { |
| 1124 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 1125 | return; |
| 1126 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1127 | } |
| 1128 | |
| 1129 | if (l2info.direction != JUNIPER_BPF_PKT_IN && /* ether-over-1483 encaps ? */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1130 | /* use EXTRACT_, not GET_ (not packet buffer pointer) */ |
| 1131 | (EXTRACT_BE_U_4(l2info.cookie) & ATM2_GAP_COUNT_MASK)) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1132 | ether_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL); |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1133 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 1134 | return; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1135 | } |
| 1136 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1137 | if (GET_U_1(p) == 0x03) { /* Cisco style NLPID encaps ? */ |
Elliott Hughes | cec480a | 2017-12-19 16:54:57 -0800 | [diff] [blame] | 1138 | isoclns_print(ndo, p + 1, l2info.length - 1); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1139 | /* FIXME check if frame was recognized */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1140 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 1141 | return; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1142 | } |
| 1143 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1144 | if(juniper_ppp_heuristic_guess(ndo, p, l2info.length) != 0) { /* PPPoA vcmux encaps ? */ |
| 1145 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 1146 | return; |
| 1147 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1148 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1149 | if (ip_heuristic_guess(ndo, p, l2info.length) != 0) { /* last try - vcmux encaps ? */ |
| 1150 | ndo->ndo_ll_hdr_len += l2info.header_len; |
| 1151 | return; |
| 1152 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1153 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1154 | ndo->ndo_ll_hdr_len += l2info.header_len; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1155 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1156 | |
| 1157 | /* try to guess, based on all PPP protos that are supported in |
| 1158 | * a juniper router if the payload data is encapsulated using PPP */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1159 | static int |
| 1160 | juniper_ppp_heuristic_guess(netdissect_options *ndo, |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1161 | const u_char *p, u_int length) |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1162 | { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1163 | switch(GET_BE_U_2(p)) { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1164 | case PPP_IP : |
| 1165 | case PPP_OSI : |
| 1166 | case PPP_MPLS_UCAST : |
| 1167 | case PPP_MPLS_MCAST : |
| 1168 | case PPP_IPCP : |
| 1169 | case PPP_OSICP : |
| 1170 | case PPP_MPLSCP : |
| 1171 | case PPP_LCP : |
| 1172 | case PPP_PAP : |
| 1173 | case PPP_CHAP : |
| 1174 | case PPP_ML : |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1175 | case PPP_IPV6 : |
| 1176 | case PPP_IPV6CP : |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1177 | ppp_print(ndo, p, length); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1178 | break; |
| 1179 | |
| 1180 | default: |
| 1181 | return 0; /* did not find a ppp header */ |
| 1182 | break; |
| 1183 | } |
| 1184 | return 1; /* we printed a ppp packet */ |
| 1185 | } |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1186 | #endif |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1187 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1188 | static int |
| 1189 | ip_heuristic_guess(netdissect_options *ndo, |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1190 | const u_char *p, u_int length) |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1191 | { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1192 | switch(GET_U_1(p)) { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1193 | case 0x45: |
| 1194 | case 0x46: |
| 1195 | case 0x47: |
| 1196 | case 0x48: |
| 1197 | case 0x49: |
| 1198 | case 0x4a: |
| 1199 | case 0x4b: |
| 1200 | case 0x4c: |
| 1201 | case 0x4d: |
| 1202 | case 0x4e: |
| 1203 | case 0x4f: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1204 | ip_print(ndo, p, length); |
| 1205 | break; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1206 | case 0x60: |
| 1207 | case 0x61: |
| 1208 | case 0x62: |
| 1209 | case 0x63: |
| 1210 | case 0x64: |
| 1211 | case 0x65: |
| 1212 | case 0x66: |
| 1213 | case 0x67: |
| 1214 | case 0x68: |
| 1215 | case 0x69: |
| 1216 | case 0x6a: |
| 1217 | case 0x6b: |
| 1218 | case 0x6c: |
| 1219 | case 0x6d: |
| 1220 | case 0x6e: |
| 1221 | case 0x6f: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1222 | ip6_print(ndo, p, length); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1223 | break; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1224 | default: |
| 1225 | return 0; /* did not find a ip header */ |
| 1226 | break; |
| 1227 | } |
| 1228 | return 1; /* we printed an v4/v6 packet */ |
| 1229 | } |
| 1230 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1231 | static int |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1232 | juniper_read_tlv_value(netdissect_options *ndo, |
| 1233 | const u_char *p, u_int tlv_type, u_int tlv_len) |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1234 | { |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1235 | int tlv_value; |
| 1236 | |
| 1237 | /* TLVs < 128 are little endian encoded */ |
| 1238 | if (tlv_type < 128) { |
| 1239 | switch (tlv_len) { |
| 1240 | case 1: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1241 | tlv_value = GET_U_1(p); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1242 | break; |
| 1243 | case 2: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1244 | tlv_value = GET_LE_U_2(p); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1245 | break; |
| 1246 | case 3: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1247 | tlv_value = GET_LE_U_3(p); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1248 | break; |
| 1249 | case 4: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1250 | tlv_value = GET_LE_U_4(p); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1251 | break; |
| 1252 | default: |
| 1253 | tlv_value = -1; |
| 1254 | break; |
| 1255 | } |
| 1256 | } else { |
| 1257 | /* TLVs >= 128 are big endian encoded */ |
| 1258 | switch (tlv_len) { |
| 1259 | case 1: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1260 | tlv_value = GET_U_1(p); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1261 | break; |
| 1262 | case 2: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1263 | tlv_value = GET_BE_U_2(p); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1264 | break; |
| 1265 | case 3: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1266 | tlv_value = GET_BE_U_3(p); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1267 | break; |
| 1268 | case 4: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1269 | tlv_value = GET_BE_U_4(p); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1270 | break; |
| 1271 | default: |
| 1272 | tlv_value = -1; |
| 1273 | break; |
| 1274 | } |
| 1275 | } |
| 1276 | return tlv_value; |
| 1277 | } |
| 1278 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1279 | static int |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1280 | juniper_parse_header(netdissect_options *ndo, |
| 1281 | const u_char *p, const struct pcap_pkthdr *h, struct juniper_l2info_t *l2info) |
| 1282 | { |
| 1283 | const struct juniper_cookie_table_t *lp = juniper_cookie_table; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1284 | u_int idx, jnx_ext_len, jnx_header_len = 0; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1285 | uint8_t tlv_type,tlv_len; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1286 | #ifdef DLT_JUNIPER_ATM2 |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1287 | uint32_t control_word; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1288 | #endif |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1289 | int tlv_value; |
| 1290 | const u_char *tptr; |
| 1291 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1292 | |
| 1293 | l2info->header_len = 0; |
| 1294 | l2info->cookie_len = 0; |
| 1295 | l2info->proto = 0; |
| 1296 | |
| 1297 | |
| 1298 | l2info->length = h->len; |
| 1299 | l2info->caplen = h->caplen; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1300 | l2info->flags = GET_U_1(p + 3); |
| 1301 | l2info->direction = GET_U_1(p + 3) & JUNIPER_BPF_PKT_IN; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1302 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1303 | if (GET_BE_U_3(p) != JUNIPER_MGC_NUMBER) { /* magic number found ? */ |
| 1304 | ND_PRINT("no magic-number found!"); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1305 | return 0; |
| 1306 | } |
| 1307 | |
| 1308 | if (ndo->ndo_eflag) /* print direction */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1309 | ND_PRINT("%3s ", tok2str(juniper_direction_values, "---", l2info->direction)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1310 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1311 | /* magic number + flags */ |
| 1312 | jnx_header_len = 4; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1313 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1314 | if (ndo->ndo_vflag > 1) |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1315 | ND_PRINT("\n\tJuniper PCAP Flags [%s]", |
| 1316 | bittok2str(jnx_flag_values, "none", l2info->flags)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1317 | |
| 1318 | /* extensions present ? - calculate how much bytes to skip */ |
| 1319 | if ((l2info->flags & JUNIPER_BPF_EXT ) == JUNIPER_BPF_EXT ) { |
| 1320 | |
| 1321 | tptr = p+jnx_header_len; |
| 1322 | |
| 1323 | /* ok to read extension length ? */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1324 | jnx_ext_len = GET_BE_U_2(tptr); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1325 | jnx_header_len += 2; |
| 1326 | tptr +=2; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1327 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1328 | /* nail up the total length - |
| 1329 | * just in case something goes wrong |
| 1330 | * with TLV parsing */ |
| 1331 | jnx_header_len += jnx_ext_len; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1332 | |
| 1333 | if (ndo->ndo_vflag > 1) |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1334 | ND_PRINT(", PCAP Extension(s) total length %u", jnx_ext_len); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1335 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1336 | ND_TCHECK_LEN(tptr, jnx_ext_len); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1337 | while (jnx_ext_len > JUNIPER_EXT_TLV_OVERHEAD) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1338 | tlv_type = GET_U_1(tptr); |
| 1339 | tptr++; |
| 1340 | tlv_len = GET_U_1(tptr); |
| 1341 | tptr++; |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1342 | tlv_value = 0; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1343 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 1344 | /* sanity checks */ |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1345 | if (tlv_type == 0 || tlv_len == 0) |
| 1346 | break; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 1347 | if (tlv_len+JUNIPER_EXT_TLV_OVERHEAD > jnx_ext_len) |
| 1348 | goto trunc; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1349 | |
| 1350 | if (ndo->ndo_vflag > 1) |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1351 | ND_PRINT("\n\t %s Extension TLV #%u, length %u, value ", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1352 | tok2str(jnx_ext_tlv_values,"Unknown",tlv_type), |
| 1353 | tlv_type, |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1354 | tlv_len); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1355 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1356 | tlv_value = juniper_read_tlv_value(ndo, tptr, tlv_type, tlv_len); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1357 | switch (tlv_type) { |
| 1358 | case JUNIPER_EXT_TLV_IFD_NAME: |
| 1359 | /* FIXME */ |
| 1360 | break; |
| 1361 | case JUNIPER_EXT_TLV_IFD_MEDIATYPE: |
| 1362 | case JUNIPER_EXT_TLV_TTP_IFD_MEDIATYPE: |
| 1363 | if (tlv_value != -1) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1364 | if (ndo->ndo_vflag > 1) |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1365 | ND_PRINT("%s (%u)", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1366 | tok2str(juniper_ifmt_values, "Unknown", tlv_value), |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1367 | tlv_value); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1368 | } |
| 1369 | break; |
| 1370 | case JUNIPER_EXT_TLV_IFL_ENCAPS: |
| 1371 | case JUNIPER_EXT_TLV_TTP_IFL_ENCAPS: |
| 1372 | if (tlv_value != -1) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1373 | if (ndo->ndo_vflag > 1) |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1374 | ND_PRINT("%s (%u)", |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1375 | tok2str(juniper_ifle_values, "Unknown", tlv_value), |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1376 | tlv_value); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1377 | } |
| 1378 | break; |
| 1379 | case JUNIPER_EXT_TLV_IFL_IDX: /* fall through */ |
| 1380 | case JUNIPER_EXT_TLV_IFL_UNIT: |
| 1381 | case JUNIPER_EXT_TLV_IFD_IDX: |
| 1382 | default: |
| 1383 | if (tlv_value != -1) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1384 | if (ndo->ndo_vflag > 1) |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1385 | ND_PRINT("%u", tlv_value); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1386 | } |
| 1387 | break; |
| 1388 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1389 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1390 | tptr+=tlv_len; |
| 1391 | jnx_ext_len -= tlv_len+JUNIPER_EXT_TLV_OVERHEAD; |
| 1392 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1393 | |
| 1394 | if (ndo->ndo_vflag > 1) |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1395 | ND_PRINT("\n\t-----original packet-----\n\t"); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1396 | } |
| 1397 | |
| 1398 | if ((l2info->flags & JUNIPER_BPF_NO_L2 ) == JUNIPER_BPF_NO_L2 ) { |
| 1399 | if (ndo->ndo_eflag) |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1400 | ND_PRINT("no-L2-hdr, "); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1401 | |
| 1402 | /* there is no link-layer present - |
| 1403 | * perform the v4/v6 heuristics |
| 1404 | * to figure out what it is |
| 1405 | */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1406 | ND_TCHECK_1(p + (jnx_header_len + 4)); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1407 | if (ip_heuristic_guess(ndo, p + jnx_header_len + 4, |
| 1408 | l2info->length - (jnx_header_len + 4)) == 0) |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1409 | ND_PRINT("no IP-hdr found!"); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1410 | |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1411 | l2info->header_len=jnx_header_len+4; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1412 | return 0; /* stop parsing the output further */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1413 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1414 | } |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1415 | l2info->header_len = jnx_header_len; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1416 | p+=l2info->header_len; |
| 1417 | l2info->length -= l2info->header_len; |
| 1418 | l2info->caplen -= l2info->header_len; |
| 1419 | |
| 1420 | /* search through the cookie table and copy values matching for our PIC type */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1421 | ND_TCHECK_1(p); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1422 | while (lp->s != NULL) { |
| 1423 | if (lp->pictype == l2info->pictype) { |
| 1424 | |
| 1425 | l2info->cookie_len += lp->cookie_len; |
| 1426 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1427 | switch (GET_U_1(p)) { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1428 | case LS_COOKIE_ID: |
| 1429 | l2info->cookie_type = LS_COOKIE_ID; |
| 1430 | l2info->cookie_len += 2; |
| 1431 | break; |
| 1432 | case AS_COOKIE_ID: |
| 1433 | l2info->cookie_type = AS_COOKIE_ID; |
| 1434 | l2info->cookie_len = 8; |
| 1435 | break; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1436 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1437 | default: |
| 1438 | l2info->bundle = l2info->cookie[0]; |
| 1439 | break; |
| 1440 | } |
| 1441 | |
| 1442 | |
| 1443 | #ifdef DLT_JUNIPER_MFR |
| 1444 | /* MFR child links don't carry cookies */ |
| 1445 | if (l2info->pictype == DLT_JUNIPER_MFR && |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1446 | (GET_U_1(p) & MFR_BE_MASK) == MFR_BE_MASK) { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1447 | l2info->cookie_len = 0; |
| 1448 | } |
| 1449 | #endif |
| 1450 | |
| 1451 | l2info->header_len += l2info->cookie_len; |
| 1452 | l2info->length -= l2info->cookie_len; |
| 1453 | l2info->caplen -= l2info->cookie_len; |
| 1454 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1455 | if (ndo->ndo_eflag) |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1456 | ND_PRINT("%s-PIC, cookie-len %u", |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1457 | lp->s, |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1458 | l2info->cookie_len); |
| 1459 | |
| 1460 | if (l2info->cookie_len > 8) { |
| 1461 | nd_print_invalid(ndo); |
| 1462 | return 0; |
| 1463 | } |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1464 | |
| 1465 | if (l2info->cookie_len > 0) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1466 | ND_TCHECK_LEN(p, l2info->cookie_len); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1467 | if (ndo->ndo_eflag) |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1468 | ND_PRINT(", cookie 0x"); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1469 | for (idx = 0; idx < l2info->cookie_len; idx++) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1470 | l2info->cookie[idx] = GET_U_1(p + idx); /* copy cookie data */ |
| 1471 | if (ndo->ndo_eflag) ND_PRINT("%02x", GET_U_1(p + idx)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1472 | } |
| 1473 | } |
| 1474 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1475 | if (ndo->ndo_eflag) ND_PRINT(": "); /* print demarc b/w L2/L3*/ |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1476 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1477 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1478 | l2info->proto = GET_BE_U_2(p + l2info->cookie_len); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1479 | break; |
| 1480 | } |
| 1481 | ++lp; |
| 1482 | } |
| 1483 | p+=l2info->cookie_len; |
| 1484 | |
| 1485 | /* DLT_ specific parsing */ |
| 1486 | switch(l2info->pictype) { |
| 1487 | #ifdef DLT_JUNIPER_MLPPP |
| 1488 | case DLT_JUNIPER_MLPPP: |
| 1489 | switch (l2info->cookie_type) { |
| 1490 | case LS_COOKIE_ID: |
| 1491 | l2info->bundle = l2info->cookie[1]; |
| 1492 | break; |
| 1493 | case AS_COOKIE_ID: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1494 | /* use EXTRACT_, not GET_ (not packet buffer pointer) */ |
| 1495 | l2info->bundle = (EXTRACT_BE_U_2(&l2info->cookie[6])>>3)&0xfff; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1496 | l2info->proto = (l2info->cookie[5])&JUNIPER_LSQ_L3_PROTO_MASK; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1497 | break; |
| 1498 | default: |
| 1499 | l2info->bundle = l2info->cookie[0]; |
| 1500 | break; |
| 1501 | } |
| 1502 | break; |
| 1503 | #endif |
| 1504 | #ifdef DLT_JUNIPER_MLFR |
| 1505 | case DLT_JUNIPER_MLFR: |
| 1506 | switch (l2info->cookie_type) { |
| 1507 | case LS_COOKIE_ID: |
| 1508 | l2info->bundle = l2info->cookie[1]; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1509 | l2info->proto = GET_BE_U_2(p); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1510 | l2info->header_len += 2; |
| 1511 | l2info->length -= 2; |
| 1512 | l2info->caplen -= 2; |
| 1513 | break; |
| 1514 | case AS_COOKIE_ID: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1515 | /* use EXTRACT_, not GET_ (not packet buffer pointer) */ |
| 1516 | l2info->bundle = (EXTRACT_BE_U_2(&l2info->cookie[6])>>3)&0xfff; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1517 | l2info->proto = (l2info->cookie[5])&JUNIPER_LSQ_L3_PROTO_MASK; |
| 1518 | break; |
| 1519 | default: |
| 1520 | l2info->bundle = l2info->cookie[0]; |
| 1521 | l2info->header_len += 2; |
| 1522 | l2info->length -= 2; |
| 1523 | l2info->caplen -= 2; |
| 1524 | break; |
| 1525 | } |
| 1526 | break; |
| 1527 | #endif |
| 1528 | #ifdef DLT_JUNIPER_MFR |
| 1529 | case DLT_JUNIPER_MFR: |
| 1530 | switch (l2info->cookie_type) { |
| 1531 | case LS_COOKIE_ID: |
| 1532 | l2info->bundle = l2info->cookie[1]; |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1533 | l2info->proto = GET_BE_U_2(p); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1534 | l2info->header_len += 2; |
| 1535 | l2info->length -= 2; |
| 1536 | l2info->caplen -= 2; |
| 1537 | break; |
| 1538 | case AS_COOKIE_ID: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1539 | /* use EXTRACT_, not GET_ (not packet buffer pointer) */ |
| 1540 | l2info->bundle = (EXTRACT_BE_U_2(&l2info->cookie[6])>>3)&0xfff; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1541 | l2info->proto = (l2info->cookie[5])&JUNIPER_LSQ_L3_PROTO_MASK; |
| 1542 | break; |
| 1543 | default: |
| 1544 | l2info->bundle = l2info->cookie[0]; |
| 1545 | break; |
| 1546 | } |
| 1547 | break; |
| 1548 | #endif |
| 1549 | #ifdef DLT_JUNIPER_ATM2 |
| 1550 | case DLT_JUNIPER_ATM2: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1551 | ND_TCHECK_4(p); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1552 | /* ATM cell relay control word present ? */ |
| 1553 | if (l2info->cookie[7] & ATM2_PKT_TYPE_MASK) { |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1554 | control_word = GET_BE_U_4(p); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1555 | /* some control word heuristics */ |
| 1556 | switch(control_word) { |
| 1557 | case 0: /* zero control word */ |
| 1558 | case 0x08000000: /* < JUNOS 7.4 control-word */ |
| 1559 | case 0x08380000: /* cntl word plus cell length (56) >= JUNOS 7.4*/ |
| 1560 | l2info->header_len += 4; |
| 1561 | break; |
| 1562 | default: |
| 1563 | break; |
| 1564 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1565 | |
| 1566 | if (ndo->ndo_eflag) |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1567 | ND_PRINT("control-word 0x%08x ", control_word); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1568 | } |
| 1569 | break; |
| 1570 | #endif |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 1571 | #ifdef DLT_JUNIPER_GGSN |
| 1572 | case DLT_JUNIPER_GGSN: |
| 1573 | break; |
| 1574 | #endif |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1575 | #ifdef DLT_JUNIPER_ATM1 |
| 1576 | case DLT_JUNIPER_ATM1: |
| 1577 | break; |
| 1578 | #endif |
| 1579 | #ifdef DLT_JUNIPER_PPP |
| 1580 | case DLT_JUNIPER_PPP: |
| 1581 | break; |
| 1582 | #endif |
| 1583 | #ifdef DLT_JUNIPER_CHDLC |
| 1584 | case DLT_JUNIPER_CHDLC: |
| 1585 | break; |
| 1586 | #endif |
| 1587 | #ifdef DLT_JUNIPER_ETHER |
| 1588 | case DLT_JUNIPER_ETHER: |
| 1589 | break; |
| 1590 | #endif |
| 1591 | #ifdef DLT_JUNIPER_FRELAY |
| 1592 | case DLT_JUNIPER_FRELAY: |
| 1593 | break; |
| 1594 | #endif |
| 1595 | |
| 1596 | default: |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1597 | ND_PRINT("Unknown Juniper DLT_ type %u: ", l2info->pictype); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1598 | break; |
| 1599 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 1600 | |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1601 | if (ndo->ndo_eflag) |
| 1602 | ND_PRINT("hlen %u, proto 0x%04x, ", l2info->header_len, l2info->proto); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1603 | |
| 1604 | return 1; /* everything went ok so far. continue parsing */ |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1605 | trunc: |
| 1606 | nd_print_trunc(ndo); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1607 | return 0; |
| 1608 | } |
Elliott Hughes | 820eced | 2021-08-20 18:00:50 -0700 | [diff] [blame] | 1609 | #endif /* defined(DLT_JUNIPER_GGSN) || defined(DLT_JUNIPER_ES) || \ |
| 1610 | defined(DLT_JUNIPER_MONITOR) || defined(DLT_JUNIPER_SERVICES) || \ |
| 1611 | defined(DLT_JUNIPER_PPPOE) || defined(DLT_JUNIPER_ETHER) || \ |
| 1612 | defined(DLT_JUNIPER_PPP) || defined(DLT_JUNIPER_FRELAY) || \ |
| 1613 | defined(DLT_JUNIPER_CHDLC) || defined(DLT_JUNIPER_PPPOE_ATM) || \ |
| 1614 | defined(DLT_JUNIPER_MLPPP) || defined(DLT_JUNIPER_MFR) || \ |
| 1615 | defined(DLT_JUNIPER_MLFR) || defined(DLT_JUNIPER_ATM1) || \ |
| 1616 | defined(DLT_JUNIPER_ATM2) */ |