From 03e97ee7d3b31d1ef9b461445630032274748711 Mon Sep 17 00:00:00 2001 From: Alexis La Goutte Date: Fri, 1 Feb 2013 09:22:31 +0000 Subject: [PATCH] * Fix indent (Tab => 2 Spaces) and add Modelines info svn path=/trunk/; revision=47414 --- epan/dissectors/packet-xdmcp.c | 314 +++++++++++++++++---------------- 1 file changed, 163 insertions(+), 151 deletions(-) diff --git a/epan/dissectors/packet-xdmcp.c b/epan/dissectors/packet-xdmcp.c index 40f8c76047..37cef7c44e 100644 --- a/epan/dissectors/packet-xdmcp.c +++ b/epan/dissectors/packet-xdmcp.c @@ -116,7 +116,7 @@ static gint ett_xdmcp_connections = -1; static gint ett_xdmcp_connection = -1; static gint xdmcp_add_string(proto_tree *tree, gint hf, - tvbuff_t *tvb, gint offset) + tvbuff_t *tvb, gint offset) { char *str; guint len; @@ -129,7 +129,7 @@ static gint xdmcp_add_string(proto_tree *tree, gint hf, } static gint xdmcp_add_bytes(proto_tree *tree, gint hf_byte, gint hf_length, - tvbuff_t *tvb, gint offset) + tvbuff_t *tvb, gint offset) { guint len; len = tvb_get_ntohs(tvb, offset); @@ -140,7 +140,7 @@ static gint xdmcp_add_bytes(proto_tree *tree, gint hf_byte, gint hf_length, } static gint xdmcp_add_authentication_names(proto_tree *tree, - tvbuff_t *tvb, gint offset) + tvbuff_t *tvb, gint offset) { proto_tree *anames_tree; proto_item *anames_ti; @@ -149,17 +149,17 @@ static gint xdmcp_add_authentication_names(proto_tree *tree, anames_start_offset = offset; anames_len = tvb_get_guint8(tvb, offset); anames_ti = proto_tree_add_text(tree, tvb, - anames_start_offset, -1, - "Authentication names (%d)", - anames_len); + anames_start_offset, -1, + "Authentication names (%d)", + anames_len); anames_tree = proto_item_add_subtree(anames_ti, - ett_xdmcp_authentication_names); + ett_xdmcp_authentication_names); anames_len = tvb_get_guint8(tvb, offset); offset++; while (anames_len > 0) { offset += xdmcp_add_string(anames_tree, hf_xdmcp_authentication_name, - tvb, offset); + tvb, offset); anames_len--; } proto_item_set_len(anames_ti, offset - anames_start_offset); @@ -167,7 +167,7 @@ static gint xdmcp_add_authentication_names(proto_tree *tree, } static gint xdmcp_add_authorization_names(proto_tree *tree, - tvbuff_t *tvb, gint offset) + tvbuff_t *tvb, gint offset) { proto_tree *anames_tree; proto_item *anames_ti; @@ -176,17 +176,17 @@ static gint xdmcp_add_authorization_names(proto_tree *tree, anames_start_offset = offset; anames_len = tvb_get_guint8(tvb, offset); anames_ti = proto_tree_add_text(tree, tvb, - anames_start_offset, -1, - "Authorization names (%d)", - anames_len); + anames_start_offset, -1, + "Authorization names (%d)", + anames_len); anames_tree = proto_item_add_subtree(anames_ti, - ett_xdmcp_authorization_names); + ett_xdmcp_authorization_names); anames_len = tvb_get_guint8(tvb, offset); offset++; while (anames_len > 0) { offset += xdmcp_add_string(anames_tree, hf_xdmcp_authorization_name, - tvb, offset); + tvb, offset); anames_len--; } proto_item_set_len(anames_ti, offset - anames_start_offset); @@ -219,14 +219,14 @@ static void dissect_xdmcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) xdmcp_tree = proto_item_add_subtree(ti, ett_xdmcp); proto_tree_add_uint(xdmcp_tree, hf_xdmcp_version, tvb, - offset, 2, version); + offset, 2, version); offset += 2; opcode = tvb_get_ntohs(tvb, offset); if (tree) { proto_tree_add_uint(xdmcp_tree, hf_xdmcp_opcode, tvb, - offset, 2, opcode); + offset, 2, opcode); } offset += 2; if (check_col(pinfo->cinfo, COL_INFO)) { @@ -237,109 +237,109 @@ static void dissect_xdmcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (tree) { proto_tree_add_item(xdmcp_tree, hf_xdmcp_length, tvb, - offset, 2, ENC_BIG_ENDIAN); + offset, 2, ENC_BIG_ENDIAN); offset += 2; switch (opcode) { case XDMCP_FORWARD_QUERY: { - gint alen, plen; - alen = tvb_get_ntohs(tvb, offset); - /* I have never seen anything except IPv4 addresses here, - * but in theory the protocol should support other address - * families. */ - if (alen == 4) { + gint alen, plen; + alen = tvb_get_ntohs(tvb, offset); + /* I have never seen anything except IPv4 addresses here, + * but in theory the protocol should support other address + * families. */ + if (alen == 4) { proto_tree_add_item(xdmcp_tree, hf_xdmcp_client_address_ipv4, tvb, offset+2, alen, ENC_BIG_ENDIAN); - offset += 6; - } else if (alen == 16) { + offset += 6; + } else if (alen == 16) { proto_tree_add_item(xdmcp_tree, hf_xdmcp_client_address_ipv6, tvb, offset+2, alen, ENC_BIG_ENDIAN); - offset += 18; - } else { - offset += xdmcp_add_bytes(xdmcp_tree, hf_xdmcp_client_address_bytes, hf_xdmcp_client_address_bytes_len, + offset += 18; + } else { + offset += xdmcp_add_bytes(xdmcp_tree, hf_xdmcp_client_address_bytes, hf_xdmcp_client_address_bytes_len, tvb, offset); - } + } - plen = tvb_get_ntohs(tvb, offset); - if (plen == 2) { + plen = tvb_get_ntohs(tvb, offset); + if (plen == 2) { proto_tree_add_item(xdmcp_tree, hf_xdmcp_client_port_u16, tvb, offset+2, plen, ENC_BIG_ENDIAN); - offset += 4; - } else { - offset += xdmcp_add_bytes(xdmcp_tree, hf_xdmcp_client_port_bytes, hf_xdmcp_client_port_len, + offset += 4; + } else { + offset += xdmcp_add_bytes(xdmcp_tree, hf_xdmcp_client_port_bytes, hf_xdmcp_client_port_len, tvb, offset); - } + } } /* fall-through */ case XDMCP_BROADCAST_QUERY: case XDMCP_QUERY: case XDMCP_INDIRECT_QUERY: - offset += xdmcp_add_authentication_names(xdmcp_tree, tvb, offset); - break; + offset += xdmcp_add_authentication_names(xdmcp_tree, tvb, offset); + break; case XDMCP_WILLING: - offset += xdmcp_add_string(xdmcp_tree, hf_xdmcp_authentication_name, - tvb, offset); - offset += xdmcp_add_string(xdmcp_tree, hf_xdmcp_hostname, - tvb, offset); - offset += xdmcp_add_string(xdmcp_tree, hf_xdmcp_status, - tvb, offset); - break; + offset += xdmcp_add_string(xdmcp_tree, hf_xdmcp_authentication_name, + tvb, offset); + offset += xdmcp_add_string(xdmcp_tree, hf_xdmcp_hostname, + tvb, offset); + offset += xdmcp_add_string(xdmcp_tree, hf_xdmcp_status, + tvb, offset); + break; case XDMCP_UNWILLING: - offset += xdmcp_add_string(xdmcp_tree, hf_xdmcp_hostname, - tvb, offset); - offset += xdmcp_add_string(xdmcp_tree, hf_xdmcp_status, - tvb, offset); - break; + offset += xdmcp_add_string(xdmcp_tree, hf_xdmcp_hostname, + tvb, offset); + offset += xdmcp_add_string(xdmcp_tree, hf_xdmcp_status, + tvb, offset); + break; case XDMCP_REQUEST: { - proto_tree *clist_tree; - proto_item *clist_ti; - gint ctypes_len, caddrs_len, n; - gint ctypes_start_offset, caddrs_offset; + proto_tree *clist_tree; + proto_item *clist_ti; + gint ctypes_len, caddrs_len, n; + gint ctypes_start_offset, caddrs_offset; - ti = proto_tree_add_item(xdmcp_tree, hf_xdmcp_display_number, tvb, - offset, 2, ENC_BIG_ENDIAN); - offset += 2; + ti = proto_tree_add_item(xdmcp_tree, hf_xdmcp_display_number, tvb, + offset, 2, ENC_BIG_ENDIAN); + offset += 2; - ctypes_len = tvb_get_guint8(tvb, offset); - ctypes_start_offset = offset; - caddrs_offset = offset + 1 + 2*ctypes_len; - caddrs_len = tvb_get_guint8(tvb, caddrs_offset); - if (ctypes_len != caddrs_len) { + ctypes_len = tvb_get_guint8(tvb, offset); + ctypes_start_offset = offset; + caddrs_offset = offset + 1 + 2*ctypes_len; + caddrs_len = tvb_get_guint8(tvb, caddrs_offset); + if (ctypes_len != caddrs_len) { expert_add_info_format(pinfo, ti, PI_PROTOCOL, PI_WARN, "Error: Connection type/address arrays don't match"); - return; - } + return; + } - clist_ti = proto_tree_add_text(xdmcp_tree, - tvb, ctypes_start_offset, -1, - "Connections (%d)", - ctypes_len); - clist_tree = proto_item_add_subtree(clist_ti, ett_xdmcp_connections); + clist_ti = proto_tree_add_text(xdmcp_tree, + tvb, ctypes_start_offset, -1, + "Connections (%d)", + ctypes_len); + clist_tree = proto_item_add_subtree(clist_ti, ett_xdmcp_connections); - offset++; - caddrs_offset++; + offset++; + caddrs_offset++; - n = 1; - while (ctypes_len > 0) { - proto_item *connection_ti; - proto_tree *connection_tree; + n = 1; + while (ctypes_len > 0) { + proto_item *connection_ti; + proto_tree *connection_tree; - gint alen; - gint ctype = tvb_get_ntohs(tvb, offset); - offset += 2; - alen = tvb_get_ntohs(tvb, caddrs_offset); - caddrs_offset += 2; + gint alen; + gint ctype = tvb_get_ntohs(tvb, offset); + offset += 2; + alen = tvb_get_ntohs(tvb, caddrs_offset); + caddrs_offset += 2; - connection_ti = proto_tree_add_text(clist_tree, NULL, 0, 0, - "Connection %d", n); - connection_tree = proto_item_add_subtree(connection_ti, - ett_xdmcp_connection); + connection_ti = proto_tree_add_text(clist_tree, NULL, 0, 0, + "Connection %d", n); + connection_tree = proto_item_add_subtree(connection_ti, + ett_xdmcp_connection); proto_tree_add_item(connection_tree, hf_xdmcp_connection_type, tvb, offset-2, 2, ENC_BIG_ENDIAN); - if ((ctype == 0) && (alen == 4)) { + if ((ctype == 0) && (alen == 4)) { proto_tree_add_item(connection_tree, hf_xdmcp_connection_address_ipv4, tvb, caddrs_offset, alen, ENC_BIG_ENDIAN); proto_item_append_text(connection_ti, ": %s", tvb_ip_to_str(tvb, caddrs_offset)); } else if ((ctype == 6) && (alen == 16)) { @@ -350,97 +350,97 @@ static void dissect_xdmcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } caddrs_offset += alen; - ctypes_len--; - n++; - } - offset = caddrs_offset; - proto_item_set_len(clist_ti, offset - ctypes_start_offset); + ctypes_len--; + n++; + } + offset = caddrs_offset; + proto_item_set_len(clist_ti, offset - ctypes_start_offset); - offset += xdmcp_add_string(xdmcp_tree, hf_xdmcp_authentication_name, - tvb, offset); - offset += xdmcp_add_bytes(xdmcp_tree, hf_xdmcp_authentication_data, hf_xdmcp_authentication_data_len, - tvb, offset); + offset += xdmcp_add_string(xdmcp_tree, hf_xdmcp_authentication_name, + tvb, offset); + offset += xdmcp_add_bytes(xdmcp_tree, hf_xdmcp_authentication_data, hf_xdmcp_authentication_data_len, + tvb, offset); - offset += xdmcp_add_authorization_names(xdmcp_tree, tvb, offset); + offset += xdmcp_add_authorization_names(xdmcp_tree, tvb, offset); - offset += xdmcp_add_bytes(xdmcp_tree, hf_xdmcp_manufacturer_display_id, hf_xdmcp_manufacturer_display_id_len, - tvb, offset); - break; + offset += xdmcp_add_bytes(xdmcp_tree, hf_xdmcp_manufacturer_display_id, hf_xdmcp_manufacturer_display_id_len, + tvb, offset); + break; } case XDMCP_ACCEPT: - proto_tree_add_item(xdmcp_tree, hf_xdmcp_session_id, tvb, - offset, 4, ENC_BIG_ENDIAN); - offset += 4; - offset += xdmcp_add_string(xdmcp_tree, hf_xdmcp_authentication_name, - tvb, offset); - offset += xdmcp_add_bytes(xdmcp_tree, hf_xdmcp_authentication_data, hf_xdmcp_authentication_data_len, - tvb, offset); - offset += xdmcp_add_string(xdmcp_tree, hf_xdmcp_authorization_name, - tvb, offset); - offset += xdmcp_add_bytes(xdmcp_tree, hf_xdmcp_authorization_data, hf_xdmcp_authorization_data_len, - tvb, offset); - break; + proto_tree_add_item(xdmcp_tree, hf_xdmcp_session_id, tvb, + offset, 4, ENC_BIG_ENDIAN); + offset += 4; + offset += xdmcp_add_string(xdmcp_tree, hf_xdmcp_authentication_name, + tvb, offset); + offset += xdmcp_add_bytes(xdmcp_tree, hf_xdmcp_authentication_data, hf_xdmcp_authentication_data_len, + tvb, offset); + offset += xdmcp_add_string(xdmcp_tree, hf_xdmcp_authorization_name, + tvb, offset); + offset += xdmcp_add_bytes(xdmcp_tree, hf_xdmcp_authorization_data, hf_xdmcp_authorization_data_len, + tvb, offset); + break; case XDMCP_DECLINE: - offset += xdmcp_add_string(xdmcp_tree, hf_xdmcp_status, - tvb, offset); - offset += xdmcp_add_string(xdmcp_tree, hf_xdmcp_authentication_name, - tvb, offset); - offset += xdmcp_add_bytes(xdmcp_tree, hf_xdmcp_authentication_data, hf_xdmcp_authentication_data_len, - tvb, offset); - break; + offset += xdmcp_add_string(xdmcp_tree, hf_xdmcp_status, + tvb, offset); + offset += xdmcp_add_string(xdmcp_tree, hf_xdmcp_authentication_name, + tvb, offset); + offset += xdmcp_add_bytes(xdmcp_tree, hf_xdmcp_authentication_data, hf_xdmcp_authentication_data_len, + tvb, offset); + break; case XDMCP_MANAGE: - proto_tree_add_item(xdmcp_tree, hf_xdmcp_session_id, tvb, - offset, 4, ENC_BIG_ENDIAN); - offset += 4; + proto_tree_add_item(xdmcp_tree, hf_xdmcp_session_id, tvb, + offset, 4, ENC_BIG_ENDIAN); + offset += 4; - proto_tree_add_item(xdmcp_tree, hf_xdmcp_display_number, tvb, - offset, 2, ENC_BIG_ENDIAN); - offset += 2; + proto_tree_add_item(xdmcp_tree, hf_xdmcp_display_number, tvb, + offset, 2, ENC_BIG_ENDIAN); + offset += 2; - offset += xdmcp_add_bytes(xdmcp_tree, hf_xdmcp_display_class, hf_xdmcp_display_class_len, - tvb, offset); - break; + offset += xdmcp_add_bytes(xdmcp_tree, hf_xdmcp_display_class, hf_xdmcp_display_class_len, + tvb, offset); + break; case XDMCP_REFUSE: - proto_tree_add_item(xdmcp_tree, hf_xdmcp_session_id, tvb, - offset, 4, ENC_BIG_ENDIAN); - offset += 4; - break; + proto_tree_add_item(xdmcp_tree, hf_xdmcp_session_id, tvb, + offset, 4, ENC_BIG_ENDIAN); + offset += 4; + break; case XDMCP_FAILED: - proto_tree_add_item(xdmcp_tree, hf_xdmcp_session_id, tvb, - offset, 4, ENC_BIG_ENDIAN); - offset += 4; + proto_tree_add_item(xdmcp_tree, hf_xdmcp_session_id, tvb, + offset, 4, ENC_BIG_ENDIAN); + offset += 4; - offset += xdmcp_add_string(xdmcp_tree, hf_xdmcp_status, - tvb, offset); - break; + offset += xdmcp_add_string(xdmcp_tree, hf_xdmcp_status, + tvb, offset); + break; case XDMCP_KEEPALIVE: - proto_tree_add_item(xdmcp_tree, hf_xdmcp_display_number, tvb, - offset, 2, ENC_BIG_ENDIAN); - offset += 2; + proto_tree_add_item(xdmcp_tree, hf_xdmcp_display_number, tvb, + offset, 2, ENC_BIG_ENDIAN); + offset += 2; - proto_tree_add_item(xdmcp_tree, hf_xdmcp_session_id, tvb, - offset, 4, ENC_BIG_ENDIAN); - offset += 4; - break; + proto_tree_add_item(xdmcp_tree, hf_xdmcp_session_id, tvb, + offset, 4, ENC_BIG_ENDIAN); + offset += 4; + break; case XDMCP_ALIVE: { - guint8 session_running = tvb_get_guint8(tvb, offset); - proto_tree_add_uint_format(xdmcp_tree, hf_xdmcp_session_running, tvb, - offset, 1, session_running, "Session running: %s", session_running ? "Yes" : "No"); - offset++; + guint8 session_running = tvb_get_guint8(tvb, offset); + proto_tree_add_uint_format(xdmcp_tree, hf_xdmcp_session_running, tvb, + offset, 1, session_running, "Session running: %s", session_running ? "Yes" : "No"); + offset++; - proto_tree_add_item(xdmcp_tree, hf_xdmcp_session_id, tvb, - offset, 4, ENC_BIG_ENDIAN); - offset += 4; + proto_tree_add_item(xdmcp_tree, hf_xdmcp_session_id, tvb, + offset, 4, ENC_BIG_ENDIAN); + offset += 4; } - break; + break; } } } @@ -611,7 +611,7 @@ void proto_register_xdmcp(void) /* Register the protocol name and description */ proto_xdmcp = proto_register_protocol("X Display Manager Control Protocol", - "XDMCP", "xdmcp"); + "XDMCP", "xdmcp"); /* Required function calls to register the header fields and subtrees used */ proto_register_field_array(proto_xdmcp, hf, array_length(hf)); @@ -626,3 +626,15 @@ proto_reg_handoff_xdmcp(void) xdmcp_handle = create_dissector_handle(dissect_xdmcp, proto_xdmcp); dissector_add_uint("udp.port", UDP_PORT_XDMCP, xdmcp_handle); } +/* + * Editor modelines + * + * Local Variables: + * c-basic-offset: 2 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * ex: set shiftwidth=2 tabstop=8 expandtab: + * :indentSize=2:tabSize=8:noTabs=true: + */