Wireshark 2.9.0-477-g68ec514b The Wireshark network protocol analyzer

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

packet-ip.h
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
17 /*
18 * IP Version numbers, from
19 *
20 * https://www.iana.org/assignments/version-numbers/version-numbers.xhtml
21 */
22 #define IP_VERSION_NUM_RESERVED 0 /* Reserved */
23 #define IP_VERSION_NUM_INET 4 /* IP (IP version 4) */
24 #define IP_VERSION_NUM_ST 5 /* ST Datagram Mode */
25 #define IP_VERSION_NUM_INET6 6 /* IP6 (IP version 6) */
26 #define IP_VERSION_NUM_TPIX 7 /* TP/IX: The Next Internet */
27 #define IP_VERSION_NUM_PIP 8 /* The P Internet Protocol */
28 #define IP_VERSION_NUM_TUBA 9 /* TUBA */
29
30 extern const value_string ip_version_vals[];
31
32 typedef struct _ws_ip4
33 {
34 guint8 ip_ver; /* 4 */
35 guint8 ip_tos; /* type of service */
36 guint32 ip_len; /* total length */
37 guint16 ip_id; /* identification */
38 guint16 ip_off; /* fragment offset */
39 guint8 ip_ttl; /* time-to-live */
40 guint8 ip_proto; /* protocol */
41 guint16 ip_sum; /* checksum */
42 address ip_src; /* source address */
43 address ip_dst; /* destination address */
44 } ws_ip4;
45
46 #define WS_IP4_PTR(p) ((ws_ip4 *)(((p) && *(guint8 *)(p) == 4) ? (p) : NULL))
47
48 /* Differentiated Services Codepoint */
49 #define IPDSFIELD_DSCP_MASK 0xFC
50 #define IPDSFIELD_DSCP(dsfield) (((dsfield) & IPDSFIELD_DSCP_MASK) >> 2)
51
52 /* Explicit Congestion Notification */
53 #define IPDSFIELD_ECN_MASK 0x03
54 #define IPDSFIELD_ECN(dsfield) ((dsfield) & IPDSFIELD_ECN_MASK)
55
56 gboolean ip_try_dissect(gboolean heur_first, guint nxt, tvbuff_t *tvb,
57 packet_info *pinfo, proto_tree *tree, void *iph);
58
59 /* Export the DSCP/ECN extended value-string table for other protocols */
60 WS_DLL_PUBLIC value_string_ext dscp_vals_ext;
61 WS_DLL_PUBLIC value_string_ext ecn_vals_ext;
62 WS_DLL_PUBLIC value_string_ext dscp_short_vals_ext;
63 WS_DLL_PUBLIC value_string_ext ecn_short_vals_ext;
64
65 typedef struct _ws_ip6
66 {
67 guint8 ip6_ver; /* 6 */
68 guint8 ip6_tc; /* traffic class */
69 guint32 ip6_flw; /* flow label */
70 guint32 ip6_len; /* payload length */
71 guint8 ip6_nxt; /* next header */
72 guint8 ip6_hop; /* hop limit */
73 address ip6_src; /* source address */
74 address ip6_dst; /* destination address */
75 } ws_ip6;
76
77 #define WS_IP6_PTR(p) ((ws_ip6 *)(((p) && *(guint8 *)(p) == 6) ? (p) : NULL))
78
79 struct ws_rthdr {
80 struct ip6_rthdr hdr;
81 proto_item *ti_len;
82 proto_item *ti_type;
83 proto_item *ti_segleft;
84 };
85
86 typedef ws_ip6 ipv6_tap_info_t;
87
88 /* Packet info for shared state between IPv6 header and extensions */
89 typedef struct {
90 guint32 jumbo_plen;
91 guint16 ip6_plen;
92 gint frag_plen;
93 proto_tree *ipv6_tree;
94 gint ipv6_item_len;
95 } ipv6_pinfo_t;
96
97 ipv6_pinfo_t *p_get_ipv6_pinfo(packet_info *pinfo);
98
99 proto_tree *p_ipv6_pinfo_select_root(packet_info *pinfo, proto_tree *tree);
100
101 ipv6_pinfo_t *p_ipv6_pinfo_add_len(packet_info *pinfo, int exthdr_len);
102
103 void ipv6_dissect_next(guint nxt, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, ws_ip6 *iph);
104
105 static inline int
106 ws_ip_protocol(void *iph)
107 {
108 ws_ip4 *ip4;
109 ws_ip6 *ip6;
110
111 if (iph != NULL) {
112 if ((ip4 = WS_IP4_PTR(iph)) != NULL)
113 return ip4->ip_proto;
114 if ((ip6 = WS_IP6_PTR(iph)) != NULL)
115 return ip6->ip6_nxt;
116 }
117 return -1;
118 }
119
120 #endif /* __PACKET_IP_H__ */
121
122 /*
123 * Editor modelines - http://www.wireshark.org/tools/modelines.html
124 *
125 * Local variables:
126 * c-basic-offset: 4
127 * tab-width: 8
128 * indent-tabs-mode: nil
129 * End:
130 *
131 * vi: set shiftwidth=4 tabstop=8 expandtab:
132 * :indentSize=4:tabSize=8:noTabs=true:
133 */
ip6_rthdr
Definition: inet_ipv6.h:47
_ws_ip4
Definition: packet-ip.h:32
_packet_info
Definition: packet_info.h:44
tvbuff
Definition: tvbuff-int.h:35
_ws_ip6
Definition: packet-ip.h:65
ipv6_pinfo_t
Definition: packet-ip.h:89
ws_rthdr
Definition: packet-ip.h:79
_value_string
Definition: value_string.h:24
_value_string_ext
Definition: value_string.h:164
_proto_node
Definition: proto.h:759
_address
Definition: address.h:47