Use MAC address documentation range in filter examples
[metze/wireshark/wip.git] / epan / dissectors / packet-sna.c
index 1f50007ac99a47451e7ce5db4846e6e4bbc7f317..82bd620550988929069c9bf39bceb8fcd16bdf52 100644 (file)
@@ -829,10 +829,11 @@ static void dissect_gds (tvbuff_t*, packet_info*, proto_tree*, proto_tree*);
 static void dissect_rh (tvbuff_t*, int, proto_tree*);
 static void dissect_control(tvbuff_t*, int, int, proto_tree*, int, enum parse);
 
-static gboolean sna_fid_to_str_buf(const address *addr, gchar *buf, int buf_len _U_)
+static int sna_fid_to_str_buf(const address *addr, gchar *buf, int buf_len _U_)
 {
        const guint8 *addrdata;
        struct sna_fid_type_4_addr sna_fid_type_4_addr;
+       gchar *bufp = buf;
 
        switch (addr->len) {
 
@@ -852,17 +853,17 @@ static gboolean sna_fid_to_str_buf(const address *addr, gchar *buf, int buf_len
                /* FID Type 4 */
                memcpy(&sna_fid_type_4_addr, addr->data, SNA_FID_TYPE_4_ADDR_LEN);
 
-               buf = dword_to_hex(buf, sna_fid_type_4_addr.saf);
-               *buf++ = '.';
-               buf = word_to_hex(buf, sna_fid_type_4_addr.ef);
-               *buf++ = '\0'; /* NULL terminate */
+               bufp = dword_to_hex(bufp, sna_fid_type_4_addr.saf);
+               *bufp++ = '.';
+               bufp = word_to_hex(bufp, sna_fid_type_4_addr.ef);
+               *bufp++ = '\0'; /* NULL terminate */
                break;
        default:
                buf[0] = '\0';
-               return FALSE;
+               return 1;
        }
 
-       return TRUE;
+       return (int)strlen(buf)+1;
 }
 
 
@@ -1728,13 +1729,13 @@ dissect_fid0_1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 
        /* Set DST addr */
        TVB_SET_ADDRESS(&pinfo->net_dst, sna_address_type, tvb, 2, SNA_FID01_ADDR_LEN);
-       TVB_SET_ADDRESS(&pinfo->dst, sna_address_type, tvb, 2, SNA_FID01_ADDR_LEN);
+       COPY_ADDRESS_SHALLOW(&pinfo->dst, &pinfo->net_dst);
 
        proto_tree_add_item(tree, hf_sna_th_oaf, tvb, 4, 2, ENC_BIG_ENDIAN);
 
        /* Set SRC addr */
        TVB_SET_ADDRESS(&pinfo->net_src, sna_address_type, tvb, 4, SNA_FID01_ADDR_LEN);
-       TVB_SET_ADDRESS(&pinfo->src, sna_address_type, tvb, 4, SNA_FID01_ADDR_LEN);
+       COPY_ADDRESS_SHALLOW(&pinfo->src, &pinfo->net_src);
 
        proto_tree_add_item(tree, hf_sna_th_snf, tvb, 6, 2, ENC_BIG_ENDIAN);
        proto_tree_add_item(tree, hf_sna_th_dcf, tvb, 8, 2, ENC_BIG_ENDIAN);
@@ -1780,14 +1781,14 @@ dissect_fid2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
 
        /* Set DST addr */
        TVB_SET_ADDRESS(&pinfo->net_dst, sna_address_type, tvb, 2, SNA_FID2_ADDR_LEN);
-       TVB_SET_ADDRESS(&pinfo->dst, sna_address_type, tvb, 2, SNA_FID2_ADDR_LEN);
+       COPY_ADDRESS_SHALLOW(&pinfo->dst, &pinfo->net_dst);
 
        /* Byte 3 */
        proto_tree_add_item(tree, hf_sna_th_oaf, tvb, 3, 1, ENC_BIG_ENDIAN);
 
        /* Set SRC addr */
        TVB_SET_ADDRESS(&pinfo->net_src, sna_address_type, tvb, 3, SNA_FID2_ADDR_LEN);
-       TVB_SET_ADDRESS(&pinfo->src, sna_address_type, tvb, 3, SNA_FID2_ADDR_LEN);
+       COPY_ADDRESS_SHALLOW(&pinfo->src, &pinfo->net_src);
 
        id = tvb_get_ntohs(tvb, 4);
        proto_tree_add_item(tree, hf_sna_th_snf, tvb, 4, 2, ENC_BIG_ENDIAN);
@@ -1978,7 +1979,7 @@ dissect_fid4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        dst->saf = dsaf;
        dst->ef = def;
        SET_ADDRESS(&pinfo->net_dst, sna_address_type, SNA_FID_TYPE_4_ADDR_LEN, dst);
-       SET_ADDRESS(&pinfo->dst, sna_address_type, SNA_FID_TYPE_4_ADDR_LEN, dst);
+       COPY_ADDRESS_SHALLOW(&pinfo->dst, &pinfo->net_dst);
 
        oef = tvb_get_ntohs(tvb, 20);
        proto_tree_add_uint(tree, hf_sna_th_oef, tvb, offset+2, 2, oef);
@@ -1988,7 +1989,7 @@ dissect_fid4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        src->saf = osaf;
        src->ef = oef;
        SET_ADDRESS(&pinfo->net_src, sna_address_type, SNA_FID_TYPE_4_ADDR_LEN, src);
-       SET_ADDRESS(&pinfo->src, sna_address_type, SNA_FID_TYPE_4_ADDR_LEN, src);
+       COPY_ADDRESS_SHALLOW(&pinfo->src, &pinfo->net_src);
 
        proto_tree_add_item(tree, hf_sna_th_snf, tvb, offset+4, 2, ENC_BIG_ENDIAN);
        proto_tree_add_item(tree, hf_sna_th_dcf, tvb, offset+6, 2, ENC_BIG_ENDIAN);
@@ -2326,7 +2327,7 @@ dissect_control(tvbuff_t *parent_tvb, int offset, int control_len,
        int             len, key;
        gint            ett;
 
-       length = tvb_length_remaining(parent_tvb, offset);
+       length = tvb_captured_length_remaining(parent_tvb, offset);
        reported_length = tvb_reported_length_remaining(parent_tvb, offset);
        if (control_len < length)
                length = control_len;
@@ -2510,6 +2511,12 @@ sna_init(void)
            &addresses_reassembly_table_functions);
 }
 
+static void
+sna_cleanup(void)
+{
+       reassembly_table_destroy(&sna_reassembly_table);
+}
+
 
 void
 proto_register_sna(void)
@@ -3481,7 +3488,7 @@ proto_register_sna(void)
            "Systems Network Architecture XID", "SNA XID", "sna_xid");
        register_dissector("sna_xid", dissect_sna_xid, proto_sna_xid);
 
-       sna_address_type = address_type_dissector_register("AT_SNA", "SNA Address", sna_fid_to_str_buf, sna_address_str_len, NULL, NULL);
+       sna_address_type = address_type_dissector_register("AT_SNA", "SNA Address", sna_fid_to_str_buf, sna_address_str_len, NULL, NULL, NULL, NULL);
 
        /* Register configuration options */
        sna_module = prefs_register_protocol(proto_sna, NULL);
@@ -3491,6 +3498,7 @@ proto_register_sna(void)
                &sna_defragment);
 
        register_init_routine(sna_init);
+       register_cleanup_routine(sna_cleanup);
 }
 
 void