From 121c65c613316380596cda4d3ae16c01f4e49c65 Mon Sep 17 00:00:00 2001 From: Bill Meier Date: Mon, 7 Feb 2011 18:49:29 +0000 Subject: Remove unneeded #includes (stdio.h,stdlib.h); Whitespace cleanup: trailing, indentation, "4-space tabs" svn path=/trunk/; revision=35850 --- epan/dissectors/packet-kink.c | 182 +++++++++++++++++++++--------------------- 1 file changed, 91 insertions(+), 91 deletions(-) (limited to 'epan/dissectors/packet-kink.c') diff --git a/epan/dissectors/packet-kink.c b/epan/dissectors/packet-kink.c index 8cf61e684f..fa3223f680 100644 --- a/epan/dissectors/packet-kink.c +++ b/epan/dissectors/packet-kink.c @@ -1,7 +1,7 @@ /* packet-kink.c - * Routines for KINK packet disassembly + * Routines for KINK packet disassembly * It is referrenced draft-ietf-kink-kink-jp-04.txt,v 1.14 2003/02/10 - * + * * Copyright 2004, Takeshi Nakashima * * $Id$ @@ -36,7 +36,7 @@ #include "packet-kerberos.h" #include "packet-isakmp.h" -#define KINK_PORT 57203 +#define KINK_PORT 57203 #define KINK_ISAKMP_PAYLOAD_BASE 14 @@ -55,7 +55,7 @@ static int hf_kink_next_payload = -1; /* Argument for making the subtree */ static gint ett_kink = -1; /*static gint ett_kink_version = -1;*/ -static gint ett_kink_payload = -1; +static gint ett_kink_payload = -1; static gint ett_payload_kink_ap_req = -1; static gint ett_payload_kink_ap_rep = -1; static gint ett_payload_kink_krb_error = -1; @@ -122,7 +122,7 @@ static const value_string kink_next_payload[]={ }; /* Define the magic number - * Using at the kink error + * Using at the kink error */ #define KINK_OK 0 #define KINK_PROTOERR 1 @@ -134,7 +134,7 @@ static const value_string kink_next_payload[]={ #define BOTTOM_RESERVED 7 #define TOP_RESERVED 8191 #define BOTTOM_PRIVATE_USE 8192 -#define TOP_PRIVATE_USE 16383 +#define TOP_PRIVATE_USE 16383 /* Using at the kink header */ #define IPSEC 1 @@ -176,9 +176,9 @@ static void dissect_payload_kink_not_defined(packet_info *pinfo, tvbuff_t *tvb, #ifdef HAVE_KERBEROS static void dissect_decrypt_kink_encrypt(packet_info *pinfo, tvbuff_t *tvb, proto_tree *tree, int payload_length); #endif - + /* This function is dissecting the kink header. */ -static void +static void dissect_kink(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){ proto_item *ti = NULL; proto_tree *kink_tree = NULL; @@ -190,13 +190,13 @@ dissect_kink(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){ guint8 value_a_and_front_reserved; guint16 value_a_and_reserved; guint8 value_a; - guint16 value_reserved; + guint16 value_reserved; int offset=0; - + type = tvb_get_guint8(tvb,offset); col_set_str(pinfo->cinfo, COL_PROTOCOL, "KINK"); - + /* It shows kink type by the type value. */ if(check_col(pinfo->cinfo, COL_INFO)){ col_add_str(pinfo->cinfo, COL_INFO, val_to_str(type, kink_type_vals, "unknown")); @@ -206,11 +206,11 @@ dissect_kink(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){ ti = proto_tree_add_item(tree, proto_kink, tvb, offset, -1, FALSE); kink_tree = proto_item_add_subtree(ti, ett_kink); } - + proto_tree_add_uint(kink_tree, hf_kink_type, tvb, offset, 1, type); offset++; - - /* This part is the version. Consider less than 1 octet value. + + /* This part is the version. Consider less than 1 octet value. * Major version and minor version is 4bit. Front half of 1octet * is major version, and second half of 1octet is minor version. * The calculation of major version is shown below. @@ -224,12 +224,12 @@ dissect_kink(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){ minor_version = version & SECOND_FOUR_BIT; proto_tree_add_text(kink_tree, tvb, offset, 1, "version: %u.%u", major_version, minor_version); offset++; - + proto_tree_add_item(kink_tree, hf_kink_length, tvb, offset, 2, FALSE); offset += 2; - + doi = tvb_get_ntohl(tvb, offset); - + if(doi == IPSEC){ proto_tree_add_text(kink_tree, tvb, offset, 4, "Domain Of Interpretation: %s (%u)", "IPsec", doi); } @@ -237,18 +237,18 @@ dissect_kink(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){ proto_tree_add_text(kink_tree, tvb, offset, 4, "Domain Of Interpretation: %s (%u)", "Not IPsec", doi); } offset += 4; - + proto_tree_add_item(kink_tree, hf_kink_transactionId, tvb, offset, 4, FALSE); offset += 4; - + chsumlen = tvb_get_guint8(tvb, offset); proto_tree_add_item(kink_tree, hf_kink_checkSumLength, tvb, offset, 1, FALSE); offset ++; - + next_payload = tvb_get_guint8(tvb, offset); proto_tree_add_uint(kink_tree, hf_kink_next_payload, tvb, offset, 1, next_payload); offset ++; - + /* A is 1bit field. The caluculation of A is shown below. * The logical product of 1octet value and 0x80 is performed. * And It is performed 7bit right shift. @@ -256,18 +256,18 @@ dissect_kink(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){ value_a_and_front_reserved = tvb_get_guint8(tvb, offset); value_a = (value_a_and_front_reserved & FRONT_ONE_BIT) >> A_BIT_SHIFT; proto_tree_add_uint(kink_tree, hf_kink_A, tvb, offset, 1, value_a); - - /* The reserved field is 15bit. + + /* The reserved field is 15bit. * The logical product of 2octet value and 0x7fff is performed. */ value_a_and_reserved = tvb_get_ntohs(tvb, offset); value_reserved = value_a_and_reserved & SECOND_FIFTEEN_BIT; proto_tree_add_uint(kink_tree, hf_kink_reserved, tvb, offset, 2, value_reserved); offset += 2; - + proto_tree_add_item(kink_tree, hf_kink_checkSum, tvb, offset, chsumlen, FALSE); - - /* This part consider the padding. Chsumlen don't contain the padding. */ + + /* This part consider the padding. Chsumlen don't contain the padding. */ if((chsumlen % PADDING) != 0){ chsumlen += (PADDING - (chsumlen % PADDING)); offset += chsumlen; @@ -275,12 +275,12 @@ dissect_kink(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){ else{ offset += chsumlen; } - + control_payload(pinfo, tvb, offset, next_payload, kink_tree); - + } -/* This part call the dissect payload function by next_payload value. +/* This part call the dissect payload function by next_payload value. * This function called by the respective function again. */ static void @@ -288,7 +288,7 @@ control_payload(packet_info *pinfo, tvbuff_t *tvb, int offset, guint8 next_paylo switch(next_payload){ case KINK_DONE: break; - case KINK_AP_REQ: + case KINK_AP_REQ: dissect_payload_kink_ap_req(pinfo, tvb, offset, kink_tree); break; case KINK_AP_REP: @@ -305,8 +305,8 @@ control_payload(packet_info *pinfo, tvbuff_t *tvb, int offset, guint8 next_paylo break; case KINK_ISAKMP: dissect_payload_kink_isakmp(pinfo, tvb, offset, kink_tree); - break; - case KINK_ENCRYPT: + break; + case KINK_ENCRYPT: dissect_payload_kink_encrypt(pinfo, tvb, offset, kink_tree); break; case KINK_ERROR: @@ -339,7 +339,7 @@ dissect_payload_kink_ap_req(packet_info *pinfo, tvbuff_t *tvb, int offset, proto next_payload = tvb_get_guint8(tvb, offset); proto_tree_add_uint(payload_kink_ap_req_tree, hf_kink_next_payload, tvb, offset, 1, next_payload); offset ++; - + reserved = tvb_get_guint8(tvb, offset); proto_tree_add_text(payload_kink_ap_req_tree, tvb, offset, 1, "RESERVED: %u", reserved); offset ++; @@ -354,10 +354,10 @@ dissect_payload_kink_ap_req(packet_info *pinfo, tvbuff_t *tvb, int offset, proto /* Show time as UTC, not local time. */ timer = tvb_get_ntohl(tvb, offset); - proto_tree_add_text(payload_kink_ap_req_tree, tvb, offset, 4, "EPOCH: %s", - abs_time_secs_to_str(timer, ABSOLUTE_TIME_UTC, TRUE)); + proto_tree_add_text(payload_kink_ap_req_tree, tvb, offset, 4, "EPOCH: %s", + abs_time_secs_to_str(timer, ABSOLUTE_TIME_UTC, TRUE)); offset += 4; - + if(payload_length > PAYLOAD_HEADER){ tvbuff_t *krb_tvb; @@ -416,8 +416,8 @@ dissect_payload_kink_ap_rep(packet_info *pinfo, tvbuff_t *tvb, int offset, proto /* Show time as UTC, not local time. */ timer = tvb_get_ntohl(tvb, offset); - proto_tree_add_text(payload_kink_ap_rep_tree, tvb, offset, 4, "EPOCH: %s", - abs_time_secs_to_str(timer, ABSOLUTE_TIME_UTC, TRUE)); + proto_tree_add_text(payload_kink_ap_rep_tree, tvb, offset, 4, "EPOCH: %s", + abs_time_secs_to_str(timer, ABSOLUTE_TIME_UTC, TRUE)); offset += 4; if(payload_length > PAYLOAD_HEADER){ @@ -462,7 +462,7 @@ dissect_payload_kink_krb_error(packet_info *pinfo, tvbuff_t *tvb, int offset, pr next_payload = tvb_get_guint8(tvb, offset); proto_tree_add_uint(payload_kink_krb_error_tree, hf_kink_next_payload, tvb, offset, 1, next_payload); offset ++; - + reserved = tvb_get_guint8(tvb, offset); proto_tree_add_text(payload_kink_krb_error_tree, tvb, offset, 1, "RESERVED: %u", reserved); offset ++; @@ -527,11 +527,11 @@ dissect_payload_kink_tgt_req(packet_info *pinfo, tvbuff_t *tvb, int offset, prot proto_tree_add_text(payload_kink_tgt_req_tree, tvb, offset, 2, "RealmNameLength: %u", realm_name_length); offset += 2; - - proto_tree_add_text(payload_kink_tgt_req_tree, tvb, offset, realm_name_length, "RealmName: %s", - tvb_format_text(tvb, offset, realm_name_length)); - offset += realm_name_length; - + + proto_tree_add_text(payload_kink_tgt_req_tree, tvb, offset, realm_name_length, "RealmName: %s", + tvb_format_text(tvb, offset, realm_name_length)); + offset += realm_name_length; + /* This part consider the padding. Payload_length don't contain the padding. */ if(payload_length % PADDING != 0){ payload_length += (PADDING - (payload_length % PADDING)); @@ -564,11 +564,11 @@ dissect_payload_kink_tgt_rep(packet_info *pinfo, tvbuff_t *tvb, int offset, prot next_payload = tvb_get_guint8(tvb, offset); proto_tree_add_uint(payload_kink_tgt_rep_tree, hf_kink_next_payload, tvb, offset, 1, next_payload); offset ++; - + reserved = tvb_get_guint8(tvb, offset); proto_tree_add_text(payload_kink_tgt_rep_tree, tvb, offset, 1, "RESERVED: %u", reserved); offset ++; - + proto_tree_add_text(payload_kink_tgt_rep_tree, tvb, offset, 2, "Payload Length: %u", payload_length); offset += 2; @@ -578,7 +578,7 @@ dissect_payload_kink_tgt_rep(packet_info *pinfo, tvbuff_t *tvb, int offset, prot proto_tree_add_text(payload_kink_tgt_rep_tree, tvb, offset, princ_name_length, "PrincName: %s", tvb_format_text(tvb, offset, princ_name_length)); - /* This part consider the padding. Princ_name_length don't contain the padding. */ + /* This part consider the padding. Princ_name_length don't contain the padding. */ if((princ_name_length + FRONT_TGT_REP_HEADER) % PADDING != 0){ offset += (princ_name_length + PADDING - ((princ_name_length + FRONT_TGT_REP_HEADER) % PADDING)); } @@ -618,7 +618,7 @@ dissect_payload_kink_isakmp(packet_info *pinfo, tvbuff_t *tvb, int offset, proto guint16 reserved2; int start_payload_offset = 0; /* Keep the begining of the payload offset */ tvbuff_t *isakmp_tvb; - + payload_length = tvb_get_ntohs(tvb, offset + TO_PAYLOAD_LENGTH); start_payload_offset = offset; @@ -633,7 +633,7 @@ dissect_payload_kink_isakmp(packet_info *pinfo, tvbuff_t *tvb, int offset, proto reserved = tvb_get_guint8(tvb, offset); proto_tree_add_text(payload_kink_isakmp_tree, tvb, offset, 1, "RESERVED: %u", reserved); offset ++; - + if(payload_length <= PAYLOAD_HEADER){ proto_tree_add_text(payload_kink_isakmp_tree, tvb, offset, 2, "This Payload Length is too small.: %u", payload_length); } @@ -661,7 +661,7 @@ dissect_payload_kink_isakmp(packet_info *pinfo, tvbuff_t *tvb, int offset, proto reserved2 = tvb_get_ntohs(tvb, offset); proto_tree_add_text(payload_kink_isakmp_tree, tvb, offset, 2, "RESERVED: %u", reserved2); offset += 2; - + if(payload_length > PAYLOAD_HEADER){ isakmp_length = payload_length - PAYLOAD_HEADER; length = tvb_length_remaining(tvb, offset); @@ -673,7 +673,7 @@ dissect_payload_kink_isakmp(packet_info *pinfo, tvbuff_t *tvb, int offset, proto isakmp_tvb = tvb_new_subset(tvb, offset, length, reported_length); isakmp_dissect_payloads(isakmp_tvb, payload_kink_isakmp_tree, 1, inner_next_pload, 0, isakmp_length, pinfo); } - + /* This part consider the padding. Payload_length don't contain the padding. */ if(payload_length % PADDING != 0){ payload_length += (PADDING - (payload_length % PADDING)); @@ -731,7 +731,7 @@ dissect_payload_kink_encrypt(packet_info *pinfo, tvbuff_t *tvb, int offset, prot guint8 *plaintext=NULL; next_tvb=tvb_new_subset(tvb, offset, MIN(tvb_length_remaining(tvb, offset), encrypt_length), encrypt_length); - plaintext=decrypt_krb5_data(tree, pinfo, 0, next_tvb, keytype, NULL); + plaintext=decrypt_krb5_data(tree, pinfo, 0, next_tvb, keytype, NULL); if(plaintext){ next_tvb=tvb_new_child_real_data(tvb, plaintext, encrypt_length, encrypt_length); tvb_set_free_cb(next_tvb, g_free); @@ -744,11 +744,11 @@ dissect_payload_kink_encrypt(packet_info *pinfo, tvbuff_t *tvb, int offset, prot inner_next_pload = tvb_get_guint8(tvb, offset); proto_tree_add_text(payload_kink_encrypt_tree, tvb, offset, 1, "InnerNextPload: %u", inner_next_pload); offset += 1; - + reserved2 = 65536*tvb_get_guint8(tvb, offset) + 256*tvb_get_guint8(tvb, offset+1) + tvb_get_guint8(tvb, offset+2); proto_tree_add_text(payload_kink_encrypt_tree, tvb, offset, 3, "RESERVED: %u", reserved2); offset += 3; - + if(payload_length > PAYLOAD_HEADER){ inner_payload_length = payload_length - PAYLOAD_HEADER; proto_tree_add_text(payload_kink_encrypt_tree, tvb, offset, inner_payload_length, "Payload"); @@ -769,7 +769,7 @@ dissect_payload_kink_encrypt(packet_info *pinfo, tvbuff_t *tvb, int offset, prot #ifdef HAVE_KERBEROS static void dissect_decrypt_kink_encrypt(packet_info *pinfo, tvbuff_t *tvb, proto_tree *tree, int payload_length){ - + proto_tree *decrypt_kink_encrypt_tree; proto_item *ti; int offset=0; @@ -810,7 +810,7 @@ dissect_payload_kink_error(packet_info *pinfo, tvbuff_t *tvb, int offset, proto_ "KINK_INTERR", "KINK_BADQMVERS" }; - + payload_length = tvb_get_ntohs(tvb,offset + TO_PAYLOAD_LENGTH); start_payload_offset = offset; @@ -835,7 +835,7 @@ dissect_payload_kink_error(packet_info *pinfo, tvbuff_t *tvb, int offset, proto_ offset += 2; error_code = tvb_get_ntohl(tvb, offset); - + /* Choosed the error code by erro_code */ switch(error_code){ case KINK_OK: @@ -873,14 +873,14 @@ dissect_payload_kink_not_defined(packet_info *pinfo, tvbuff_t *tvb, int offset, guint payload_length; guint8 reserved; int start_payload_offset = 0; /* Keep the begining of the payload offset */ - + start_payload_offset = offset; payload_length = tvb_get_ntohs(tvb, offset + TO_PAYLOAD_LENGTH); - + /* Make the subtree */ ti = proto_tree_add_text(tree, tvb, offset, payload_length, "UNKNOWN PAYLOAD"); payload_kink_not_defined_tree = proto_item_add_subtree(ti, ett_payload_not_defined); - + next_payload = tvb_get_guint8(tvb, offset); proto_tree_add_uint(payload_kink_not_defined_tree, hf_kink_next_payload, tvb, offset, 1, next_payload); offset ++; @@ -888,10 +888,10 @@ dissect_payload_kink_not_defined(packet_info *pinfo, tvbuff_t *tvb, int offset, reserved = tvb_get_guint8(tvb, offset); proto_tree_add_text(payload_kink_not_defined_tree, tvb, offset, 1, "RESERVED: %u", reserved); offset ++; - + proto_tree_add_text(payload_kink_not_defined_tree, tvb, offset, 2, "Payload Length: %u", payload_length); offset += 2; - + /* This part consider the padding. Payload_length don't contain the padding. */ if(payload_length % PADDING != 0){ payload_length += (PADDING - (payload_length % PADDING)); @@ -905,42 +905,42 @@ dissect_payload_kink_not_defined(packet_info *pinfo, tvbuff_t *tvb, int offset, } /* Output part */ -void +void proto_register_kink(void) { static hf_register_info hf[] = { { &hf_kink_type, - { "Type", "kink.type", - FT_UINT8, BASE_DEC, VALS(kink_type_vals), 0x0, - "the type of the kink", HFILL }}, + { "Type", "kink.type", + FT_UINT8, BASE_DEC, VALS(kink_type_vals), 0x0, + "the type of the kink", HFILL }}, { &hf_kink_length, - { "Length", "kink.length", - FT_UINT16, BASE_DEC, NULL, 0x0, - "the length of the kink length", HFILL }}, + { "Length", "kink.length", + FT_UINT16, BASE_DEC, NULL, 0x0, + "the length of the kink length", HFILL }}, { &hf_kink_transactionId, - { "Transaction ID", "kink.transactionId", - FT_UINT32, BASE_DEC, NULL, 0x0, - "the transactionID of kink", HFILL }}, + { "Transaction ID", "kink.transactionId", + FT_UINT32, BASE_DEC, NULL, 0x0, + "the transactionID of kink", HFILL }}, { &hf_kink_checkSumLength, - { "Checksum Length", "kink.checkSumLength", - FT_UINT8, BASE_DEC, NULL, 0x0, - "the check sum length of kink", HFILL }}, + { "Checksum Length", "kink.checkSumLength", + FT_UINT8, BASE_DEC, NULL, 0x0, + "the check sum length of kink", HFILL }}, { &hf_kink_A, - { "A", "kink.A", - FT_UINT8, BASE_DEC, VALS(kink_A_vals), 0x0, - "the A of kink", HFILL }}, + { "A", "kink.A", + FT_UINT8, BASE_DEC, VALS(kink_A_vals), 0x0, + "the A of kink", HFILL }}, { &hf_kink_reserved, - { "Reserved", "kink.reserved", - FT_UINT16, BASE_DEC, NULL, 0x0, - "the reserved of kink", HFILL }}, + { "Reserved", "kink.reserved", + FT_UINT16, BASE_DEC, NULL, 0x0, + "the reserved of kink", HFILL }}, { &hf_kink_checkSum, - { "Checksum", "kink.checkSum", - FT_BYTES, BASE_NONE, NULL, 0x0, - "the checkSum of kink", HFILL }}, + { "Checksum", "kink.checkSum", + FT_BYTES, BASE_NONE, NULL, 0x0, + "the checkSum of kink", HFILL }}, { &hf_kink_next_payload, - { "Next Payload", "kink.nextPayload", - FT_UINT8, BASE_DEC, VALS(kink_next_payload), 0x0, - "the next payload of kink", HFILL }} + { "Next Payload", "kink.nextPayload", + FT_UINT8, BASE_DEC, VALS(kink_next_payload), 0x0, + "the next payload of kink", HFILL }} }; @@ -959,9 +959,9 @@ proto_register_kink(void) { &ett_payload_kink_error, &ett_payload_not_defined, &ett_decrypt_kink_encrypt, - + }; - + proto_kink = proto_register_protocol("Kerberized Internet Negotiation of Key", "KINK", "kink"); proto_register_field_array(proto_kink, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); @@ -969,9 +969,9 @@ proto_register_kink(void) { } void proto_reg_handoff_kink(void) { - + dissector_handle_t kink_handle = NULL; - + kink_handle = create_dissector_handle(dissect_kink, proto_kink); dissector_add_uint("udp.port", KINK_PORT, kink_handle); -- cgit v1.2.3