/src/wireshark/epan/dissectors/packet-ip.h
Line | Count | Source |
1 | | /* packet-ip.h |
2 | | * Definitions for IP packet disassembly structures and routines |
3 | | * |
4 | | * Wireshark - Network traffic analyzer |
5 | | * By Gerald Combs <gerald@wireshark.org> |
6 | | * Copyright 1998 Gerald Combs |
7 | | * |
8 | | * SPDX-License-Identifier: GPL-2.0-or-later |
9 | | */ |
10 | | |
11 | | |
12 | | #ifndef __PACKET_IP_H__ |
13 | | #define __PACKET_IP_H__ |
14 | | |
15 | | #include "ws_symbol_export.h" |
16 | | #include "packet-ipv6.h" |
17 | | #include <epan/conversation.h> |
18 | | |
19 | | /* |
20 | | * IP Version numbers, from |
21 | | * |
22 | | * https://www.iana.org/assignments/version-numbers/version-numbers.xhtml |
23 | | */ |
24 | | #define IP_VERSION_NUM_RESERVED 0 /* Reserved */ |
25 | 66 | #define IP_VERSION_NUM_INET 4 /* IP (IP version 4) */ |
26 | | #define IP_VERSION_NUM_ST 5 /* ST Datagram Mode */ |
27 | 67 | #define IP_VERSION_NUM_INET6 6 /* IP6 (IP version 6) */ |
28 | | #define IP_VERSION_NUM_TPIX 7 /* TP/IX: The Next Internet */ |
29 | | #define IP_VERSION_NUM_PIP 8 /* The P Internet Protocol */ |
30 | | #define IP_VERSION_NUM_TUBA 9 /* TUBA */ |
31 | | |
32 | | extern const value_string ip_version_vals[]; |
33 | | |
34 | | typedef struct _ws_ip4 |
35 | | { |
36 | | uint8_t ip_ver; /* 4 */ |
37 | | uint8_t ip_tos; /* type of service */ |
38 | | uint32_t ip_len; /* total length */ |
39 | | uint16_t ip_id; /* identification */ |
40 | | uint16_t ip_off; /* fragment offset */ |
41 | | uint8_t ip_ttl; /* time-to-live */ |
42 | | uint8_t ip_proto; /* protocol */ |
43 | | uint16_t ip_sum; /* checksum */ |
44 | | address ip_src; /* source address */ |
45 | | address ip_dst; /* destination address */ |
46 | | uint32_t ip_stream; /* track conversations */ |
47 | | } ws_ip4; |
48 | | |
49 | 4.34k | #define WS_IP4_PTR(p) ((ws_ip4 *)(((p) && *(uint8_t *)(p) == 4) ? (p) : NULL)) |
50 | | |
51 | | /* Differentiated Services Codepoint */ |
52 | 84.5k | #define IPDSFIELD_DSCP_MASK 0xFC |
53 | 84.5k | #define IPDSFIELD_DSCP(dsfield) (((dsfield) & IPDSFIELD_DSCP_MASK) >> 2) |
54 | | |
55 | | /* Explicit Congestion Notification */ |
56 | 37.0k | #define IPDSFIELD_ECN_MASK 0x03 |
57 | 37.0k | #define IPDSFIELD_ECN(dsfield) ((dsfield) & IPDSFIELD_ECN_MASK) |
58 | | |
59 | | bool ip_try_dissect(bool heur_first, unsigned nxt, tvbuff_t *tvb, |
60 | | packet_info *pinfo, proto_tree *tree, void *iph); |
61 | | |
62 | | /* Export the DSCP/ECN extended value-string table for other protocols */ |
63 | | WS_DLL_PUBLIC value_string_ext dscp_vals_ext; |
64 | | WS_DLL_PUBLIC value_string_ext ecn_vals_ext; |
65 | | WS_DLL_PUBLIC value_string_ext dscp_short_vals_ext; |
66 | | WS_DLL_PUBLIC value_string_ext ecn_short_vals_ext; |
67 | | |
68 | | typedef struct _ws_ip6 |
69 | | { |
70 | | uint8_t ip6_ver; /* 6 */ |
71 | | uint8_t ip6_tc; /* traffic class */ |
72 | | uint32_t ip6_flw; /* flow label */ |
73 | | uint32_t ip6_len; /* payload length */ |
74 | | uint8_t ip6_nxt; /* next header */ |
75 | | uint8_t ip6_hop; /* hop limit */ |
76 | | address ip6_src; /* source address */ |
77 | | address ip6_dst; /* destination address */ |
78 | | uint32_t ip6_stream; /* track conversations */ |
79 | | } ws_ip6; |
80 | | |
81 | 2.66k | #define WS_IP6_PTR(p) ((ws_ip6 *)(((p) && *(uint8_t *)(p) == 6) ? (p) : NULL)) |
82 | | |
83 | | struct ws_rthdr { |
84 | | struct ws_ip6_rthdr hdr; |
85 | | proto_item *ti_len; |
86 | | proto_item *ti_type; |
87 | | proto_item *ti_segleft; |
88 | | }; |
89 | | |
90 | | typedef ws_ip6 ipv6_tap_info_t; |
91 | | |
92 | | /* Packet info for shared state between IPv6 header and extensions. |
93 | | * |
94 | | * frag_plen: This is the IPv6 header payload length of a fragment packet |
95 | | * minus per-fragment *extension* headers (anything up to and including the |
96 | | * Fragment extension header). |
97 | | * |
98 | | * See RFC 8200 Section 4.5: |
99 | | * The Per-Fragment headers must consist of the IPv6 header plus any |
100 | | * extension headers that must be processed by nodes en route to the |
101 | | * destination, that is, all headers up to and including the Routing |
102 | | * header if present, else the Hop-by-Hop Options header if present, |
103 | | * else no extension headers. |
104 | | */ |
105 | | typedef struct { |
106 | | uint32_t jumbo_plen; |
107 | | uint16_t ip6_plen; /* header payload length (can be zero) */ |
108 | | int frag_plen; |
109 | | proto_tree *ipv6_tree; |
110 | | int ipv6_item_len; |
111 | | } ipv6_pinfo_t; |
112 | | |
113 | | ipv6_pinfo_t *p_get_ipv6_pinfo(packet_info *pinfo); |
114 | | |
115 | | proto_tree *p_ipv6_pinfo_select_root(packet_info *pinfo, proto_tree *tree); |
116 | | |
117 | | ipv6_pinfo_t *p_ipv6_pinfo_add_len(packet_info *pinfo, int exthdr_len); |
118 | | |
119 | | void ipv6_dissect_next(unsigned nxt, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, ws_ip6 *iph); |
120 | | |
121 | | static inline int |
122 | | ws_ip_protocol(void *iph) |
123 | 989 | { |
124 | 989 | ws_ip4 *ip4; |
125 | 989 | ws_ip6 *ip6; |
126 | | |
127 | 989 | if (iph != NULL) { |
128 | 977 | if ((ip4 = WS_IP4_PTR(iph)) != NULL) |
129 | 268 | return ip4->ip_proto; |
130 | 709 | if ((ip6 = WS_IP6_PTR(iph)) != NULL) |
131 | 709 | return ip6->ip6_nxt; |
132 | 709 | } |
133 | 12 | return -1; |
134 | 989 | } Unexecuted instantiation: packet-arcnet.c:ws_ip_protocol Unexecuted instantiation: packet-bgp.c:ws_ip_protocol Unexecuted instantiation: packet-chdlc.c:ws_ip_protocol Unexecuted instantiation: packet-clip.c:ws_ip_protocol Unexecuted instantiation: packet-dns.c:ws_ip_protocol Unexecuted instantiation: packet-f5ethtrailer.c:ws_ip_protocol Unexecuted instantiation: packet-gtpv2.c:ws_ip_protocol Unexecuted instantiation: packet-icmp.c:ws_ip_protocol Unexecuted instantiation: packet-icmpv6.c:ws_ip_protocol Unexecuted instantiation: packet-ip.c:ws_ip_protocol Unexecuted instantiation: packet-ipsec.c:ws_ip_protocol Unexecuted instantiation: packet-ipv6.c:ws_ip_protocol Unexecuted instantiation: packet-megaco.c:ws_ip_protocol Unexecuted instantiation: packet-mip6.c:ws_ip_protocol Unexecuted instantiation: packet-mpls-pm.c:ws_ip_protocol Unexecuted instantiation: packet-null.c:ws_ip_protocol Unexecuted instantiation: packet-pfcp.c:ws_ip_protocol Unexecuted instantiation: packet-ppp.c:ws_ip_protocol Unexecuted instantiation: packet-raw.c:ws_ip_protocol Unexecuted instantiation: packet-rsvp.c:ws_ip_protocol Unexecuted instantiation: packet-shim6.c:ws_ip_protocol packet-stt.c:ws_ip_protocol Line | Count | Source | 123 | 492 | { | 124 | 492 | ws_ip4 *ip4; | 125 | 492 | ws_ip6 *ip6; | 126 | | | 127 | 492 | if (iph != NULL) { | 128 | 486 | if ((ip4 = WS_IP4_PTR(iph)) != NULL) | 129 | 134 | return ip4->ip_proto; | 130 | 352 | if ((ip6 = WS_IP6_PTR(iph)) != NULL) | 131 | 352 | return ip6->ip6_nxt; | 132 | 352 | } | 133 | 6 | return -1; | 134 | 492 | } |
packet-tapa.c:ws_ip_protocol Line | Count | Source | 123 | 497 | { | 124 | 497 | ws_ip4 *ip4; | 125 | 497 | ws_ip6 *ip6; | 126 | | | 127 | 497 | if (iph != NULL) { | 128 | 491 | if ((ip4 = WS_IP4_PTR(iph)) != NULL) | 129 | 134 | return ip4->ip_proto; | 130 | 357 | if ((ip6 = WS_IP6_PTR(iph)) != NULL) | 131 | 357 | return ip6->ip6_nxt; | 132 | 357 | } | 133 | 6 | return -1; | 134 | 497 | } |
Unexecuted instantiation: ipproto.c:ws_ip_protocol |
135 | | |
136 | | struct ip_analysis { |
137 | | |
138 | | /* Initial frame starting this conversation |
139 | | */ |
140 | | uint32_t initial_frame; |
141 | | |
142 | | uint32_t stream; |
143 | | }; |
144 | | |
145 | | WS_DLL_PUBLIC struct ip_analysis *get_ip_conversation_data(conversation_t *conv, |
146 | | packet_info *pinfo); |
147 | | |
148 | | #endif /* __PACKET_IP_H__ */ |
149 | | |
150 | | /* |
151 | | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
152 | | * |
153 | | * Local variables: |
154 | | * c-basic-offset: 4 |
155 | | * tab-width: 8 |
156 | | * indent-tabs-mode: nil |
157 | | * End: |
158 | | * |
159 | | * vi: set shiftwidth=4 tabstop=8 expandtab: |
160 | | * :indentSize=4:tabSize=8:noTabs=true: |
161 | | */ |