diff options
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dissectors/packet-dnp.c | 62 | ||||
-rw-r--r-- | epan/dissectors/packet-gtpv2.c | 18 | ||||
-rw-r--r-- | epan/dissectors/packet-h223.c | 38 | ||||
-rw-r--r-- | epan/dissectors/packet-hdfs.c | 1198 | ||||
-rw-r--r-- | epan/dissectors/packet-iax2.c | 4 | ||||
-rw-r--r-- | epan/dissectors/packet-ppi-vector.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-tcp.c | 16 | ||||
-rw-r--r-- | epan/dissectors/packet-wifi-p2p.c | 6 | ||||
-rw-r--r-- | epan/nstime.c | 32 | ||||
-rw-r--r-- | epan/uat.c | 836 |
10 files changed, 1106 insertions, 1106 deletions
diff --git a/epan/dissectors/packet-dnp.c b/epan/dissectors/packet-dnp.c index 6b48192f5b..b961cbc690 100644 --- a/epan/dissectors/packet-dnp.c +++ b/epan/dissectors/packet-dnp.c @@ -469,10 +469,10 @@ /***************************************************************************/ /* File Objects */ -#define AL_OBJ_FILE_CMD 0x4603 /* 70 03 File Control - Command */ -#define AL_OBJ_FILE_STAT 0x4604 /* 70 04 File Control - Status */ -#define AL_OBJ_FILE_TRANS 0x4605 /* 70 05 File Control - Transport */ -#define AL_OBJ_FILE_TRAN_ST 0x4606 /* 70 05 File Control - Transport Status */ +#define AL_OBJ_FILE_CMD 0x4603 /* 70 03 File Control - Command */ +#define AL_OBJ_FILE_STAT 0x4604 /* 70 04 File Control - Status */ +#define AL_OBJ_FILE_TRANS 0x4605 /* 70 05 File Control - Transport */ +#define AL_OBJ_FILE_TRAN_ST 0x4606 /* 70 05 File Control - Transport Status */ /* File Control Mode flags */ #define AL_OBJ_FILE_MODE_NULL 0x00 /* NULL */ @@ -1032,9 +1032,9 @@ static GHashTable *dl_conversation_table = NULL; /* Data-Link-Layer Conversation Key Structure */ typedef struct _dl_conversation_key { - guint32 conversation; /* TCP / UDP conversation index */ - guint16 src; /* DNP3.0 Source Address */ - guint16 dst; /* DNP3.0 Destination Address */ + guint32 conversation; /* TCP / UDP conversation index */ + guint16 src; /* DNP3.0 Source Address */ + guint16 dst; /* DNP3.0 Destination Address */ } dl_conversation_key_t; /* Data-Link-Layer conversation key equality function */ @@ -1058,12 +1058,12 @@ dl_conversation_equal(gconstpointer v, gconstpointer w) static guint dl_conversation_hash(gconstpointer v) { - const dl_conversation_key_t *key = (const dl_conversation_key_t*)v; - guint val; + const dl_conversation_key_t *key = (const dl_conversation_key_t*)v; + guint val; - val = key->conversation + (key->src << 16) + key->dst; + val = key->conversation + (key->src << 16) + key->dst; - return val; + return val; } /* ************************************************************************* */ @@ -2165,7 +2165,7 @@ dnp3_al_process_object(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree switch (al_obj) { case AL_OBJ_AO_32: /* 32-Bit Analog Output Status (Obj:40, Var:01) */ - case AL_OBJ_AOC_32NT: /* 32-Bit Analog Output Event w/o Time (Obj:42, Var:01) */ + case AL_OBJ_AOC_32NT: /* 32-Bit Analog Output Event w/o Time (Obj:42, Var:01) */ case AL_OBJ_AOC_32T: /* 32-Bit Analog Output Event with Time (Obj:42, Var:03) */ al_val32 = tvb_get_letohl(tvb, data_pos); @@ -2175,8 +2175,8 @@ dnp3_al_process_object(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree break; case AL_OBJ_AO_16: /* 16-Bit Analog Output Status (Obj:40, Var:02) */ - case AL_OBJ_AOC_16NT: /* 16-Bit Analog Output Event w/o Time (Obj:42, Var:02) */ - case AL_OBJ_AOC_16T: /* 16-Bit Analog Output Event with Time (Obj:42, Var:04) */ + case AL_OBJ_AOC_16NT: /* 16-Bit Analog Output Event w/o Time (Obj:42, Var:02) */ + case AL_OBJ_AOC_16T: /* 16-Bit Analog Output Event with Time (Obj:42, Var:04) */ al_val16 = tvb_get_letohs(tvb, data_pos); proto_item_append_text(point_item, ", Value: %u", al_val16); @@ -2185,8 +2185,8 @@ dnp3_al_process_object(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree break; case AL_OBJ_AO_FLT: /* 32-Bit Floating Point Output Status (Obj:40, Var:03) */ - case AL_OBJ_AOC_FLTNT: /* 32-Bit Floating Point Output Event w/o Time (Obj:42, Var:05) */ - case AL_OBJ_AOC_FLTT: /* 32-Bit Floating Point Output Event w/ Time (Obj:42, Var:07) */ + case AL_OBJ_AOC_FLTNT: /* 32-Bit Floating Point Output Event w/o Time (Obj:42, Var:05) */ + case AL_OBJ_AOC_FLTT: /* 32-Bit Floating Point Output Event w/ Time (Obj:42, Var:07) */ al_valflt = tvb_get_letohieee_float(tvb, data_pos); proto_item_append_text(point_item, ", Value: %g", al_valflt); @@ -2195,8 +2195,8 @@ dnp3_al_process_object(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree break; case AL_OBJ_AO_DBL: /* 64-Bit Floating Point Output Status (Obj:40, Var:04) */ - case AL_OBJ_AOC_DBLNT: /* 64-Bit Floating Point Output Event w/o Time (Obj:42, Var:06) */ - case AL_OBJ_AOC_DBLT: /* 64-Bit Floating Point Output Event w/ Time (Obj:42, Var:08) */ + case AL_OBJ_AOC_DBLNT: /* 64-Bit Floating Point Output Event w/o Time (Obj:42, Var:06) */ + case AL_OBJ_AOC_DBLT: /* 64-Bit Floating Point Output Event w/ Time (Obj:42, Var:08) */ al_valdbl = tvb_get_letohieee_double(tvb, data_pos); proto_item_append_text(point_item, ", Value: %g", al_valdbl); @@ -2391,7 +2391,7 @@ dnp3_al_process_object(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree offset = data_pos; break; - case AL_OBJ_FILE_TRAN_ST: /* File Control Tansport Status (Obj:70, Var:06) */ + case AL_OBJ_FILE_TRAN_ST: /* File Control Tansport Status (Obj:70, Var:06) */ /* File Handle */ proto_tree_add_item(point_tree, hf_dnp3_al_file_handle, tvb, data_pos, 4, ENC_LITTLE_ENDIAN); @@ -2416,7 +2416,7 @@ dnp3_al_process_object(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree proto_item_set_len(point_item, data_pos - offset); offset = data_pos; - break; + break; case AL_OBJ_IIN: /* IIN Data Object */ @@ -2656,9 +2656,9 @@ dissect_dnp3_al(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) break; - case AL_FUNC_OPENFILE: /* Open File Function Code 0x19 */ - case AL_FUNC_CLOSEFILE: /* Close File Function Code 0x1A */ - case AL_FUNC_DELETEFILE: /* Delete File Function Code 0x1B */ + case AL_FUNC_OPENFILE: /* Open File Function Code 0x19 */ + case AL_FUNC_CLOSEFILE: /* Close File Function Code 0x1A */ + case AL_FUNC_DELETEFILE: /* Delete File Function Code 0x1B */ /* Create File Data Objects Tree */ t_robj = proto_tree_add_text(al_tree, tvb, offset, -1, "File Data Objects"); @@ -2941,11 +2941,11 @@ dissect_dnp3_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* Look up the conversation to get the fragment reassembly id */ conversation = find_or_create_conversation(pinfo); - /* - * The TCP/UDP conversation is not sufficient to identify a conversation - * on a multi-drop DNP network. Lookup conversation data based on TCP/UDP - * conversation and the DNP src and dst addresses - */ + /* + * The TCP/UDP conversation is not sufficient to identify a conversation + * on a multi-drop DNP network. Lookup conversation data based on TCP/UDP + * conversation and the DNP src and dst addresses + */ dl_conversation_key.conversation = conversation->index; dl_conversation_key.src = dl_src; @@ -2958,14 +2958,14 @@ dissect_dnp3_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) dl_conversation_key_t* new_dl_conversation_key = NULL; new_dl_conversation_key = se_alloc(sizeof(dl_conversation_key_t)); *new_dl_conversation_key = dl_conversation_key; - + conv_data_ptr = se_alloc(sizeof(dnp3_conv_t)); - + /*** Increment static global fragment reassembly id ***/ conv_data_ptr->conv_seq_number = seq_number++; g_hash_table_insert(dl_conversation_table, new_dl_conversation_key, conv_data_ptr); - } + } conv_seq_number = conv_data_ptr->conv_seq_number; diff --git a/epan/dissectors/packet-gtpv2.c b/epan/dissectors/packet-gtpv2.c index 91d045c116..e2b71bd392 100644 --- a/epan/dissectors/packet-gtpv2.c +++ b/epan/dissectors/packet-gtpv2.c @@ -1853,22 +1853,22 @@ dissect_diameter_3gpp_uli(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) length = tvb_length(tvb); flags_3gpp = tvb_get_guint8(tvb,offset); - proto_tree_add_item(tree, hf_gtpv2_glt, tvb, offset, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(tree, hf_gtpv2_glt, tvb, offset, 1, ENC_BIG_ENDIAN); switch(flags_3gpp) { - case 0: + case 0: /* CGI */ flags = GTPv2_ULI_CGI_MASK; - break; - case 1: + break; + case 1: /* SAI */ flags = GTPv2_ULI_SAI_MASK; - break; - case 2: + break; + case 2: /* RAI */ flags = GTPv2_ULI_RAI_MASK; - break; + break; case 128: /* TAI */ flags = GTPv2_ULI_TAI_MASK; @@ -1882,7 +1882,7 @@ dissect_diameter_3gpp_uli(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) flags = GTPv2_ULI_TAI_MASK + GTPv2_ULI_ECGI_MASK; break; default: - proto_tree_add_text(tree, tvb, 1, -1, "Geographic Location"); + proto_tree_add_text(tree, tvb, 1, -1, "Geographic Location"); return length; } @@ -4626,7 +4626,7 @@ void proto_register_gtpv2(void) FT_BOOLEAN, 8, NULL, GTPv2_ULI_CGI_MASK, NULL, HFILL} }, - { &hf_gtpv2_glt, + { &hf_gtpv2_glt, {"Geographic Location Type", "gtpv2.glt", FT_UINT8, BASE_DEC, VALS(geographic_location_type_vals), 0x0, NULL, HFILL} diff --git a/epan/dissectors/packet-h223.c b/epan/dissectors/packet-h223.c index 7fa16f888b..6ded1dc05e 100644 --- a/epan/dissectors/packet-h223.c +++ b/epan/dissectors/packet-h223.c @@ -635,7 +635,7 @@ static guint8 h223_al2_crc8bit( tvbuff_t *tvb ) { static void dissect_mux_al_pdu( tvbuff_t *tvb, packet_info *pinfo, proto_tree *vc_tree, /* circuit_t* vc_circuit, */ - h223_lc_params* lc_params ) + h223_lc_params* lc_params ) { proto_tree *al_tree = NULL; proto_item *al_item, *hidden_item; @@ -739,9 +739,9 @@ dissect_mux_al_pdu( tvbuff_t *tvb, packet_info *pinfo, proto_tree *vc_tree, */ static void dissect_mux_sdu_fragment(tvbuff_t *volatile next_tvb, packet_info *pinfo, - guint32 pkt_offset, proto_tree *pdu_tree, - h223_call_info* call_info, guint16 vc, - gboolean end_of_mux_sdu) + guint32 pkt_offset, proto_tree *pdu_tree, + h223_call_info* call_info, guint16 vc, + gboolean end_of_mux_sdu) { /* update the circuit details before passing to a subdissector */ guint32 orig_circuit = pinfo->circuit_id; @@ -856,10 +856,10 @@ mux_element_sublist_size( h223_mux_element* me ) */ static guint32 dissect_mux_payload_by_me_list( tvbuff_t *tvb, packet_info *pinfo, - guint32 pkt_offset, proto_tree *pdu_tree, - h223_call_info* call_info, - h223_mux_element *me, guint32 offset, - gboolean endOfMuxSdu ) + guint32 pkt_offset, proto_tree *pdu_tree, + h223_call_info* call_info, + h223_mux_element *me, guint32 offset, + gboolean endOfMuxSdu ) { guint32 len = tvb_reported_length(tvb); guint32 frag_len; @@ -909,8 +909,8 @@ dissect_mux_payload_by_me_list( tvbuff_t *tvb, packet_info *pinfo, */ static void dissect_mux_payload( tvbuff_t *tvb, packet_info *pinfo, guint32 pkt_offset, - proto_tree *pdu_tree, h223_call_info *call_info, - guint8 mc, gboolean endOfMuxSdu ) + proto_tree *pdu_tree, h223_call_info *call_info, + guint8 mc, gboolean endOfMuxSdu ) { guint32 len = tvb_reported_length(tvb); @@ -944,7 +944,7 @@ dissect_mux_payload( tvbuff_t *tvb, packet_info *pinfo, guint32 pkt_offset, */ static void dissect_mux_pdu( tvbuff_t *tvb, packet_info *pinfo, guint32 pkt_offset, - proto_tree *h223_tree, h223_call_info *call_info) + proto_tree *h223_tree, h223_call_info *call_info) { guint32 offset = 0; /* actual (as opposed to reported) payload len */ @@ -1188,8 +1188,8 @@ h223_mux_check_hdlc(int h223_level, guint32 nbytes, guint32 tail_buf) static gint dissect_mux_pdu_fragment( tvbuff_t *tvb, guint32 start_offset, - packet_info *pinfo, proto_tree *h223_tree, - h223_call_info *call_info) + packet_info *pinfo, proto_tree *h223_tree, + h223_call_info *call_info) { tvbuff_t *volatile next_tvb; volatile guint32 offset = start_offset; @@ -1265,16 +1265,16 @@ dissect_mux_pdu_fragment( tvbuff_t *tvb, guint32 start_offset, } CATCH2(BoundsError,ReportedBoundsError) { - /* Restore the private_data structure in case one of the - * called dissectors modified it (and, due to the exception, - * was unable to restore it). - */ - pinfo->private_data = pd_save; + /* Restore the private_data structure in case one of the + * called dissectors modified it (and, due to the exception, + * was unable to restore it). + */ + pinfo->private_data = pd_save; col_append_str(pinfo->cinfo, COL_INFO, "[Malformed Packet]"); proto_tree_add_protocol_format(h223_tree, proto_malformed, tvb, 0, 0, "[Malformed Packet: %s]", - pinfo->current_proto); + pinfo->current_proto); } ENDTRY; diff --git a/epan/dissectors/packet-hdfs.c b/epan/dissectors/packet-hdfs.c index d062e4b19c..a050a5c739 100644 --- a/epan/dissectors/packet-hdfs.c +++ b/epan/dissectors/packet-hdfs.c @@ -80,7 +80,7 @@ static int hf_hdfs_rest = -1; static int hf_hdfs_fileperm = -1; static int hf_hdfs_blockloc = -1; static int hf_hdfs_endblockloc = -1; -static int hf_hdfs_blockgen = -1; +static int hf_hdfs_blockgen = -1; static int hf_hdfs_prover = -1; static int hf_hdfs_objname = -1; static int hf_hdfs_filename = -1; @@ -131,101 +131,101 @@ void proto_reg_handoff_hdfs(void); static void dissect_params (tvbuff_t *tvb, proto_tree *hdfs_tree, guint offset, int params) { - guint length; - int i = 0; - const guint8* type_name; - for (i = 0; i < params; i++) { + guint length; + int i = 0; + const guint8* type_name; + for (i = 0; i < params; i++) { - /* get length that we just dissected */ - length = tvb_get_ntohs(tvb, offset); + /* get length that we just dissected */ + length = tvb_get_ntohs(tvb, offset); - /* 2 bytes = parameter type length */ - proto_tree_add_item(hdfs_tree, hf_hdfs_namelentwo, tvb, offset, 2, ENC_BIG_ENDIAN); - offset += 2; + /* 2 bytes = parameter type length */ + proto_tree_add_item(hdfs_tree, hf_hdfs_namelentwo, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; - /* length bytes = parameter type */ - proto_tree_add_item(hdfs_tree, hf_hdfs_paramtype, tvb, offset, length, ENC_BIG_ENDIAN); - offset += length; + /* length bytes = parameter type */ + proto_tree_add_item(hdfs_tree, hf_hdfs_paramtype, tvb, offset, length, ENC_BIG_ENDIAN); + offset += length; - if (offset >= length && (!tvb_memeql(tvb, offset - length, "long", length) || !tvb_memeql(tvb, offset - length, "int", length) || - !tvb_memeql(tvb, offset - length, "short", length) || !tvb_memeql(tvb, offset - length, "char", length) || - !tvb_memeql(tvb, offset - length, "byte", length) || !tvb_memeql(tvb, offset - length, "float", length) - || !tvb_memeql(tvb, offset - length, "double", length) || !tvb_memeql(tvb, offset - length, "boolean", length))) { + if (offset >= length && (!tvb_memeql(tvb, offset - length, "long", length) || !tvb_memeql(tvb, offset - length, "int", length) || + !tvb_memeql(tvb, offset - length, "short", length) || !tvb_memeql(tvb, offset - length, "char", length) || + !tvb_memeql(tvb, offset - length, "byte", length) || !tvb_memeql(tvb, offset - length, "float", length) + || !tvb_memeql(tvb, offset - length, "double", length) || !tvb_memeql(tvb, offset - length, "boolean", length))) { if (!tvb_memeql(tvb, offset - length, "boolean", length)) { length = 1; } else if (!tvb_memeql(tvb, offset - length, "short", length)) { length = 2; } else { - length = sizeof(type_name); + length = sizeof(type_name); } - - proto_tree_add_item(hdfs_tree, hf_hdfs_paramvalnum, tvb, offset, length, ENC_BIG_ENDIAN); - offset += length; - - } else { - /* get length */ - length = tvb_get_ntohs(tvb, offset); - - /* 2 bytes = parameter value length */ - proto_tree_add_item(hdfs_tree, hf_hdfs_namelentwo, tvb, offset, 2, ENC_BIG_ENDIAN); - offset += 2; - - proto_tree_add_item(hdfs_tree, hf_hdfs_paramval, tvb, offset, length, ENC_BIG_ENDIAN); - offset += length; - - if (!tvb_memeql(tvb, offset - length, "org.apache.hadoop.fs.permission.FsPermission", length)) { - proto_tree_add_item(hdfs_tree, hf_hdfs_fileperm, tvb, offset, 2, ENC_BIG_ENDIAN); - offset += 2; - } - } - } + + proto_tree_add_item(hdfs_tree, hf_hdfs_paramvalnum, tvb, offset, length, ENC_BIG_ENDIAN); + offset += length; + + } else { + /* get length */ + length = tvb_get_ntohs(tvb, offset); + + /* 2 bytes = parameter value length */ + proto_tree_add_item(hdfs_tree, hf_hdfs_namelentwo, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; + + proto_tree_add_item(hdfs_tree, hf_hdfs_paramval, tvb, offset, length, ENC_BIG_ENDIAN); + offset += length; + + if (!tvb_memeql(tvb, offset - length, "org.apache.hadoop.fs.permission.FsPermission", length)) { + proto_tree_add_item(hdfs_tree, hf_hdfs_fileperm, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; + } + } + } } /* Dissects a data packet of the form: - method name length : 2B - method name : above value - number of parameters : 4B + method name length : 2B + method name : above value + number of parameters : 4B -- list of parameters the length of above -- - parameter type length : 2B - parameter type : above value + parameter type length : 2B + parameter type : above value -- if the type is variable size -- - parameter value length : 2B - parameter value : above value + parameter value length : 2B + parameter value : above value -- otherwise -- - parameter value : length of the type */ + parameter value : length of the type */ static void dissect_data (tvbuff_t *tvb, proto_tree *hdfs_tree, guint offset) { - int params = 0; - guint length = 0; + int params = 0; + guint length = 0; - /* get length */ - length = tvb_get_ntohs(tvb, offset); + /* get length */ + length = tvb_get_ntohs(tvb, offset); - /* method name length = 2 B */ - proto_tree_add_item(hdfs_tree, hf_hdfs_namelentwo, tvb, offset, 2, ENC_BIG_ENDIAN); - offset += 2; + /* method name length = 2 B */ + proto_tree_add_item(hdfs_tree, hf_hdfs_namelentwo, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; - /* length bytes = method name */ - proto_tree_add_item(hdfs_tree, hf_hdfs_strcall, tvb, offset, length, ENC_BIG_ENDIAN); - offset += length; + /* length bytes = method name */ + proto_tree_add_item(hdfs_tree, hf_hdfs_strcall, tvb, offset, length, ENC_BIG_ENDIAN); + offset += length; - /* we only want to parse the packet if it is not a heartbeat (random looking numbers are the decimal - representation of sendHeartbeat */ - if (!(tvb_get_ntohl(tvb, offset - SEND_OFFSET) == SEND_DEC && tvb_get_ntohl(tvb, offset - HEAR_OFFSET) == HEAR_DEC && - tvb_get_ntohl(tvb, offset - TBEA_OFFSET) == TBEA_DEC && tvb_get_guint8(tvb, offset - T_OFFSET) == T_DEC)) { + /* we only want to parse the packet if it is not a heartbeat (random looking numbers are the decimal + representation of sendHeartbeat */ + if (!(tvb_get_ntohl(tvb, offset - SEND_OFFSET) == SEND_DEC && tvb_get_ntohl(tvb, offset - HEAR_OFFSET) == HEAR_DEC && + tvb_get_ntohl(tvb, offset - TBEA_OFFSET) == TBEA_DEC && tvb_get_guint8(tvb, offset - T_OFFSET) == T_DEC)) { - /* get number of params */ - params = tvb_get_ntohl(tvb, offset); + /* get number of params */ + params = tvb_get_ntohl(tvb, offset); - /* 4 bytes = # of parameters */ - proto_tree_add_item(hdfs_tree, hf_hdfs_params, tvb, offset, 4, ENC_BIG_ENDIAN); - offset += 4; + /* 4 bytes = # of parameters */ + proto_tree_add_item(hdfs_tree, hf_hdfs_params, tvb, offset, 4, ENC_BIG_ENDIAN); + offset += 4; - /* go through all params and dissect their type length, type, value length and value */ - dissect_params (tvb, hdfs_tree, offset, params); - } + /* go through all params and dissect their type length, type, value length and value */ + dissect_params (tvb, hdfs_tree, offset, params); + } } /* @@ -244,7 +244,7 @@ dissect_resp_long (tvbuff_t *tvb, proto_tree *hdfs_tree, int offset) { /* length bytes = parameter type */ proto_tree_add_item(hdfs_tree, hf_hdfs_paramtype, tvb, offset, length, ENC_BIG_ENDIAN); offset += length; - + /* the value */ proto_tree_add_item(hdfs_tree, hf_hdfs_prover, tvb, offset, 8, ENC_BIG_ENDIAN); offset += 8; @@ -260,8 +260,8 @@ dissect_resp_filestatus (tvbuff_t *tvb, proto_tree *hdfs_tree, int offset) { /* file status */ proto_tree_add_item(hdfs_tree, hf_hdfs_fileperm, tvb, offset, 2, ENC_BIG_ENDIAN); - offset += 2; - + offset += 2; + /* get length */ length = tvb_get_ntohs(tvb, offset); @@ -271,25 +271,25 @@ dissect_resp_filestatus (tvbuff_t *tvb, proto_tree *hdfs_tree, int offset) { /* file name */ proto_tree_add_item(hdfs_tree, hf_hdfs_filename, tvb, offset, length, ENC_BIG_ENDIAN); - offset += length; - + offset += length; + /* 8 file size / end location */ proto_tree_add_item(hdfs_tree, hf_hdfs_endblockloc, tvb, offset, 8, ENC_BIG_ENDIAN); offset += 8; - + /* is directory */ proto_tree_add_item(hdfs_tree, hf_hdfs_isdir, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; - + /* block replication factor */ proto_tree_add_item(hdfs_tree, hf_hdfs_blockrep, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; - + /* block size */ proto_tree_add_item(hdfs_tree, hf_hdfs_blocksize, tvb, offset, 8, ENC_BIG_ENDIAN); offset += 8; - + /* modified time */ proto_tree_add_item(hdfs_tree, hf_hdfs_modtime, tvb, offset, 8, ENC_BIG_ENDIAN); offset += 8; @@ -301,7 +301,7 @@ dissect_resp_filestatus (tvbuff_t *tvb, proto_tree *hdfs_tree, int offset) { /* 2 of file permissions */ proto_tree_add_item(hdfs_tree, hf_hdfs_fileperm, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; - + /* get length */ length = tvb_get_guint8 (tvb, offset); @@ -313,7 +313,7 @@ dissect_resp_filestatus (tvbuff_t *tvb, proto_tree *hdfs_tree, int offset) { /* owner name */ proto_tree_add_item(hdfs_tree, hf_hdfs_ownername, tvb, offset, length, ENC_BIG_ENDIAN); offset += length; - + /* get length */ length = tvb_get_guint8 (tvb, offset); @@ -333,60 +333,60 @@ parses the sent back information about each blcok */ static int dissect_block_info (tvbuff_t *tvb, proto_tree *hdfs_tree, int offset) { - + int length; - + length = tvb_get_guint8(tvb, offset); - + /* identifier length */ proto_tree_add_item(hdfs_tree, hf_hdfs_namelenone, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; - + /* identifier */ proto_tree_add_item(hdfs_tree, hf_hdfs_identifier, tvb, offset, length, ENC_BIG_ENDIAN); offset += length; - + length = tvb_get_guint8(tvb, offset); - + /* password length */ proto_tree_add_item(hdfs_tree, hf_hdfs_namelenone, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; - + /* password */ proto_tree_add_item(hdfs_tree, hf_hdfs_password, tvb, offset, length, ENC_BIG_ENDIAN); offset += length; - + length = tvb_get_guint8(tvb, offset); - + /* kind length */ proto_tree_add_item(hdfs_tree, hf_hdfs_namelenone, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; - + /* kind */ proto_tree_add_item(hdfs_tree, hf_hdfs_kind, tvb, offset, length, ENC_BIG_ENDIAN); offset += length; - + length = tvb_get_guint8(tvb, offset); - + /* service length */ proto_tree_add_item(hdfs_tree, hf_hdfs_namelenone, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; - + /* service */ proto_tree_add_item(hdfs_tree, hf_hdfs_service, tvb, offset, length, ENC_BIG_ENDIAN); offset += length; - + /* corrupt */ proto_tree_add_item(hdfs_tree, hf_hdfs_corrupt, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; - + /* offset */ proto_tree_add_item(hdfs_tree, hf_hdfs_offset, tvb, offset, 8, ENC_BIG_ENDIAN); offset += 8; - - + + /* block info section */ - + /* block location */ proto_tree_add_item(hdfs_tree, hf_hdfs_blockloc, tvb, offset, 8, ENC_BIG_ENDIAN); offset += 8; @@ -394,11 +394,11 @@ dissect_block_info (tvbuff_t *tvb, proto_tree *hdfs_tree, int offset) { /* block size */ proto_tree_add_item(hdfs_tree, hf_hdfs_blocksize, tvb, offset, 8, ENC_BIG_ENDIAN); offset += 8; - + /* gen id 8 */ proto_tree_add_item(hdfs_tree, hf_hdfs_blockgen, tvb, offset, 8, ENC_BIG_ENDIAN); - offset += 8; - + offset += 8; + /* locations */ proto_tree_add_item(hdfs_tree, hf_hdfs_locations, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; @@ -416,9 +416,9 @@ dissect_block_info (tvbuff_t *tvb, proto_tree *hdfs_tree, int offset) { /* datanode id */ proto_tree_add_item(hdfs_tree, hf_hdfs_datanodeid, tvb, offset, length, ENC_BIG_ENDIAN); offset += length; - + length = tvb_get_ntohs(tvb, offset); - + /* length of addr */ proto_tree_add_item(hdfs_tree, hf_hdfs_namelentwo, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; @@ -426,11 +426,11 @@ dissect_block_info (tvbuff_t *tvb, proto_tree *hdfs_tree, int offset) { /* storageid */ proto_tree_add_item(hdfs_tree, hf_hdfs_storageid, tvb, offset, length, ENC_BIG_ENDIAN); offset += length; - + /* info port */ proto_tree_add_item(hdfs_tree, hf_hdfs_infoport, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; - + /* default name node port */ proto_tree_add_item(hdfs_tree, hf_hdfs_ipcport, tvb, offset, 2, ENC_BIG_ENDIAN); @@ -439,79 +439,79 @@ dissect_block_info (tvbuff_t *tvb, proto_tree *hdfs_tree, int offset) { /* capacity */ proto_tree_add_item(hdfs_tree, hf_hdfs_capacity, tvb, offset, 8, ENC_BIG_ENDIAN); offset += 8; - + /* dfs used */ proto_tree_add_item(hdfs_tree, hf_hdfs_dfsused, tvb, offset, 8, ENC_BIG_ENDIAN); offset += 8; - + /* remaining */ proto_tree_add_item(hdfs_tree, hf_hdfs_remaining, tvb, offset, 8, ENC_BIG_ENDIAN); offset += 8; - + /* last update */ proto_tree_add_item(hdfs_tree, hf_hdfs_lastupdate, tvb, offset, 8, ENC_BIG_ENDIAN); offset += 8; - + /* num active connections */ proto_tree_add_item(hdfs_tree, hf_hdfs_activecon, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; - - + + length = tvb_get_guint8(tvb, offset); - + /* location rack length */ proto_tree_add_item(hdfs_tree, hf_hdfs_namelenone, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; - + /* location rack */ proto_tree_add_item(hdfs_tree, hf_hdfs_rackloc, tvb, offset, length, ENC_BIG_ENDIAN); offset += length; - + length = tvb_get_guint8(tvb, offset); - + /* hostname length */ proto_tree_add_item(hdfs_tree, hf_hdfs_namelenone, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; - + /* hostname */ proto_tree_add_item(hdfs_tree, hf_hdfs_hostname, tvb, offset, length, ENC_BIG_ENDIAN); offset += length; - + length = tvb_get_guint8(tvb, offset); - + /* admin state length */ proto_tree_add_item(hdfs_tree, hf_hdfs_namelenone, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; - + /* admin state */ proto_tree_add_item(hdfs_tree, hf_hdfs_adminstate, tvb, offset, length, ENC_BIG_ENDIAN); offset += length; - + return offset; } -/* -dissects the response from get block info. +/* +dissects the response from get block info. */ static void dissect_resp_locatedblocks (tvbuff_t *tvb, proto_tree *hdfs_tree, int offset) { - - + + /* file length = 8 */ proto_tree_add_item(hdfs_tree, hf_hdfs_filelen, tvb, offset, 8, ENC_BIG_ENDIAN); offset += 8; - + /* under construction = 1 */ proto_tree_add_item(hdfs_tree, hf_hdfs_construct, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; - + /* number of blocks */ proto_tree_add_item(hdfs_tree, hf_hdfs_blockcount, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; - + /* dissect info for each block */ while (tvb_reported_length(tvb) - offset > 0) { offset = dissect_block_info (tvb, hdfs_tree, offset); @@ -523,143 +523,143 @@ dissect_resp_locatedblocks (tvbuff_t *tvb, proto_tree *hdfs_tree, int offset) { static void dissect_hdfs_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - guint offset = 0; - int success = 0; - guint length = 0; - - - col_set_str(pinfo->cinfo, COL_PROTOCOL, "HDFS"); - /* Clear out stuff in the info column */ - col_clear(pinfo->cinfo,COL_INFO); - - if (tree) { - - proto_item *ti = NULL; - proto_tree *hdfs_tree = NULL; - - ti = proto_tree_add_item(tree, proto_hdfs, tvb, 0, -1, ENC_BIG_ENDIAN); - hdfs_tree = proto_item_add_subtree(ti, ett_hdfs); - - /* Response */ - if (pinfo->srcport == NAMENODE_PORT) { - /* 4 bytes = sequence number */ - proto_tree_add_item(hdfs_tree, hf_hdfs_packetno, tvb, offset, 4, ENC_BIG_ENDIAN); - offset += 4; - - /* 4 bytes = status -> 0000 = success, 0001 = error, ffff = fatal */ - success = tvb_get_ntohl(tvb, offset); - proto_tree_add_item(hdfs_tree, hf_hdfs_success, tvb, offset, 4, ENC_BIG_ENDIAN); - offset += 4; - - if (success != 0) { - return; - } - - if (!tvb_memeql(tvb, offset + 2, "long", 4)) { - dissect_resp_long (tvb, hdfs_tree, offset); - - } else { - - /* name length = 2 B */ - length = tvb_get_ntohs(tvb, offset); - proto_tree_add_item(hdfs_tree, hf_hdfs_namelentwo, tvb, offset, 2, ENC_BIG_ENDIAN); - offset += 2; - - /* length bytes = method name */ - proto_tree_add_item(hdfs_tree, hf_hdfs_objname, tvb, offset, length, ENC_BIG_ENDIAN); - offset += length; + guint offset = 0; + int success = 0; + guint length = 0; + + + col_set_str(pinfo->cinfo, COL_PROTOCOL, "HDFS"); + /* Clear out stuff in the info column */ + col_clear(pinfo->cinfo,COL_INFO); + + if (tree) { + + proto_item *ti = NULL; + proto_tree *hdfs_tree = NULL; + + ti = proto_tree_add_item(tree, proto_hdfs, tvb, 0, -1, ENC_BIG_ENDIAN); + hdfs_tree = proto_item_add_subtree(ti, ett_hdfs); + + /* Response */ + if (pinfo->srcport == NAMENODE_PORT) { + /* 4 bytes = sequence number */ + proto_tree_add_item(hdfs_tree, hf_hdfs_packetno, tvb, offset, 4, ENC_BIG_ENDIAN); + offset += 4; + + /* 4 bytes = status -> 0000 = success, 0001 = error, ffff = fatal */ + success = tvb_get_ntohl(tvb, offset); + proto_tree_add_item(hdfs_tree, hf_hdfs_success, tvb, offset, 4, ENC_BIG_ENDIAN); + offset += 4; + + if (success != 0) { + return; + } + + if (!tvb_memeql(tvb, offset + 2, "long", 4)) { + dissect_resp_long (tvb, hdfs_tree, offset); + + } else { + + /* name length = 2 B */ + length = tvb_get_ntohs(tvb, offset); + proto_tree_add_item(hdfs_tree, hf_hdfs_namelentwo, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; + + /* length bytes = method name */ + proto_tree_add_item(hdfs_tree, hf_hdfs_objname, tvb, offset, length, ENC_BIG_ENDIAN); + offset += length; /* get length that we just dissected */ - length = tvb_get_ntohs(tvb, offset); - - /* 2 bytes = objects length */ - proto_tree_add_item(hdfs_tree, hf_hdfs_namelentwo, tvb, offset, 2, ENC_BIG_ENDIAN); - offset += 2; - - /* length bytes = object name */ - proto_tree_add_item(hdfs_tree, hf_hdfs_objname, tvb, offset, length, ENC_BIG_ENDIAN); - offset += length; - - /* responses about block location info */ - if (!tvb_memeql(tvb, offset - length, "org.apache.hadoop.hdfs.protocol.LocatedBlocks", length)) { + length = tvb_get_ntohs(tvb, offset); + + /* 2 bytes = objects length */ + proto_tree_add_item(hdfs_tree, hf_hdfs_namelentwo, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; + + /* length bytes = object name */ + proto_tree_add_item(hdfs_tree, hf_hdfs_objname, tvb, offset, length, ENC_BIG_ENDIAN); + offset += length; + + /* responses about block location info */ + if (!tvb_memeql(tvb, offset - length, "org.apache.hadoop.hdfs.protocol.LocatedBlocks", length)) { dissect_resp_locatedblocks (tvb, hdfs_tree, offset); - - /* responses about file statuses */ + + /* responses about file statuses */ } else if (!tvb_memeql(tvb, offset - length, "org.apache.hadoop.hdfs.protocol.HdfsFileStatus", length)) { - dissect_resp_filestatus (tvb, hdfs_tree, offset); - + dissect_resp_filestatus (tvb, hdfs_tree, offset); + } else { - /* get length */ - length = tvb_get_ntohs(tvb, offset); + /* get length */ + length = tvb_get_ntohs(tvb, offset); - /* 2 bytes = parameter value length */ - proto_tree_add_item(hdfs_tree, hf_hdfs_namelentwo, tvb, offset, 2, ENC_BIG_ENDIAN); - offset += 2; + /* 2 bytes = parameter value length */ + proto_tree_add_item(hdfs_tree, hf_hdfs_namelentwo, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; /* the value of the parameter */ - proto_tree_add_item(hdfs_tree, hf_hdfs_paramval, tvb, offset, length, ENC_BIG_ENDIAN); - offset += length; + proto_tree_add_item(hdfs_tree, hf_hdfs_paramval, tvb, offset, length, ENC_BIG_ENDIAN); + offset += length; + } + } + + /* Request to namenode */ + } else { + + /* check the packet length */ + guint auth = tvb_get_ntohl(tvb, offset); + + /* first setup packet starts with "hrpc" */ + if (!tvb_memeql(tvb, offset, REQUEST_STR, sizeof(REQUEST_STR) - 1)) { + + proto_tree_add_item(hdfs_tree, hf_hdfs_sequenceno, tvb, offset, sizeof(REQUEST_STR) - 1, ENC_BIG_ENDIAN); + offset += sizeof(REQUEST_STR) - 1; + + proto_tree_add_item(hdfs_tree, hf_hdfs_pdu_type, tvb, offset, 1, ENC_BIG_ENDIAN); + offset += 1; + + proto_tree_add_item(hdfs_tree, hf_hdfs_flags, tvb, offset, 1, ENC_BIG_ENDIAN); + offset += 1; + + } else { + /* second authentication packet */ + if (auth + 4 != tvb_reported_length(tvb)) { + + /* authentication length (read out of first 4 bytes) */ + length = tvb_get_ntohl(tvb, offset); + proto_tree_add_item(hdfs_tree, hf_hdfs_authlen, tvb, offset, 4, ENC_BIG_ENDIAN); + offset += 4; + + /* authentication (length the number we just got) */ + proto_tree_add_item(hdfs_tree, hf_hdfs_auth, tvb, offset, length, ENC_BIG_ENDIAN); + offset += length; } - } - - /* Request to namenode */ - } else { - - /* check the packet length */ - guint auth = tvb_get_ntohl(tvb, offset); - - /* first setup packet starts with "hrpc" */ - if (!tvb_memeql(tvb, offset, REQUEST_STR, sizeof(REQUEST_STR) - 1)) { - - proto_tree_add_item(hdfs_tree, hf_hdfs_sequenceno, tvb, offset, sizeof(REQUEST_STR) - 1, ENC_BIG_ENDIAN); - offset += sizeof(REQUEST_STR) - 1; - - proto_tree_add_item(hdfs_tree, hf_hdfs_pdu_type, tvb, offset, 1, ENC_BIG_ENDIAN); - offset += 1; - - proto_tree_add_item(hdfs_tree, hf_hdfs_flags, tvb, offset, 1, ENC_BIG_ENDIAN); - offset += 1; - - } else { - /* second authentication packet */ - if (auth + 4 != tvb_reported_length(tvb)) { - - /* authentication length (read out of first 4 bytes) */ - length = tvb_get_ntohl(tvb, offset); - proto_tree_add_item(hdfs_tree, hf_hdfs_authlen, tvb, offset, 4, ENC_BIG_ENDIAN); - offset += 4; - - /* authentication (length the number we just got) */ - proto_tree_add_item(hdfs_tree, hf_hdfs_auth, tvb, offset, length, ENC_BIG_ENDIAN); - offset += length; - } - - /* data packets */ - - /* 4 bytes = length */ - proto_tree_add_item(hdfs_tree, hf_hdfs_len, tvb, offset, 4, ENC_BIG_ENDIAN); - offset += 4; - - /* 4 bytes = sequence number */ - proto_tree_add_item(hdfs_tree, hf_hdfs_packetno, tvb, offset, 4, ENC_BIG_ENDIAN); - offset += 4; - - /* dissect packet data */ - dissect_data (tvb, hdfs_tree, offset); - } - } - } + + /* data packets */ + + /* 4 bytes = length */ + proto_tree_add_item(hdfs_tree, hf_hdfs_len, tvb, offset, 4, ENC_BIG_ENDIAN); + offset += 4; + + /* 4 bytes = sequence number */ + proto_tree_add_item(hdfs_tree, hf_hdfs_packetno, tvb, offset, 4, ENC_BIG_ENDIAN); + offset += 4; + + /* dissect packet data */ + dissect_data (tvb, hdfs_tree, offset); + } + } + } } /* determine PDU length of protocol */ static guint get_hdfs_message_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset _U_) { int len = tvb_reported_length(tvb); - + if (tvb_reported_length(tvb) == 1448 || tvb_reported_length(tvb) == 1321) { - len = 150 * tvb_get_ntohs(tvb, 113) + 115 ; + len = 150 * tvb_get_ntohs(tvb, 113) + 115 ; } - + return len; } @@ -669,14 +669,14 @@ dissect_hdfs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { int frame_header_len = 0; gboolean need_reassemble = FALSE; - + frame_header_len = tvb_reported_length(tvb); - + if (frame_header_len == 1448 || frame_header_len == 1321) { need_reassemble = TRUE; } - - + + tcp_dissect_pdus(tvb, pinfo, tree, need_reassemble, frame_header_len, get_hdfs_message_len, dissect_hdfs_message); } @@ -687,346 +687,346 @@ proto_register_hdfs(void) static hf_register_info hf[] = { - /* list of all options for dissecting the protocol */ - - /************************************************* - First packet - **************************************************/ - { &hf_hdfs_sequenceno, - { "HDFS protocol type", "hdfs.type", - FT_STRING, BASE_NONE, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_pdu_type, - { "HDFS protocol version", "hdfs.version", - FT_UINT8, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_flags, - { "HDFS authentication type", "hdfs.auth", - FT_UINT8, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - /*********************************************** - Authentication packet - ***********************************************/ - { &hf_hdfs_authlen, - { "HDFS authentication length", "hdfs.authlen", - FT_STRING, BASE_NONE, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_auth, - { "HDFS authorization bits", "hdfs.auth", - FT_STRING, BASE_NONE, - NULL, 0x0, - NULL, HFILL } - }, - /********************************************** - Response - **********************************************/ - { &hf_hdfs_packetno, - { "HDFS packet number", "hdfs.seqno", - FT_UINT32, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_success, - { "HDFS success", "hdfs.success", - FT_UINT32, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_strcall, - { "HDFS method name", "hdfs.strcall", - FT_STRING, BASE_NONE, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_rest, - { "HDFS value", "hdfs.rest", - FT_STRING, BASE_NONE, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_blockloc, - { "HDFS block location", "hdfs.blockloc", - FT_UINT64, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_blocksize, - { "HDFS block size", "hdfs.blocksize", - FT_UINT64, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_endblockloc, - { "HDFS file size", "hdfs.endblockloc", - FT_UINT64, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_blockgen, - { "HDFS block gen", "hdfs.blockgen", - FT_UINT64, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_prover, - { "HDFS protocol version", "hdfs.prover", - FT_UINT64, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_objname, - { "HDFS object name", "hdfs.objname", - FT_STRING, BASE_NONE, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_filename, - { "HDFS file name", "hdfs.filename", - FT_STRING, BASE_NONE, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_blockcount, - { "HDFS block count", "hdfs.blockcount", - FT_UINT32, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_ownername, - { "HDFS owner name", "hdfs.ownername", - FT_STRING, BASE_NONE, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_groupname, - { "HDFS group name", "hdfs.groupname", - FT_STRING, BASE_NONE, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_accesstime, - { "HDFS access time", "hdfs.accesstime", - FT_UINT64, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_modtime, - { "HDFS modified time", "hdfs.modtime", - FT_UINT64, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_blockrep, - { "HDFS block replication factor", "hdfs.blockrep", - FT_UINT16, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_isdir, - { "HDFS is directory", "hdfs.isdir", - FT_UINT8, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_filelen, - { "HDFS file length", "hdfs.filelen", - FT_UINT64, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_construct, - { "HDFS under construction", "hdfs.construct", - FT_UINT8, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_rackloc, - { "HDFS rack location", "hdfs.rackloc", - FT_STRING, BASE_NONE, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_adminstate, - { "HDFS admin state", "hdfs.adminstate", - FT_STRING, BASE_NONE, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_hostname, - { "HDFS hostname", "hdfs.hostname", - FT_STRING, BASE_NONE, - NULL, 0x0, - NULL, HFILL } - }, - - - { &hf_hdfs_namelenone, - { "HDFS name length", "hdfs.namelenone", - FT_UINT8, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_namelentwo, - { "HDFS name length", "hdfs.namelentwo", - FT_UINT16, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - - - /*************************************** - file info response - ***************************************/ - { &hf_hdfs_activecon, - { "HDFS active connections", "hdfs.activecon", - FT_UINT32, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_lastupdate, - { "HDFS lastupdate", "hdfs.lastupdate", - FT_UINT64, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_remaining, - { "HDFS remaining", "hdfs.remaining", - FT_UINT64, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_dfsused, - { "HDFS dfs used", "hdfs.dfsused", - FT_UINT64, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_capacity, - { "HDFS capacity", "hdfs.capacity", - FT_UINT64, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_ipcport, - { "HDFS ipcport", "hdfs.ipcport", - FT_UINT16, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_infoport, - { "HDFS info port", "hdfs.infoport", - FT_UINT16, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_storageid, - { "HDFS storage id", "hdfs.storageid", - FT_STRING, BASE_NONE, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_datanodeid, - { "HDFS datanodeid", "hdfs.datanodeid", - FT_STRING, BASE_NONE, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_locations, - { "HDFS locations", "hdfs.locations", - FT_UINT32, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - - { &hf_hdfs_identifier, - { "HDFS locations", "hdfs.identifier", - FT_STRING, BASE_NONE, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_password, - { "HDFS password", "hdfs.password", - FT_STRING, BASE_NONE, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_kind, - { "HDFS kind", "hdfs.kind", - FT_STRING, BASE_NONE, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_service, - { "HDFS locations", "hdfs.service", - FT_STRING, BASE_NONE, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_corrupt, - { "HDFS corrupt", "hdfs.corrupt", - FT_UINT8, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_offset, - { "HDFS offset", "hdfs.offset", - FT_UINT64, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - - - /*********************************************** - Data request - ***********************************************/ - { &hf_hdfs_len, - { "HDFS length", "hdfs.len", - FT_UINT32, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - /* packet number, same as in response - method name length, same as in response - string call, same as in response */ - { &hf_hdfs_params, - { "HDFS number of parameters", "hdfs.params", - FT_UINT32, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_paramtype, - { "HDFS parameter type", "hdfs.paramtype", - FT_STRING, BASE_NONE, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_paramval, - { "HDFS parameter value", "hdfs.paramval", - FT_STRING, BASE_NONE, - NULL, 0x0, - NULL, HFILL } - }, - /* param value that is displayed as a number not a string */ - { &hf_hdfs_paramvalnum, - { "HDFS parameter value", "hdfs.paramvalnum", - FT_INT64, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, - { &hf_hdfs_fileperm, - { "HDFS File permission", "hdfs.fileperm", - FT_INT16, BASE_DEC, - NULL, 0x0, - NULL, HFILL } - }, + /* list of all options for dissecting the protocol */ + + /************************************************* + First packet + **************************************************/ + { &hf_hdfs_sequenceno, + { "HDFS protocol type", "hdfs.type", + FT_STRING, BASE_NONE, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_pdu_type, + { "HDFS protocol version", "hdfs.version", + FT_UINT8, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_flags, + { "HDFS authentication type", "hdfs.auth", + FT_UINT8, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + /*********************************************** + Authentication packet + ***********************************************/ + { &hf_hdfs_authlen, + { "HDFS authentication length", "hdfs.authlen", + FT_STRING, BASE_NONE, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_auth, + { "HDFS authorization bits", "hdfs.auth", + FT_STRING, BASE_NONE, + NULL, 0x0, + NULL, HFILL } + }, + /********************************************** + Response + **********************************************/ + { &hf_hdfs_packetno, + { "HDFS packet number", "hdfs.seqno", + FT_UINT32, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_success, + { "HDFS success", "hdfs.success", + FT_UINT32, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_strcall, + { "HDFS method name", "hdfs.strcall", + FT_STRING, BASE_NONE, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_rest, + { "HDFS value", "hdfs.rest", + FT_STRING, BASE_NONE, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_blockloc, + { "HDFS block location", "hdfs.blockloc", + FT_UINT64, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_blocksize, + { "HDFS block size", "hdfs.blocksize", + FT_UINT64, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_endblockloc, + { "HDFS file size", "hdfs.endblockloc", + FT_UINT64, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_blockgen, + { "HDFS block gen", "hdfs.blockgen", + FT_UINT64, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_prover, + { "HDFS protocol version", "hdfs.prover", + FT_UINT64, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_objname, + { "HDFS object name", "hdfs.objname", + FT_STRING, BASE_NONE, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_filename, + { "HDFS file name", "hdfs.filename", + FT_STRING, BASE_NONE, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_blockcount, + { "HDFS block count", "hdfs.blockcount", + FT_UINT32, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_ownername, + { "HDFS owner name", "hdfs.ownername", + FT_STRING, BASE_NONE, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_groupname, + { "HDFS group name", "hdfs.groupname", + FT_STRING, BASE_NONE, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_accesstime, + { "HDFS access time", "hdfs.accesstime", + FT_UINT64, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_modtime, + { "HDFS modified time", "hdfs.modtime", + FT_UINT64, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_blockrep, + { "HDFS block replication factor", "hdfs.blockrep", + FT_UINT16, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_isdir, + { "HDFS is directory", "hdfs.isdir", + FT_UINT8, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_filelen, + { "HDFS file length", "hdfs.filelen", + FT_UINT64, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_construct, + { "HDFS under construction", "hdfs.construct", + FT_UINT8, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_rackloc, + { "HDFS rack location", "hdfs.rackloc", + FT_STRING, BASE_NONE, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_adminstate, + { "HDFS admin state", "hdfs.adminstate", + FT_STRING, BASE_NONE, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_hostname, + { "HDFS hostname", "hdfs.hostname", + FT_STRING, BASE_NONE, + NULL, 0x0, + NULL, HFILL } + }, + + + { &hf_hdfs_namelenone, + { "HDFS name length", "hdfs.namelenone", + FT_UINT8, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_namelentwo, + { "HDFS name length", "hdfs.namelentwo", + FT_UINT16, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + + + /*************************************** + file info response + ***************************************/ + { &hf_hdfs_activecon, + { "HDFS active connections", "hdfs.activecon", + FT_UINT32, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_lastupdate, + { "HDFS lastupdate", "hdfs.lastupdate", + FT_UINT64, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_remaining, + { "HDFS remaining", "hdfs.remaining", + FT_UINT64, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_dfsused, + { "HDFS dfs used", "hdfs.dfsused", + FT_UINT64, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_capacity, + { "HDFS capacity", "hdfs.capacity", + FT_UINT64, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_ipcport, + { "HDFS ipcport", "hdfs.ipcport", + FT_UINT16, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_infoport, + { "HDFS info port", "hdfs.infoport", + FT_UINT16, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_storageid, + { "HDFS storage id", "hdfs.storageid", + FT_STRING, BASE_NONE, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_datanodeid, + { "HDFS datanodeid", "hdfs.datanodeid", + FT_STRING, BASE_NONE, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_locations, + { "HDFS locations", "hdfs.locations", + FT_UINT32, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + + { &hf_hdfs_identifier, + { "HDFS locations", "hdfs.identifier", + FT_STRING, BASE_NONE, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_password, + { "HDFS password", "hdfs.password", + FT_STRING, BASE_NONE, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_kind, + { "HDFS kind", "hdfs.kind", + FT_STRING, BASE_NONE, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_service, + { "HDFS locations", "hdfs.service", + FT_STRING, BASE_NONE, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_corrupt, + { "HDFS corrupt", "hdfs.corrupt", + FT_UINT8, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_offset, + { "HDFS offset", "hdfs.offset", + FT_UINT64, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + + + /*********************************************** + Data request + ***********************************************/ + { &hf_hdfs_len, + { "HDFS length", "hdfs.len", + FT_UINT32, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + /* packet number, same as in response + method name length, same as in response + string call, same as in response */ + { &hf_hdfs_params, + { "HDFS number of parameters", "hdfs.params", + FT_UINT32, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_paramtype, + { "HDFS parameter type", "hdfs.paramtype", + FT_STRING, BASE_NONE, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_paramval, + { "HDFS parameter value", "hdfs.paramval", + FT_STRING, BASE_NONE, + NULL, 0x0, + NULL, HFILL } + }, + /* param value that is displayed as a number not a string */ + { &hf_hdfs_paramvalnum, + { "HDFS parameter value", "hdfs.paramvalnum", + FT_INT64, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_hdfs_fileperm, + { "HDFS File permission", "hdfs.fileperm", + FT_INT16, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, }; @@ -1049,11 +1049,11 @@ proto_register_hdfs(void) hdfs_module = prefs_register_protocol(proto_hdfs, proto_reg_handoff_hdfs); prefs_register_uint_preference(hdfs_module, - "tcp.port", - "TCP port for HDFS", - "Set the TCP port for HDFS", - 10, - &tcp_port); + "tcp.port", + "TCP port for HDFS", + "Set the TCP port for HDFS", + 10, + &tcp_port); register_dissector("hdfs", dissect_hdfs, proto_hdfs); } @@ -1084,11 +1084,11 @@ proto_reg_handoff_hdfs(void) * Editor modelines * * Local Variables: - * c-basic-offset: 2 + * c-basic-offset: 4 * tab-width: 8 * indent-tabs-mode: nil * End: * - * ex: set shiftwidth=2 tabstop=8 expandtab: - * :indentSize=2:tabSize=8:noTabs=true: + * ex: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: */ diff --git a/epan/dissectors/packet-iax2.c b/epan/dissectors/packet-iax2.c index 3fe37d3571..5fdb124b66 100644 --- a/epan/dissectors/packet-iax2.c +++ b/epan/dissectors/packet-iax2.c @@ -1922,7 +1922,7 @@ static guint32 dissect_trunkpacket (tvbuff_t * tvb, guint32 offset, /* Timestamp */ proto_tree_add_item(iax2_tree, hf_iax2_trunk_ts, tvb, offset + 2, 4, FALSE); } - + offset += 6; if( trunkts ) { @@ -2807,7 +2807,7 @@ proto_reg_handoff_iax2 (void) dissector_add_uint("udp.port", IAX2_PORT, find_dissector("iax2")); v110_handle = find_dissector("v110"); if(v110_handle) - dissector_add_uint("iax2.dataformat", AST_DATAFORMAT_V110, v110_handle); + dissector_add_uint("iax2.dataformat", AST_DATAFORMAT_V110, v110_handle); data_handle = find_dissector("data"); } diff --git a/epan/dissectors/packet-ppi-vector.c b/epan/dissectors/packet-ppi-vector.c index cfc3e7b03b..ebfcf8f262 100644 --- a/epan/dissectors/packet-ppi-vector.c +++ b/epan/dissectors/packet-ppi-vector.c @@ -4,7 +4,7 @@ * * See * - * http://new.11mercenary.net/~johnycsh/ppi_geolocation_spec/ + * http://new.11mercenary.net/~johnycsh/ppi_geolocation_spec/ * * for specifications. * diff --git a/epan/dissectors/packet-tcp.c b/epan/dissectors/packet-tcp.c index c9dcfedcea..f84b4ccb84 100644 --- a/epan/dissectors/packet-tcp.c +++ b/epan/dissectors/packet-tcp.c @@ -270,8 +270,8 @@ static gint ett_tcp_opt_rvbd_trpy_flags = -1; #define TCPOPT_MOOD 25 /* RFC5841 TCP Packet Mood */ #define TCPOPT_QS 27 /* RFC4782 */ #define TCPOPT_USER_TO 28 /* RFC5482 */ -#define TCPOPT_EXP_FD 0xfd /* Experimental, reserved */ -#define TCPOPT_EXP_FE 0xfe /* Experimental, reserved */ +#define TCPOPT_EXP_FD 0xfd /* Experimental, reserved */ +#define TCPOPT_EXP_FE 0xfe /* Experimental, reserved */ /* Non IANA registered option numbers */ #define TCPOPT_RVBD_PROBE 76 /* Riverbed probe option */ #define TCPOPT_RVBD_TRPY 78 /* Riverbed transparency option */ @@ -300,7 +300,7 @@ static gint ett_tcp_opt_rvbd_trpy_flags = -1; #define TCPOLEN_USER_TO 4 #define TCPOLEN_RVBD_PROBE_MIN 3 #define TCPOLEN_RVBD_TRPY_MIN 16 -#define TCPOLEN_EXP_MIN 2 +#define TCPOLEN_EXP_MIN 2 static const true_false_string tcp_option_user_to_granularity = { "Minutes", "Seconds" @@ -2270,12 +2270,12 @@ dissect_tcpopt_exp(const ip_tcp_opt *optp _U_, tvbuff_t *tvb, proto_tree *exp_tree; item = proto_tree_add_item(opt_tree, hf_tcp_option_exp, tvb, - offset, optlen, FALSE); + offset, optlen, FALSE); exp_tree = proto_item_add_subtree(item, ett_tcp_option_exp); proto_tree_add_item(exp_tree, hf_tcp_option_kind, tvb, offset, 1, FALSE); proto_tree_add_item(exp_tree, hf_tcp_option_len, tvb, offset + 1, 1, FALSE); proto_tree_add_item(exp_tree, hf_tcp_option_exp_data, tvb, - offset + 2, optlen - 2, FALSE); + offset + 2, optlen - 2, FALSE); tcp_info_append_uint(pinfo, "Expxx", TRUE); } @@ -2305,7 +2305,7 @@ dissect_tcpopt_mss(const ip_tcp_opt *optp, tvbuff_t *tvb, mss = tvb_get_ntohs(tvb, offset + 2); item = proto_tree_add_none_format(opt_tree, hf_tcp_option_mss, tvb, offset, - optlen, "%s: %u bytes", optp->name, mss); + optlen, "%s: %u bytes", optp->name, mss); exp_tree = proto_item_add_subtree(item, ett_tcp_option_mss); proto_tree_add_item(exp_tree, hf_tcp_option_kind, tvb, offset, 1, FALSE); proto_tree_add_item(exp_tree, hf_tcp_option_len, tvb, offset + 1, 1, FALSE); @@ -2476,8 +2476,8 @@ dissect_tcpopt_timestamp(const ip_tcp_opt *optp _U_, tvbuff_t *tvb, proto_item_append_text(ti, "TSval %u, TSecr %u", ts_val, ts_ecr); if (tcp_ignore_timestamps == FALSE) { - tcp_info_append_uint(pinfo, "TSval", ts_val); - tcp_info_append_uint(pinfo, "TSecr", ts_ecr); + tcp_info_append_uint(pinfo, "TSval", ts_val); + tcp_info_append_uint(pinfo, "TSecr", ts_ecr); } } diff --git a/epan/dissectors/packet-wifi-p2p.c b/epan/dissectors/packet-wifi-p2p.c index 73b512fd58..027d2e9497 100644 --- a/epan/dissectors/packet-wifi-p2p.c +++ b/epan/dissectors/packet-wifi-p2p.c @@ -660,9 +660,9 @@ static void dissect_wifi_p2p_group_id(proto_item *tlv_root, } static void dissect_wifi_p2p_group_bssid(packet_info *pinfo, - proto_item *tlv_root, - proto_item *tlv_item, tvbuff_t *tvb, - int offset, guint16 slen) + proto_item *tlv_root, + proto_item *tlv_item, tvbuff_t *tvb, + int offset, guint16 slen) { int s_offset; guint8 addr[6]; diff --git a/epan/nstime.c b/epan/nstime.c index 490f0c35ae..3d05c575ba 100644 --- a/epan/nstime.c +++ b/epan/nstime.c @@ -36,18 +36,18 @@ /* set the given nstime_t to zero */ void nstime_set_zero(nstime_t *nstime) { - nstime->secs = 0; - nstime->nsecs = 0; + nstime->secs = 0; + nstime->nsecs = 0; } /* is the given nstime_t currently zero? */ gboolean nstime_is_zero(nstime_t *nstime) { - if(nstime->secs == 0 && nstime->nsecs == 0) { - return TRUE; - } else { - return FALSE; - } + if(nstime->secs == 0 && nstime->nsecs == 0) { + return TRUE; + } else { + return FALSE; + } } /* set the given nstime_t to (0,maxint) to mark it as "unset" @@ -56,18 +56,18 @@ gboolean nstime_is_zero(nstime_t *nstime) */ void nstime_set_unset(nstime_t *nstime) { - nstime->secs = 0; - nstime->nsecs = G_MAXINT; + nstime->secs = 0; + nstime->nsecs = G_MAXINT; } /* is the given nstime_t currently (0,maxint)? */ gboolean nstime_is_unset(nstime_t *nstime) { - if(nstime->secs == 0 && nstime->nsecs == G_MAXINT) { - return TRUE; - } else { - return FALSE; - } + if(nstime->secs == 0 && nstime->nsecs == G_MAXINT) { + return TRUE; + } else { + return FALSE; + } } @@ -77,8 +77,8 @@ gboolean nstime_is_unset(nstime_t *nstime) */ void nstime_copy(nstime_t *a, const nstime_t *b) { - a->secs = b->secs; - a->nsecs = b->nsecs; + a->secs = b->secs; + a->nsecs = b->nsecs; } /* diff --git a/epan/uat.c b/epan/uat.c index 8219347ea5..645503b691 100644 --- a/epan/uat.c +++ b/epan/uat.c @@ -53,204 +53,204 @@ static GPtrArray* all_uats = NULL; void uat_init(void) { - all_uats = g_ptr_array_new(); + all_uats = g_ptr_array_new(); } uat_t* uat_new(const char* name, - size_t size, - const char* filename, - gboolean from_profile, - void** data_ptr, - guint* numitems_ptr, - const char* category, - const char* help, - uat_copy_cb_t copy_cb, - uat_update_cb_t update_cb, - uat_free_cb_t free_cb, - uat_post_update_cb_t post_update_cb, - uat_field_t* flds_array) { - /* Create new uat */ - uat_t* uat = g_malloc(sizeof(uat_t)); - guint i; - - /* Add to global array of uats */ - if (!all_uats) - all_uats = g_ptr_array_new(); - - g_ptr_array_add(all_uats,uat); - - /* Check params */ - g_assert(name && size && filename && data_ptr && numitems_ptr); - - /* Set uat values from inputs */ - uat->name = g_strdup(name); - uat->record_size = size; - uat->filename = g_strdup(filename); - uat->from_profile = from_profile; - uat->user_ptr = data_ptr; - uat->nrows_p = numitems_ptr; - uat->copy_cb = copy_cb; - uat->update_cb = update_cb; - uat->free_cb = free_cb; - uat->post_update_cb = post_update_cb; - uat->fields = flds_array; - uat->user_data = g_array_new(FALSE,FALSE,(guint)uat->record_size); - uat->changed = FALSE; - uat->loaded = FALSE; - uat->rep = NULL; - uat->free_rep = NULL; - uat->help = help; - uat->category = category; - - for (i=0;flds_array[i].title;i++) { - fld_data_t* f = g_malloc(sizeof(fld_data_t)); - - f->colnum = i+1; - f->rep = NULL; - f->free_rep = NULL; - - flds_array[i].priv = f; - } - - uat->ncols = i; - - *data_ptr = NULL; - *numitems_ptr = 0; - - return uat; + size_t size, + const char* filename, + gboolean from_profile, + void** data_ptr, + guint* numitems_ptr, + const char* category, + const char* help, + uat_copy_cb_t copy_cb, + uat_update_cb_t update_cb, + uat_free_cb_t free_cb, + uat_post_update_cb_t post_update_cb, + uat_field_t* flds_array) { + /* Create new uat */ + uat_t* uat = g_malloc(sizeof(uat_t)); + guint i; + + /* Add to global array of uats */ + if (!all_uats) + all_uats = g_ptr_array_new(); + + g_ptr_array_add(all_uats,uat); + + /* Check params */ + g_assert(name && size && filename && data_ptr && numitems_ptr); + + /* Set uat values from inputs */ + uat->name = g_strdup(name); + uat->record_size = size; + uat->filename = g_strdup(filename); + uat->from_profile = from_profile; + uat->user_ptr = data_ptr; + uat->nrows_p = numitems_ptr; + uat->copy_cb = copy_cb; + uat->update_cb = update_cb; + uat->free_cb = free_cb; + uat->post_update_cb = post_update_cb; + uat->fields = flds_array; + uat->user_data = g_array_new(FALSE,FALSE,(guint)uat->record_size); + uat->changed = FALSE; + uat->loaded = FALSE; + uat->rep = NULL; + uat->free_rep = NULL; + uat->help = help; + uat->category = category; + + for (i=0;flds_array[i].title;i++) { + fld_data_t* f = g_malloc(sizeof(fld_data_t)); + + f->colnum = i+1; + f->rep = NULL; + f->free_rep = NULL; + + flds_array[i].priv = f; + } + + uat->ncols = i; + + *data_ptr = NULL; + *numitems_ptr = 0; + + return uat; } void* uat_add_record(uat_t* uat, const void* data) { - void* rec; + void* rec; - g_array_append_vals (uat->user_data, data, 1); + g_array_append_vals (uat->user_data, data, 1); - rec = uat->user_data->data + (uat->record_size * (uat->user_data->len-1)); + rec = uat->user_data->data + (uat->record_size * (uat->user_data->len-1)); - if (uat->copy_cb) { - uat->copy_cb(rec, data, (unsigned int) uat->record_size); - } + if (uat->copy_cb) { + uat->copy_cb(rec, data, (unsigned int) uat->record_size); + } - UAT_UPDATE(uat); + UAT_UPDATE(uat); - return rec; + return rec; } void uat_swap(uat_t* uat, guint a, guint b) { - size_t s = uat->record_size; - void* tmp = ep_alloc(s); + size_t s = uat->record_size; + void* tmp = ep_alloc(s); - g_assert( a < uat->user_data->len && b < uat->user_data->len ); + g_assert( a < uat->user_data->len && b < uat->user_data->len ); - if (a == b) return; + if (a == b) return; - memcpy(tmp, UAT_INDEX_PTR(uat,a), s); - memcpy(UAT_INDEX_PTR(uat,a), UAT_INDEX_PTR(uat,b), s); - memcpy(UAT_INDEX_PTR(uat,b), tmp, s); + memcpy(tmp, UAT_INDEX_PTR(uat,a), s); + memcpy(UAT_INDEX_PTR(uat,a), UAT_INDEX_PTR(uat,b), s); + memcpy(UAT_INDEX_PTR(uat,b), tmp, s); } void uat_remove_record_idx(uat_t* uat, guint idx) { - g_assert( idx < uat->user_data->len ); + g_assert( idx < uat->user_data->len ); - if (uat->free_cb) { - uat->free_cb(UAT_INDEX_PTR(uat,idx)); - } + if (uat->free_cb) { + uat->free_cb(UAT_INDEX_PTR(uat,idx)); + } - g_array_remove_index(uat->user_data, idx); + g_array_remove_index(uat->user_data, idx); - UAT_UPDATE(uat); + UAT_UPDATE(uat); } /* The returned filename was g_malloc()'d so the caller must free it */ gchar* uat_get_actual_filename(uat_t* uat, gboolean for_writing) { - gchar* pers_fname = get_persconffile_path(uat->filename, uat->from_profile, for_writing); + gchar* pers_fname = get_persconffile_path(uat->filename, uat->from_profile, for_writing); - if (! for_writing ) { - gchar* data_fname = get_datafile_path(uat->filename); + if (! for_writing ) { + gchar* data_fname = get_datafile_path(uat->filename); - if ((! file_exists(pers_fname) ) && file_exists(data_fname)) { - g_free(pers_fname); - return data_fname; - } + if ((! file_exists(pers_fname) ) && file_exists(data_fname)) { + g_free(pers_fname); + return data_fname; + } - g_free(data_fname); - } + g_free(data_fname); + } - if ((! file_exists(pers_fname) ) && (! for_writing ) ) { - g_free(pers_fname); - return NULL; - } + if ((! file_exists(pers_fname) ) && (! for_writing ) ) { + g_free(pers_fname); + return NULL; + } - return pers_fname; + return pers_fname; } uat_t* uat_get_table_by_name(const char* name) { - guint i; + guint i; - for (i=0; i < all_uats->len; i++) { - uat_t* u = g_ptr_array_index(all_uats,i); - if ( g_str_equal(u->name,name) ) { - return (u); - } - } + for (i=0; i < all_uats->len; i++) { + uat_t* u = g_ptr_array_index(all_uats,i); + if ( g_str_equal(u->name,name) ) { + return (u); + } + } - return NULL; + return NULL; } static void putfld(FILE* fp, void* rec, uat_field_t* f) { - guint fld_len; - const char* fld_ptr; - - f->cb.tostr(rec,&fld_ptr,&fld_len,f->cbdata.tostr,f->fld_data); - - switch(f->mode){ - case PT_TXTMOD_ENUM: - case PT_TXTMOD_FILENAME: - case PT_TXTMOD_DIRECTORYNAME: - case PT_TXTMOD_STRING: { - guint i; - - putc('"',fp); - - for(i=0;i<fld_len;i++) { - char c = fld_ptr[i]; - - if (c == '"' || c == '\\' || ! isprint((guchar)c) ) { - fprintf(fp,"\\x%.2x",c); - } else { - putc(c,fp); - } - } - - putc('"',fp); - return; - } - case PT_TXTMOD_HEXBYTES: { - guint i; - - for(i=0;i<fld_len;i++) { - fprintf(fp,"%.2x",((guint8*)fld_ptr)[i]); - } - - return; - } - default: - g_assert_not_reached(); - } + guint fld_len; + const char* fld_ptr; + + f->cb.tostr(rec,&fld_ptr,&fld_len,f->cbdata.tostr,f->fld_data); + + switch(f->mode){ + case PT_TXTMOD_ENUM: + case PT_TXTMOD_FILENAME: + case PT_TXTMOD_DIRECTORYNAME: + case PT_TXTMOD_STRING: { + guint i; + + putc('"',fp); + + for(i=0;i<fld_len;i++) { + char c = fld_ptr[i]; + + if (c == '"' || c == '\\' || ! isprint((guchar)c) ) { + fprintf(fp,"\\x%.2x",c); + } else { + putc(c,fp); + } + } + + putc('"',fp); + return; + } + case PT_TXTMOD_HEXBYTES: { + guint i; + + for(i=0;i<fld_len;i++) { + fprintf(fp,"%.2x",((guint8*)fld_ptr)[i]); + } + + return; + } + default: + g_assert_not_reached(); + } } gboolean uat_save(uat_t* uat, char** error) { - guint i; - gchar* fname = uat_get_actual_filename(uat,TRUE); - FILE* fp; + guint i; + gchar* fname = uat_get_actual_filename(uat,TRUE); + FILE* fp; - if (! fname ) return FALSE; + if (! fname ) return FALSE; - fp = ws_fopen(fname,"w"); + fp = ws_fopen(fname,"w"); if (!fp && errno == ENOENT) { /* Parent directory does not exist, try creating first */ @@ -263,186 +263,186 @@ gboolean uat_save(uat_t* uat, char** error) { fp = ws_fopen(fname,"w"); } - if (!fp) { - *error = ep_strdup_printf("uat_save: error opening '%s': %s",fname,g_strerror(errno)); - return FALSE; - } + if (!fp) { + *error = ep_strdup_printf("uat_save: error opening '%s': %s",fname,g_strerror(errno)); + return FALSE; + } - *error = NULL; - g_free (fname); + *error = NULL; + g_free (fname); - fprintf(fp,"# This file is automatically generated, DO NOT MODIFY.\n"); + fprintf(fp,"# This file is automatically generated, DO NOT MODIFY.\n"); - for ( i = 0 ; i < uat->user_data->len ; i++ ) { - void* rec = uat->user_data->data + (uat->record_size * i); - uat_field_t* f; - guint j; + for ( i = 0 ; i < uat->user_data->len ; i++ ) { + void* rec = uat->user_data->data + (uat->record_size * i); + uat_field_t* f; + guint j; - f = uat->fields; + f = uat->fields; - for( j=0 ; j < uat->ncols ; j++ ) { - putfld(fp, rec, &(f[j])); - fputs((j == uat->ncols - 1) ? "\n" : "," ,fp); - } + for( j=0 ; j < uat->ncols ; j++ ) { + putfld(fp, rec, &(f[j])); + fputs((j == uat->ncols - 1) ? "\n" : "," ,fp); + } - } + } - fclose(fp); + fclose(fp); - uat->changed = FALSE; + uat->changed = FALSE; - return TRUE; + return TRUE; } void uat_destroy(uat_t* uat) { - /* XXX still missing a destructor */ - g_ptr_array_remove(all_uats,uat); + /* XXX still missing a destructor */ + g_ptr_array_remove(all_uats,uat); } uat_t *uat_find(gchar *name) { guint i; - for (i=0; i < all_uats->len; i++) { - uat_t* u = g_ptr_array_index(all_uats,i); + for (i=0; i < all_uats->len; i++) { + uat_t* u = g_ptr_array_index(all_uats,i); if (strcmp(u->name, name) == 0 || strcmp(u->filename, name) == 0) { return u; } - } + } return NULL; } void uat_clear(uat_t* uat) { - guint i; + guint i; - for ( i = 0 ; i < uat->user_data->len ; i++ ) { - if (uat->free_cb) { - uat->free_cb(UAT_INDEX_PTR(uat,i)); - } - } + for ( i = 0 ; i < uat->user_data->len ; i++ ) { + if (uat->free_cb) { + uat->free_cb(UAT_INDEX_PTR(uat,i)); + } + } - g_array_set_size(uat->user_data,0); + g_array_set_size(uat->user_data,0); - *((uat)->user_ptr) = NULL; - *((uat)->nrows_p) = 0; + *((uat)->user_ptr) = NULL; + *((uat)->nrows_p) = 0; } void* uat_dup(uat_t* uat, guint* len_p) { - guint size = (guint) (uat->record_size * uat->user_data->len); - *len_p = size; - return size ? g_memdup(uat->user_data->data,size) : NULL ; + guint size = (guint) (uat->record_size * uat->user_data->len); + *len_p = size; + return size ? g_memdup(uat->user_data->data,size) : NULL ; } void* uat_se_dup(uat_t* uat, guint* len_p) { - guint size = (guint) (uat->record_size * uat->user_data->len); - *len_p = (guint) size; - return size ? se_memdup(uat->user_data->data,size) : NULL ; + guint size = (guint) (uat->record_size * uat->user_data->len); + *len_p = (guint) size; + return size ? se_memdup(uat->user_data->data,size) : NULL ; } void uat_unload_all(void) { - guint i; + guint i; - for (i=0; i < all_uats->len; i++) { - uat_t* u = g_ptr_array_index(all_uats,i); + for (i=0; i < all_uats->len; i++) { + uat_t* u = g_ptr_array_index(all_uats,i); /* Do not unload if not in profile */ if (u->from_profile) { uat_clear(u); u->loaded = FALSE; } - } + } } void uat_cleanup(void) { - while( all_uats->len ) { - uat_destroy((uat_t*)all_uats->pdata); - } + while( all_uats->len ) { + uat_destroy((uat_t*)all_uats->pdata); + } - g_ptr_array_free(all_uats,TRUE); + g_ptr_array_free(all_uats,TRUE); } void uat_foreach_table(uat_cb_t cb,void* user_data) { - guint i; + guint i; - for (i=0; i < all_uats->len; i++) - cb(g_ptr_array_index(all_uats,i), user_data); + for (i=0; i < all_uats->len; i++) + cb(g_ptr_array_index(all_uats,i), user_data); } void uat_load_all(void) { - guint i; - gchar* err; + guint i; + gchar* err; - for (i=0; i < all_uats->len; i++) { - uat_t* u = g_ptr_array_index(all_uats,i); - err = NULL; + for (i=0; i < all_uats->len; i++) { + uat_t* u = g_ptr_array_index(all_uats,i); + err = NULL; - if (!u->loaded) - uat_load(u, &err); + if (!u->loaded) + uat_load(u, &err); - if (err) { - report_failure("Error loading table '%s': %s",u->name,err); - } - } + if (err) { + report_failure("Error loading table '%s': %s",u->name,err); + } + } } gboolean uat_fld_chk_str(void* u1 _U_, const char* strptr, unsigned len _U_, const void* u2 _U_, const void* u3 _U_, const char** err) { - if (strptr == NULL) { - *err = "NULL pointer"; - return FALSE; - } + if (strptr == NULL) { + *err = "NULL pointer"; + return FALSE; + } - *err = NULL; - return TRUE; + *err = NULL; + return TRUE; } gboolean uat_fld_chk_oid(void* u1 _U_, const char* strptr, unsigned len, const void* u2 _U_, const void* u3 _U_, const char** err) { unsigned int i; - *err = NULL; - - if (strptr == NULL) { - *err = "NULL pointer"; - return FALSE; - } + *err = NULL; + + if (strptr == NULL) { + *err = "NULL pointer"; + return FALSE; + } - for(i = 0; i < len; i++) - if(!(isdigit(strptr[i]) || strptr[i] == '.')) { - *err = "Only digits [0-9] and \".\" allowed in an OID"; - break; - } + for(i = 0; i < len; i++) + if(!(isdigit(strptr[i]) || strptr[i] == '.')) { + *err = "Only digits [0-9] and \".\" allowed in an OID"; + break; + } - if(strptr[len-1] == '.') - *err = "OIDs must not be terminated with a \".\""; + if(strptr[len-1] == '.') + *err = "OIDs must not be terminated with a \".\""; - if(!((*strptr == '0' || *strptr == '1' || *strptr =='2') && (len > 1 && strptr[1] == '.'))) - *err = "OIDs must start with \"0.\" (ITU-T assigned), \"1.\" (ISO assigned) or \"2.\" (joint ISO/ITU-T assigned)"; + if(!((*strptr == '0' || *strptr == '1' || *strptr =='2') && (len > 1 && strptr[1] == '.'))) + *err = "OIDs must start with \"0.\" (ITU-T assigned), \"1.\" (ISO assigned) or \"2.\" (joint ISO/ITU-T assigned)"; - /* should also check that the second arc is in the range 0-39 */ + /* should also check that the second arc is in the range 0-39 */ - return *err == NULL; + return *err == NULL; } gboolean uat_fld_chk_proto(void* u1 _U_, const char* strptr, unsigned len, const void* u2 _U_, const void* u3 _U_, const char** err) { - if (len) { - char* name = ep_strndup(strptr,len); - ascii_strdown_inplace(name); - g_strchug(name); - - if (find_dissector(name)) { - *err = NULL; - return TRUE; - } else { - *err = "dissector not found"; - return FALSE; - } - } else { - *err = NULL; - return TRUE; - } + if (len) { + char* name = ep_strndup(strptr,len); + ascii_strdown_inplace(name); + g_strchug(name); + + if (find_dissector(name)) { + *err = NULL; + return TRUE; + } else { + *err = "dissector not found"; + return FALSE; + } + } else { + *err = NULL; + return TRUE; + } } gboolean uat_fld_chk_num_dec(void* u1 _U_, const char* strptr, unsigned len, const void* u2 _U_, const void* u3 _U_, const char** err) { @@ -456,8 +456,8 @@ gboolean uat_fld_chk_num_dec(void* u1 _U_, const char* strptr, unsigned len, con } } - *err = NULL; - return TRUE; + *err = NULL; + return TRUE; } gboolean uat_fld_chk_num_hex(void* u1 _U_, const char* strptr, unsigned len, const void* u2 _U_, const void* u3 _U_, const char** err) { @@ -471,197 +471,197 @@ gboolean uat_fld_chk_num_hex(void* u1 _U_, const char* strptr, unsigned len, con } } - *err = NULL; - return TRUE; + *err = NULL; + return TRUE; } gboolean uat_fld_chk_enum(void* u1 _U_, const char* strptr, unsigned len, const void* v, const void* u3 _U_, const char** err) { - char* str = ep_strndup(strptr,len); - guint i; - const value_string* vs = v; - - for(i=0;vs[i].strptr;i++) { - if (g_str_equal(vs[i].strptr,str)) { - *err = NULL; - return TRUE; - } - } - - *err = ep_strdup_printf("invalid value: %s",str); - return FALSE; + char* str = ep_strndup(strptr,len); + guint i; + const value_string* vs = v; + + for(i=0;vs[i].strptr;i++) { + if (g_str_equal(vs[i].strptr,str)) { + *err = NULL; + return TRUE; + } + } + + *err = ep_strdup_printf("invalid value: %s",str); + return FALSE; } gboolean uat_fld_chk_range(void* u1 _U_, const char* strptr, unsigned len, const void* v _U_, const void* u3, const char** err) { - char* str = ep_strndup(strptr,len); - range_t* r = NULL; - convert_ret_t ret = range_convert_str(&r, str,GPOINTER_TO_UINT(u3)); - - switch ( ret ) { - case CVT_NO_ERROR: - *err = NULL; - return TRUE; - case CVT_SYNTAX_ERROR: - *err = ep_strdup_printf("syntax error in range: %s",str); - return FALSE; - case CVT_NUMBER_TOO_BIG: - *err = ep_strdup_printf("value too large in range: '%s' (max = %u)",str,GPOINTER_TO_UINT(u3)); - return FALSE; - default: - *err = "This should not happen, it is a bug in wireshark! please report to wireshark-dev@wireshark.org"; - return FALSE; - } + char* str = ep_strndup(strptr,len); + range_t* r = NULL; + convert_ret_t ret = range_convert_str(&r, str,GPOINTER_TO_UINT(u3)); + + switch ( ret ) { + case CVT_NO_ERROR: + *err = NULL; + return TRUE; + case CVT_SYNTAX_ERROR: + *err = ep_strdup_printf("syntax error in range: %s",str); + return FALSE; + case CVT_NUMBER_TOO_BIG: + *err = ep_strdup_printf("value too large in range: '%s' (max = %u)",str,GPOINTER_TO_UINT(u3)); + return FALSE; + default: + *err = "This should not happen, it is a bug in wireshark! please report to wireshark-dev@wireshark.org"; + return FALSE; + } } static int xton(char d) { - switch(d) { - case '0': return 0; - case '1': return 1; - case '2': return 2; - case '3': return 3; - case '4': return 4; - case '5': return 5; - case '6': return 6; - case '7': return 7; - case '8': return 8; - case '9': return 9; - case 'a': case 'A': return 10; - case 'b': case 'B': return 11; - case 'c': case 'C': return 12; - case 'd': case 'D': return 13; - case 'e': case 'E': return 14; - case 'f': case 'F': return 15; - default: return -1; - } + switch(d) { + case '0': return 0; + case '1': return 1; + case '2': return 2; + case '3': return 3; + case '4': return 4; + case '5': return 5; + case '6': return 6; + case '7': return 7; + case '8': return 8; + case '9': return 9; + case 'a': case 'A': return 10; + case 'b': case 'B': return 11; + case 'c': case 'C': return 12; + case 'd': case 'D': return 13; + case 'e': case 'E': return 14; + case 'f': case 'F': return 15; + default: return -1; + } } char* uat_unbinstring(const char* si, guint in_len, guint* len_p) { - guint8* buf; - guint len = in_len/2; - int i = 0; - int d0, d1; + guint8* buf; + guint len = in_len/2; + int i = 0; + int d0, d1; - if (in_len%2) { - return NULL; - } + if (in_len%2) { + return NULL; + } - buf= g_malloc0(len+1); - if (len_p) *len_p = len; + buf= g_malloc0(len+1); + if (len_p) *len_p = len; - while(in_len) { - d1 = xton(*(si++)); - d0 = xton(*(si++)); + while(in_len) { + d1 = xton(*(si++)); + d0 = xton(*(si++)); - buf[i++] = (d1 * 16) + d0; + buf[i++] = (d1 * 16) + d0; - in_len -= 2; - } + in_len -= 2; + } - return (char*)buf; + return (char*)buf; } char* uat_unesc(const char* si, guint in_len, guint* len_p) { - char* buf = g_malloc0(in_len+1); - char* p = buf; - guint len = 0; - const char* s; - const char* in_end = si+in_len; - - for (s = (void*)si; s < in_end; s++) { - switch(*s) { - case '\\': - switch(*(++s)) { - case 'a': *(p++) = '\a'; len++; break; - case 'b': *(p++) = '\b'; len++; break; - case 'e': *(p++) = '\033' /* '\e' is non ANSI-C */; len++; break; - case 'f': *(p++) = '\f'; len++; break; - case 'n': *(p++) = '\n'; len++; break; - case 'r': *(p++) = '\r'; len++; break; - case 't': *(p++) = '\t'; len++; break; - case 'v': *(p++) = '\v'; len++; break; - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - { - int c0 = 0; - int c1 = 0; - int c2 = 0; - int c = 0; - - c0 = (*s) - '0'; - - if ( s[1] >= '0' && s[1] <= '7' ) { - c1 = c0; - c0 = (*++s) - '0'; - - if ( s[1] >= '0' && s[1] <= '7' ) { - c2 = c1; - c1 = c0; - c0 = (*++s) - '0'; - } - } - c = (64 * c2) + (8 * c1) + c0; - *(p++) = (char) (c > 255 ? 255 : c); - len++; - break; - } - - case 'x': - { - char c1 = *(s+1); - char c0 = *(s+2); - - if (isxdigit((guchar)c1) && isxdigit((guchar)c0)) { - *(p++) = (xton(c1) * 0x10) + xton(c0); - s += 2; - } else { - *(p++) = *s; - } - len++; - break; - } - default: - *p++ = *s; - break; - } - break; - default: - *(p++) = *s; - len++; - break; - } - } - - if (len_p) *len_p = len; - return buf; + char* buf = g_malloc0(in_len+1); + char* p = buf; + guint len = 0; + const char* s; + const char* in_end = si+in_len; + + for (s = (void*)si; s < in_end; s++) { + switch(*s) { + case '\\': + switch(*(++s)) { + case 'a': *(p++) = '\a'; len++; break; + case 'b': *(p++) = '\b'; len++; break; + case 'e': *(p++) = '\033' /* '\e' is non ANSI-C */; len++; break; + case 'f': *(p++) = '\f'; len++; break; + case 'n': *(p++) = '\n'; len++; break; + case 'r': *(p++) = '\r'; len++; break; + case 't': *(p++) = '\t'; len++; break; + case 'v': *(p++) = '\v'; len++; break; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + { + int c0 = 0; + int c1 = 0; + int c2 = 0; + int c = 0; + + c0 = (*s) - '0'; + + if ( s[1] >= '0' && s[1] <= '7' ) { + c1 = c0; + c0 = (*++s) - '0'; + + if ( s[1] >= '0' && s[1] <= '7' ) { + c2 = c1; + c1 = c0; + c0 = (*++s) - '0'; + } + } + c = (64 * c2) + (8 * c1) + c0; + *(p++) = (char) (c > 255 ? 255 : c); + len++; + break; + } + + case 'x': + { + char c1 = *(s+1); + char c0 = *(s+2); + + if (isxdigit((guchar)c1) && isxdigit((guchar)c0)) { + *(p++) = (xton(c1) * 0x10) + xton(c0); + s += 2; + } else { + *(p++) = *s; + } + len++; + break; + } + default: + *p++ = *s; + break; + } + break; + default: + *(p++) = *s; + len++; + break; + } + } + + if (len_p) *len_p = len; + return buf; } char* uat_undquote(const char* si, guint in_len, guint* len_p) { - return uat_unesc(si+1,in_len-2,len_p); + return uat_unesc(si+1,in_len-2,len_p); } char* uat_esc(const char* buf, guint len) { - const guint8* end = ((guint8*)buf)+len; - char* out = ep_alloc0((4*len)+1); - const guint8* b; - char* s = out; - - for (b = (void*)buf; b < end; b++) { - if (isprint(*b) ) { - *(s++) = (*b); - } else { - g_snprintf(s,5,"\\x%.2x",((guint)*b)); - s+=4; - } - } - - return out; + const guint8* end = ((guint8*)buf)+len; + char* out = ep_alloc0((4*len)+1); + const guint8* b; + char* s = out; + + for (b = (void*)buf; b < end; b++) { + if (isprint(*b) ) { + *(s++) = (*b); + } else { + g_snprintf(s,5,"\\x%.2x",((guint)*b)); + s+=4; + } + } + + return out; } @@ -676,10 +676,10 @@ CHK_STR_IS_DEF(isxdigit) * * Local Variables: * c-basic-offset: 4 - * tab-width: 4 + * tab-width: 8 * indent-tabs-mode: nil * End: * - * ex: set shiftwidth=4 tabstop=4 expandtab: - * :indentSize=4:tabSize=4:noTabs=true: + * ex: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: */ |