Rename the routines that handle dissector tables with unsigned integer
[obnox/wireshark/wip.git] / epan / dissectors / packet-kpasswd.c
index a6584668e53acd910f534994840aed027b7a26c2..34c5cb0c7e3ad89f6e6e19bcc439741731469118 100644 (file)
@@ -30,7 +30,6 @@
 #endif
 
 #include <epan/packet.h>
-#include <epan/emem.h>
 #include <epan/asn1.h>
 #include "packet-tcp.h"
 #include "packet-kerberos.h"
@@ -83,14 +82,14 @@ dissect_kpasswd_ap_req_data(packet_info *pinfo _U_, tvbuff_t *tvb, proto_tree *p
 }
 
 
-static int dissect_kpasswd_newpassword(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_)
+static int dissect_kpasswd_newpassword(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_)
 {
-       offset=dissect_ber_octet_string_wcb(FALSE, pinfo, tree, tvb, offset, hf_kpasswd_newpassword, NULL);
+       offset=dissect_ber_octet_string_wcb(FALSE, actx, tree, tvb, offset, hf_kpasswd_newpassword, NULL);
 
        return offset;
 }
 
-static ber_sequence_t ChangePasswdData_sequence[] = {
+static ber_old_sequence_t ChangePasswdData_sequence[] = {
        { BER_CLASS_CON, 0, 0,
                dissect_kpasswd_newpassword },
        { BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL, 
@@ -104,8 +103,10 @@ static int
 dissect_kpasswd_user_data_request(packet_info *pinfo, tvbuff_t *tvb, proto_tree *tree)
 {
     int offset=0;
+       asn1_ctx_t asn1_ctx;
+       asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
 
-    offset=dissect_ber_sequence(FALSE, pinfo, tree, tvb, offset, ChangePasswdData_sequence, hf_kpasswd_ChangePasswdData, ett_ChangePasswdData);
+    offset=dissect_ber_old_sequence(FALSE, &asn1_ctx, tree, tvb, offset, ChangePasswdData_sequence, hf_kpasswd_ChangePasswdData, ett_ChangePasswdData);
 
     return offset;
 }
@@ -146,7 +147,7 @@ dissect_kpasswd_user_data_reply(packet_info *pinfo, tvbuff_t *tvb, proto_tree *t
     proto_tree_add_uint(tree, hf_kpasswd_result, tvb, offset, 2, result);
     offset+=2;
     if (check_col(pinfo->cinfo, COL_INFO))
-        col_set_str(pinfo->cinfo, COL_INFO, 
+        col_add_str(pinfo->cinfo, COL_INFO, 
                    val_to_str(result, kpasswd_result_types, "Result: %u"));
 
    
@@ -201,10 +202,8 @@ dissect_kpasswd_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboo
         gint krb_reclen = 0;
         gint krb_rm_size = 0;    /* bytes consumed by record mark: 0 or 4 */
 
-       if (check_col(pinfo->cinfo, COL_PROTOCOL))
-               col_set_str(pinfo->cinfo, COL_PROTOCOL, "KPASSWD");
-       if (check_col(pinfo->cinfo, COL_INFO))
-               col_clear(pinfo->cinfo, COL_INFO);
+       col_set_str(pinfo->cinfo, COL_PROTOCOL, "KPASSWD");
+       col_clear(pinfo->cinfo, COL_INFO);
 
         /* can't pass have_rm to dissect_kerberos_main, so strip rm first */
         if (have_rm) {
@@ -224,7 +223,7 @@ dissect_kpasswd_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboo
        if(tvb_get_guint8(tvb, offset)==0x7e){
                 /* TCP record mark, if any, not displayed.  But hopefully
                    KRB-ERROR dissection will proceed correctly. */
-               next_tvb=tvb_new_subset(tvb, offset, -1, -1);
+               next_tvb=tvb_new_subset_remaining(tvb, offset);
                return dissect_kerberos_main(next_tvb, pinfo, tree, FALSE, NULL);
        }
 
@@ -242,7 +241,7 @@ dissect_kpasswd_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboo
        proto_tree_add_uint(kpasswd_tree, hf_kpasswd_message_len, tvb, offset, 2, message_len);
        proto_tree_add_uint(kpasswd_tree, hf_kpasswd_version, tvb, offset+2, 2, version);
        if (check_col(pinfo->cinfo, COL_INFO))
-               col_set_str(pinfo->cinfo, COL_INFO, val_to_str(version, vers_vals, "Unknown command"));
+               col_add_str(pinfo->cinfo, COL_INFO, val_to_str(version, vers_vals, "Unknown command"));
        proto_tree_add_uint(kpasswd_tree, hf_kpasswd_ap_req_len, tvb, offset+4, 2, ap_req_len);
        offset+=6;
 
@@ -252,7 +251,7 @@ dissect_kpasswd_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboo
        offset+=ap_req_len;
 
        /* KRB-PRIV message */
-       next_tvb=tvb_new_subset(tvb, offset, -1, -1);
+       next_tvb=tvb_new_subset_remaining(tvb, offset);
        offset += dissect_kpasswd_krb_priv_message(pinfo, next_tvb, kpasswd_tree, (version==0xff80));
 
         proto_item_set_len(kpasswd_item, offset);
@@ -277,19 +276,15 @@ dissect_kpasswd_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
         * The dissector failed to recognize this as a valid
         * Kerberos message.  Mark it as a continuation packet.
         */
-       if (check_col(pinfo->cinfo, COL_INFO)) {
-               col_set_str(pinfo->cinfo, COL_INFO, "Continuation");
-       }
+       col_set_str(pinfo->cinfo, COL_INFO, "Continuation");
     }
 }
 
 static void
 dissect_kpasswd_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 {
-    if (check_col(pinfo->cinfo, COL_PROTOCOL))
-        col_set_str(pinfo->cinfo, COL_PROTOCOL, "KPASSWD");
-    if (check_col(pinfo->cinfo, COL_INFO))
-        col_clear(pinfo->cinfo, COL_INFO);
+    col_set_str(pinfo->cinfo, COL_PROTOCOL, "KPASSWD");
+    col_clear(pinfo->cinfo, COL_INFO);
 
     tcp_dissect_pdus(tvb, pinfo, tree, kpasswd_desegment, 4, get_krb_pdu_len,
        dissect_kpasswd_tcp_pdu);
@@ -301,22 +296,22 @@ proto_register_kpasswd(void)
        static hf_register_info hf[] = {
        { &hf_kpasswd_message_len,
                { "Message Length", "kpasswd.message_len", FT_UINT16, BASE_DEC,
-               NULL, 0, "Message Length", HFILL }},
+               NULL, 0, NULL, HFILL }},
        { &hf_kpasswd_ap_req_len,
                { "AP_REQ Length", "kpasswd.ap_req_len", FT_UINT16, BASE_DEC,
                NULL, 0, "Length of AP_REQ data", HFILL }},
        { &hf_kpasswd_version,
                { "Version", "kpasswd.version", FT_UINT16, BASE_HEX,
-               VALS(vers_vals), 0, "Version", HFILL }},
+               VALS(vers_vals), 0, NULL, HFILL }},
        { &hf_kpasswd_result,
                { "Result", "kpasswd.result", FT_UINT16, BASE_DEC,
-               VALS(kpasswd_result_types), 0, "Result", HFILL }},
+               VALS(kpasswd_result_types), 0, NULL, HFILL }},
        { &hf_kpasswd_result_string,
                { "Result String", "kpasswd.result_string", FT_STRING, BASE_NONE,
-               NULL, 0, "Result String", HFILL }},
+               NULL, 0, NULL, HFILL }},
        { &hf_kpasswd_newpassword,
                { "New Password", "kpasswd.new_password", FT_STRING, BASE_NONE,
-               NULL, 0, "New Password", HFILL }},
+               NULL, 0, NULL, HFILL }},
        { &hf_kpasswd_ap_req_data,
                { "AP_REQ", "kpasswd.ap_req", FT_NONE, BASE_NONE,
                NULL, 0, "AP_REQ structure", HFILL }},
@@ -324,7 +319,7 @@ proto_register_kpasswd(void)
                { "KRB-PRIV", "kpasswd.krb_priv", FT_NONE, BASE_NONE,
                NULL, 0, "KRB-PRIV message", HFILL }},
        { &hf_kpasswd_ChangePasswdData, {
-           "ChangePasswdData", "kpasswd.ChangePasswdData", FT_NONE, BASE_DEC,
+           "ChangePasswdData", "kpasswd.ChangePasswdData", FT_NONE, BASE_NONE,
            NULL, 0, "Change Password Data structure", HFILL }},
        };
 
@@ -358,7 +353,7 @@ proto_reg_handoff_kpasswd(void)
 
        kpasswd_handle_udp = create_dissector_handle(dissect_kpasswd_udp, proto_kpasswd);
         kpasswd_handle_tcp = create_dissector_handle(dissect_kpasswd_tcp, proto_kpasswd);
-       dissector_add("udp.port", UDP_PORT_KPASSWD, kpasswd_handle_udp);
-        dissector_add("tcp.port", TCP_PORT_KPASSWD, kpasswd_handle_tcp);
+       dissector_add_uint("udp.port", UDP_PORT_KPASSWD, kpasswd_handle_udp);
+        dissector_add_uint("tcp.port", TCP_PORT_KPASSWD, kpasswd_handle_tcp);
 
 }