aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>2015-11-29 15:22:36 +0000
committerMichael Mann <mmann78@netscape.net>2015-11-29 21:38:30 +0000
commit2932596b65c36a63e79ab85d3349d404a1e16b37 (patch)
treeb9383de6e0560f6ebf5f73b97c41edf25da772ce /epan
parente75f74add63243fcaf620e47ae232f26a5b6dd67 (diff)
IPv6: Add ipv6extprotostr() to ipproto.h
Move ipv6_exthdr_check() to ipproto.c. Seems a better fit, prevents future code duplication. Change-Id: I84f247febd1499e334289e3057ec1d8ba32d5bcc Reviewed-on: https://code.wireshark.org/review/12283 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-ipv6.c28
-rw-r--r--epan/ipproto.c30
-rw-r--r--epan/ipproto.h2
3 files changed, 34 insertions, 26 deletions
diff --git a/epan/dissectors/packet-ipv6.c b/epan/dissectors/packet-ipv6.c
index d8c9bd2b69..8d992cae36 100644
--- a/epan/dissectors/packet-ipv6.c
+++ b/epan/dissectors/packet-ipv6.c
@@ -448,31 +448,6 @@ ipv6_build_filter(packet_info *pinfo)
address_to_str(pinfo->pool, &pinfo->net_dst));
}
-/* https://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml#extension-header */
-static gboolean
-ipv6_exthdr_check(int proto) {
- switch (proto) {
- /* fall through all cases */
- case 0: /* IPv6 Hop-by-Hop Option */
- case 43: /* Routing Header for IPv6 */
- case 44: /* Fragment Header for IPv6 */
- case 50: /* Encapsulating Security Payload */
- case 51: /* Authentication Header */
- case 60: /* Destination Options for IPv6 */
- case 135: /* Mobility Header */
- case 139: /* Host Identity Protocol */
- case 140: /* Shim6 Protocol */
- /* Experimental values ignored because they can collide with
- * other experimental uses not relating to IPv6 parameters */
-/* case 253: */ /* Use for experimentation and testing */
-/* case 254: */ /* Use for experimentation and testing */
- return TRUE;
- default:
- break;
- }
- return FALSE;
-}
-
static const fragment_items ipv6_frag_items = {
&ett_ipv6_fragment,
&ett_ipv6_fragments,
@@ -2398,7 +2373,8 @@ again:
break;
default:
- if (ipv6_exthdr_check(nxt) && !dissector_get_uint_handle(ip_dissector_table, nxt)) {
+ if ((ipv6extprotostr(nxt) != NULL) &&
+ !dissector_get_uint_handle(ip_dissector_table, nxt)) {
advance = dissect_unknown_exthdr(tvb, offset, ipv6_exthdr_tree);
nxt = tvb_get_guint8(tvb, offset);
offset += advance;
diff --git a/epan/ipproto.c b/epan/ipproto.c
index e865600750..4b1814ea88 100644
--- a/epan/ipproto.c
+++ b/epan/ipproto.c
@@ -296,6 +296,36 @@ const char *ipprotostr(const int proto) {
return s;
}
+/* https://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml#extension-header */
+
+static gboolean ipv6_exthdr_check(int proto)
+{
+ switch (proto) {
+ /* fall through all cases */
+ case IP_PROTO_HOPOPTS: /* IPv6 Hop-by-Hop Option */
+ case IP_PROTO_ROUTING: /* Routing Header for IPv6 */
+ case IP_PROTO_FRAGMENT: /* Fragment Header for IPv6 */
+ case IP_PROTO_ESP: /* Encapsulating Security Payload */
+ case IP_PROTO_AH: /* Authentication Header */
+ case IP_PROTO_DSTOPTS: /* Destination Options for IPv6 */
+ case IP_PROTO_MIPV6: /* Mobility Header */
+ case IP_PROTO_HIP: /* Host Identity Protocol */
+ case IP_PROTO_SHIM6: /* Shim6 Protocol */
+ return TRUE;
+ break;
+ default:
+ break;
+ }
+ return FALSE;
+}
+
+const char *ipv6extprotostr(int proto)
+{
+ if (ipv6_exthdr_check(proto))
+ return ipprotostr(proto);
+ return NULL;
+}
+
/*
* Editor modelines
*
diff --git a/epan/ipproto.h b/epan/ipproto.h
index ba15f9336d..90b8c9efdb 100644
--- a/epan/ipproto.h
+++ b/epan/ipproto.h
@@ -194,6 +194,8 @@
WS_DLL_PUBLIC value_string_ext ipproto_val_ext;
WS_DLL_PUBLIC const char *ipprotostr(const int proto);
+WS_DLL_PUBLIC const char *ipv6extprotostr(int proto);
+
#endif /* ipproto.h */
/*