]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-sflow.c
CONTRIBUTION: mention the nd_ types.
[tcpdump] / print-sflow.c
index 71ca26630ab56067148093aff74b81b17020821c..ea947ba2b4f0ce10d57332c600cf7184037a98a5 100644 (file)
@@ -120,22 +120,22 @@ struct sflow_expanded_flow_sample_t {
     nd_uint32_t records;
 };
 
-#define        SFLOW_FLOW_RAW_PACKET                   1
-#define        SFLOW_FLOW_ETHERNET_FRAME               2
-#define        SFLOW_FLOW_IPV4_DATA                    3
-#define        SFLOW_FLOW_IPV6_DATA                    4
-#define        SFLOW_FLOW_EXTENDED_SWITCH_DATA         1001
-#define        SFLOW_FLOW_EXTENDED_ROUTER_DATA         1002
-#define        SFLOW_FLOW_EXTENDED_GATEWAY_DATA        1003
-#define        SFLOW_FLOW_EXTENDED_USER_DATA           1004
-#define        SFLOW_FLOW_EXTENDED_URL_DATA            1005
-#define        SFLOW_FLOW_EXTENDED_MPLS_DATA           1006
-#define        SFLOW_FLOW_EXTENDED_NAT_DATA            1007
-#define        SFLOW_FLOW_EXTENDED_MPLS_TUNNEL         1008
-#define        SFLOW_FLOW_EXTENDED_MPLS_VC             1009
-#define        SFLOW_FLOW_EXTENDED_MPLS_FEC            1010
-#define        SFLOW_FLOW_EXTENDED_MPLS_LVP_FEC        1011
-#define        SFLOW_FLOW_EXTENDED_VLAN_TUNNEL         1012
+#define        SFLOW_FLOW_RAW_PACKET                   1
+#define        SFLOW_FLOW_ETHERNET_FRAME               2
+#define        SFLOW_FLOW_IPV4_DATA                    3
+#define        SFLOW_FLOW_IPV6_DATA                    4
+#define        SFLOW_FLOW_EXTENDED_SWITCH_DATA         1001
+#define        SFLOW_FLOW_EXTENDED_ROUTER_DATA         1002
+#define        SFLOW_FLOW_EXTENDED_GATEWAY_DATA        1003
+#define        SFLOW_FLOW_EXTENDED_USER_DATA           1004
+#define        SFLOW_FLOW_EXTENDED_URL_DATA            1005
+#define        SFLOW_FLOW_EXTENDED_MPLS_DATA           1006
+#define        SFLOW_FLOW_EXTENDED_NAT_DATA            1007
+#define        SFLOW_FLOW_EXTENDED_MPLS_TUNNEL         1008
+#define        SFLOW_FLOW_EXTENDED_MPLS_VC             1009
+#define        SFLOW_FLOW_EXTENDED_MPLS_FEC            1010
+#define        SFLOW_FLOW_EXTENDED_MPLS_LVP_FEC        1011
+#define        SFLOW_FLOW_EXTENDED_VLAN_TUNNEL         1012
 
 static const struct tok sflow_flow_type_values[] = {
     { SFLOW_FLOW_RAW_PACKET, "Raw packet"},
@@ -864,7 +864,7 @@ sflow_print(netdissect_options *ndo,
 
     /* ok they seem to want to know everything - lets fully decode it */
     if (ip_version == 1) {
-        nsamples=GET_BE_U_4(sflow_datagram->samples);
+        nsamples = GET_BE_U_4(sflow_datagram->samples);
         ND_PRINT("sFlowv%u, %s agent %s, agent-id %u, seqnum %u, uptime %u, samples %u, length %u",
                GET_BE_U_4(sflow_datagram->version),
                "IPv4",
@@ -876,10 +876,11 @@ sflow_print(netdissect_options *ndo,
                len);
 
         /* skip Common header */
+        ND_ICHECK_ZU(tlen, <, sizeof(struct sflow_datagram_t));
         tptr += sizeof(struct sflow_datagram_t);
         tlen -= sizeof(struct sflow_datagram_t);
     } else {
-        nsamples=GET_BE_U_4(sflow_v6_datagram->samples);
+        nsamples = GET_BE_U_4(sflow_v6_datagram->samples);
         ND_PRINT("sFlowv%u, %s agent %s, agent-id %u, seqnum %u, uptime %u, samples %u, length %u",
                GET_BE_U_4(sflow_v6_datagram->version),
                "IPv6",
@@ -891,6 +892,7 @@ sflow_print(netdissect_options *ndo,
                len);
 
         /* skip Common header */
+        ND_ICHECK_ZU(tlen, <, sizeof(struct sflow_v6_datagram_t));
         tptr += sizeof(struct sflow_v6_datagram_t);
         tlen -= sizeof(struct sflow_v6_datagram_t);
     }
@@ -912,7 +914,7 @@ sflow_print(netdissect_options *ndo,
                sflow_sample_len);
 
         /* basic sanity check */
-        if (sflow_sample_type == 0 || sflow_sample_len ==0) {
+        if (sflow_sample_type == 0 || sflow_sample_len == 0) {
             return;
         }