aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--epan/dissectors/packet-ncp-nmas.c342
-rw-r--r--epan/dissectors/packet-ncp-sss.c311
-rw-r--r--epan/dissectors/packet-ncp.c68
3 files changed, 323 insertions, 398 deletions
diff --git a/epan/dissectors/packet-ncp-nmas.c b/epan/dissectors/packet-ncp-nmas.c
index 5849b47a98..da6dae9752 100644
--- a/epan/dissectors/packet-ncp-nmas.c
+++ b/epan/dissectors/packet-ncp-nmas.c
@@ -189,95 +189,79 @@ static const value_string nmas_errors_enum[] = {
static int
align_4(tvbuff_t *tvb, int aoffset)
{
- if(tvb_length_remaining(tvb, aoffset) > 4 )
- {
- return (aoffset%4);
- }
- return 0;
+ if (tvb_length_remaining(tvb, aoffset) > 4 ) {
+ return (aoffset%4);
+ }
+ return 0;
}
#endif
static int
nmas_string(tvbuff_t* tvb, int hfinfo, proto_tree *nmas_tree, int offset, gboolean little)
{
- int foffset = offset;
- guint32 str_length;
- char *buffer;
- guint32 i;
- guint16 c_char;
- guint32 length_remaining = 0;
-
- buffer=(char *)ep_alloc(ITEM_LABEL_LENGTH+1);
- if (little) {
- str_length = tvb_get_letohl(tvb, foffset);
- }
- else
- {
- str_length = tvb_get_ntohl(tvb, foffset);
- }
- foffset += 4;
- if(str_length >= ITEM_LABEL_LENGTH)
- {
- proto_tree_add_string(nmas_tree, hfinfo, tvb, foffset,
- length_remaining + 4, "<String too long to process>");
- foffset += length_remaining;
- return foffset;
- }
- if(str_length == 0)
- {
- proto_tree_add_string(nmas_tree, hfinfo, tvb, offset,
- 4, "<Not Specified>");
- return foffset;
+ int foffset = offset;
+ guint32 str_length;
+ char *buffer;
+ guint32 i;
+ guint16 c_char;
+ guint32 length_remaining = 0;
+
+ buffer = (char *)ep_alloc(ITEM_LABEL_LENGTH+1);
+ if (little) {
+ str_length = tvb_get_letohl(tvb, foffset);
+ } else {
+ str_length = tvb_get_ntohl(tvb, foffset);
+ }
+ foffset += 4;
+ if (str_length >= ITEM_LABEL_LENGTH) {
+ proto_tree_add_string(nmas_tree, hfinfo, tvb, foffset,
+ length_remaining + 4, "<String too long to process>");
+ foffset += length_remaining;
+ return foffset;
+ }
+ if (str_length == 0) {
+ proto_tree_add_string(nmas_tree, hfinfo, tvb, offset, 4,
+ "<Not Specified>");
+ return foffset;
+ }
+ /*
+ * XXX - other than the special-casing of null bytes,
+ * we could just use "proto_tree_add_item()", as for
+ * FT_STRING, FT_STRINGZ, and FT_UINT_STRING fields,
+ * the display representation of an item is generated
+ * using "format_text()", so it handles non-printable
+ * characters.
+ */
+ for ( i = 0; i < str_length; i++ ) {
+ c_char = tvb_get_guint8(tvb, foffset );
+ if (c_char<0x20 || c_char>0x7e) {
+ if (c_char != 0x00) {
+ c_char = 0x2e;
+ buffer[i] = c_char & 0xff;
+ } else {
+ i--;
+ str_length--;
+ }
+ } else {
+ buffer[i] = c_char & 0xff;
}
- /*
- * XXX - other than the special-casing of null bytes,
- * we could just use "proto_tree_add_item()", as for
- * FT_STRING, FT_STRINGZ, and FT_UINT_STRING fields,
- * the display representation of an item is generated
- * using "format_text()", so it handles non-printable
- * characters.
- */
- for ( i = 0; i < str_length; i++ )
- {
- c_char = tvb_get_guint8(tvb, foffset );
- if (c_char<0x20 || c_char>0x7e)
- {
- if (c_char != 0x00)
- {
- c_char = 0x2e;
- buffer[i] = c_char & 0xff;
- }
- else
- {
- i--;
- str_length--;
- }
- }
- else
- {
- buffer[i] = c_char & 0xff;
- }
- foffset++;
- length_remaining--;
+ foffset++;
+ length_remaining--;
- if(length_remaining==1)
- {
- i++;
- break;
- }
+ if (length_remaining==1) {
+ i++;
+ break;
}
- buffer[i] = '\0';
+ }
+ buffer[i] = '\0';
- if (little) {
- str_length = tvb_get_letohl(tvb, offset);
- }
- else
- {
- str_length = tvb_get_ntohl(tvb, offset);
- }
- proto_tree_add_string(nmas_tree, hfinfo, tvb, offset+4,
- str_length, buffer);
- return foffset;
+ if (little) {
+ str_length = tvb_get_letohl(tvb, offset);
+ } else {
+ str_length = tvb_get_ntohl(tvb, offset);
+ }
+ proto_tree_add_string(nmas_tree, hfinfo, tvb, offset+4, str_length, buffer);
+ return foffset;
}
void
@@ -301,10 +285,10 @@ dissect_nmas_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, nc
/* Fill in the INFO column. */
col_set_str(pinfo->cinfo, COL_PROTOCOL, "NMAS");
col_add_fstr(pinfo->cinfo, COL_INFO, "C NMAS - %s",
- val_to_str(subfunc, nmas_func_enum, "Unknown (0x%02x)"));
+ val_to_str(subfunc, nmas_func_enum, "Unknown (0x%02x)"));
aitem = proto_tree_add_text(ncp_tree, tvb, foffset, -1, "Packet Type: %s",
- val_to_str(subfunc, nmas_func_enum, "Unknown (0x%02x)"));
+ val_to_str(subfunc, nmas_func_enum, "Unknown (0x%02x)"));
atree = proto_item_add_subtree(aitem, ett_nmas);
switch (subfunc) {
case 1:
@@ -334,7 +318,7 @@ dissect_nmas_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, nc
foffset += 4;
msg_length -= 4;
col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",
- val_to_str(subverb, nmas_subverb_enum, "Unknown subverb (%u)"));
+ val_to_str(subverb, nmas_subverb_enum, "Unknown subverb (%u)"));
switch (subverb) {
case 0: /* Fragmented Ping */
proto_tree_add_item(atree, hf_ping_version, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
@@ -360,10 +344,9 @@ dissect_nmas_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, nc
proto_tree_add_item(atree, hf_lsm_verb, tvb, foffset, 1, ENC_LITTLE_ENDIAN);
foffset += 4;
col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",
- val_to_str(msgverb, nmas_lsmverb_enum, "Unknown (%u)"));
+ val_to_str(msgverb, nmas_lsmverb_enum, "Unknown (%u)"));
- switch (msgverb)
- {
+ switch (msgverb) {
case 1:
break;
case 2:
@@ -401,10 +384,9 @@ dissect_nmas_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, nc
foffset += 1;
msg_length -= 12;
col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",
- val_to_str(msgverb, nmas_msgverb_enum, "Unknown (%u)"));
+ val_to_str(msgverb, nmas_msgverb_enum, "Unknown (%u)"));
- switch(msgverb)
- {
+ switch(msgverb) {
case 1:
msg_length = tvb_get_ntohl(tvb, foffset);
proto_tree_add_item(atree, hf_length, tvb, foffset, 4, ENC_BIG_ENDIAN);
@@ -417,8 +399,7 @@ dissect_nmas_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, nc
msg_length -= 4;
proto_tree_add_item(atree, hf_length, tvb, foffset, 4, ENC_BIG_ENDIAN);
foffset += 4;
- while (msg_length > 0)
- {
+ while (msg_length > 0) {
attribute = tvb_get_ntohl(tvb, foffset);
foffset += 4;
cur_string_len=tvb_get_ntohl(tvb, foffset);
@@ -439,14 +420,14 @@ dissect_nmas_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, nc
break;
}
msg_length -= cur_string_len;
- if (tvb_reported_length_remaining(tvb, foffset)<5)
- {
+ if (tvb_reported_length_remaining(tvb, foffset)<5) {
break;
}
}
break;
case 5:
- proto_tree_add_item(atree, hf_opaque, tvb, foffset, tvb_reported_length_remaining(tvb, foffset), ENC_NA);
+ proto_tree_add_item(atree, hf_opaque, tvb, foffset,
+ tvb_reported_length_remaining(tvb, foffset), ENC_NA);
foffset += msg_length;
break;
case 7:
@@ -494,7 +475,7 @@ dissect_nmas_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, guin
}
aitem = proto_tree_add_text(ncp_tree, tvb, foffset, -1, "Packet Type: %s",
- val_to_str(subfunc, nmas_func_enum, "Unknown (0x%02x)"));
+ val_to_str(subfunc, nmas_func_enum, "Unknown (0x%02x)"));
atree = proto_item_add_subtree(aitem, ett_nmas);
switch (subfunc) {
case 1:
@@ -505,7 +486,7 @@ dissect_nmas_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, guin
break;
case 2:
proto_tree_add_text(atree, tvb, foffset, -1, "Verb: %s",
- val_to_str(subverb, nmas_subverb_enum, "Unknown (%u)"));
+ val_to_str(subverb, nmas_subverb_enum, "Unknown (%u)"));
proto_tree_add_item(atree, hf_length, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
msg_length = tvb_get_letohl(tvb, foffset);
foffset +=4;
@@ -519,8 +500,7 @@ dissect_nmas_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, guin
roffset = foffset;
foffset += 4;
msg_length -= 8;
- if (return_code == 0 && msg_length > 0)
- {
+ if (return_code == 0 && msg_length > 0) {
switch (subverb) {
case 0: /* Fragmented Ping */
proto_tree_add_item(atree, hf_session_ident, tvb, foffset, 4, ENC_BIG_ENDIAN);
@@ -551,9 +531,8 @@ dissect_nmas_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, guin
break;
case 8: /* Login Store Management */
proto_tree_add_text(atree, tvb, foffset, -1, "Subverb: %s",
- val_to_str(msgverb, nmas_lsmverb_enum, "Unknown (%u)"));
- switch(msgverb)
- {
+ val_to_str(msgverb, nmas_lsmverb_enum, "Unknown (%u)"));
+ switch(msgverb) {
/* The data within these structures is all encrypted. */
case 1:
case 3:
@@ -574,8 +553,7 @@ dissect_nmas_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, guin
case 1242: /* Message Handler */
proto_tree_add_text(atree, tvb, foffset, -1, "Subverb: %s",
val_to_str(msgverb, nmas_msgverb_enum, "Unknown (%u)"));
- switch(msgverb)
- {
+ switch(msgverb) {
case 1:
msg_length = tvb_get_ntohl(tvb, foffset);
proto_tree_add_item(atree, hf_length, tvb, foffset, 4, ENC_BIG_ENDIAN);
@@ -593,14 +571,11 @@ dissect_nmas_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, guin
case 7:
encrypt_error = tvb_get_ntohl(tvb, foffset);
str = try_val_to_str(encrypt_error, nmas_errors_enum);
- if (str)
- {
+ if (str) {
col_add_fstr(pinfo->cinfo, COL_INFO, "R Payload Error - %s", str);
expert_item = proto_tree_add_item(atree, hf_encrypt_error, tvb, foffset, 4, ENC_BIG_ENDIAN);
expert_add_info_format_text(pinfo, expert_item, &ei_encrypt_error, "NMAS Payload Error: %s", str);
- }
- else
- {
+ } else {
proto_tree_add_item(atree, hf_opaque, tvb, foffset, msg_length, ENC_NA);
}
foffset += msg_length;
@@ -617,16 +592,12 @@ dissect_nmas_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, guin
}
}
str = try_val_to_str(return_code, nmas_errors_enum);
- if (str)
- {
+ if (str) {
expert_item = proto_tree_add_item(atree, hf_return_code, tvb, roffset, 4, ENC_LITTLE_ENDIAN);
expert_add_info_format_text(pinfo, expert_item, &ei_return_error, "NMAS Error: 0x%08x %s", return_code, str);
col_add_fstr(pinfo->cinfo, COL_INFO, "R Error - %s", str);
- }
- else
- {
- if (return_code!=0)
- {
+ } else {
+ if (return_code!=0) {
expert_item = proto_tree_add_item(atree, hf_return_code, tvb, roffset, 4, ENC_LITTLE_ENDIAN);
expert_add_info_format_text(pinfo, expert_item, &ei_return_error, "NMAS Error: 0x%08x is unknown", return_code);
col_add_fstr(pinfo->cinfo, COL_INFO, "R Unknown NMAS Error - 0x%08x", return_code);
@@ -650,139 +621,130 @@ proto_register_nmas(void)
static hf_register_info hf_nmas[] = {
#if 0
{ &hf_func,
- { "Function", "nmas.func", FT_UINT8, BASE_HEX, NULL, 0x0,
- NULL, HFILL }},
+ { "Function", "nmas.func",
+ FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
#endif
#if 0
{ &hf_subfunc,
- { "Subfunction", "nmas.subfunc", FT_UINT8, BASE_HEX, NULL, 0x0,
- NULL, HFILL }},
+ { "Subfunction", "nmas.subfunc",
+ FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
#endif
{ &hf_ping_version,
- { "Ping Version", "nmas.ping_version", FT_UINT32, BASE_HEX, NULL, 0x0,
- NULL, HFILL }},
+ { "Ping Version", "nmas.ping_version",
+ FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_ping_flags,
- { "Flags", "nmas.ping_flags", FT_UINT32, BASE_HEX, NULL, 0x0,
- NULL, HFILL }},
+ { "Flags", "nmas.ping_flags",
+ FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_frag_handle,
- { "Fragment Handle", "nmas.frag_handle", FT_UINT32, BASE_HEX, NULL, 0x0,
- NULL, HFILL }},
+ { "Fragment Handle", "nmas.frag_handle",
+ FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_length,
- { "Length", "nmas.length", FT_UINT32, BASE_DEC, NULL, 0x0,
- NULL, HFILL }},
+ { "Length", "nmas.length",
+ FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_subverb,
- { "Sub Verb", "nmas.subverb",
- FT_UINT32, BASE_HEX, VALS(nmas_subverb_enum), 0x0,
- NULL, HFILL }},
+ { "Sub Verb", "nmas.subverb",
+ FT_UINT32, BASE_HEX, VALS(nmas_subverb_enum), 0x0, NULL, HFILL }},
{ &hf_tree,
- { "Tree", "nmas.tree",
- FT_STRING, BASE_NONE, NULL, 0x0,
- NULL, HFILL }},
+ { "Tree", "nmas.tree",
+ FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_user,
- { "User", "nmas.user",
- FT_STRING, BASE_NONE, NULL, 0x0,
- NULL, HFILL }},
+ { "User", "nmas.user",
+ FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_nmas_version,
- { "NMAS Protocol Version", "nmas.version", FT_UINT32, BASE_HEX, NULL, 0x0,
- NULL, HFILL }},
+ { "NMAS Protocol Version", "nmas.version",
+ FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_msg_version,
- { "Message Version", "nmas.msg_version", FT_UINT32, BASE_HEX, NULL, 0x0,
- NULL, HFILL }},
+ { "Message Version", "nmas.msg_version",
+ FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_session_ident,
- { "Session Identifier", "nmas.session_ident", FT_UINT32, BASE_HEX, NULL, 0x0,
- NULL, HFILL }},
+ { "Session Identifier", "nmas.session_ident",
+ FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_msg_verb,
- { "Message Verb", "nmas.msg_verb", FT_UINT8, BASE_HEX, VALS(nmas_msgverb_enum), 0x0,
- NULL, HFILL }},
+ { "Message Verb", "nmas.msg_verb",
+ FT_UINT8, BASE_HEX, VALS(nmas_msgverb_enum), 0x0, NULL, HFILL }},
#if 0
{ &hf_attribute,
- { "Attribute Type", "nmas.attribute", FT_UINT32, BASE_DEC, VALS(nmas_attribute_enum), 0x0,
- NULL, HFILL }},
+ { "Attribute Type", "nmas.attribute",
+ FT_UINT32, BASE_DEC, VALS(nmas_attribute_enum), 0x0, NULL, HFILL }},
#endif
{ &hf_clearance,
- { "Requested Clearance", "nmas.clearance",
- FT_STRING, BASE_NONE, NULL, 0x0,
- NULL, HFILL }},
+ { "Requested Clearance", "nmas.clearance",
+ FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_login_sequence,
- { "Requested Login Sequence", "nmas.login_seq",
- FT_STRING, BASE_NONE, NULL, 0x0,
- NULL, HFILL }},
+ { "Requested Login Sequence", "nmas.login_seq",
+ FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_opaque,
- { "Opaque Data", "nmas.opaque",
- FT_BYTES, BASE_NONE, NULL, 0x0,
- NULL, HFILL }},
+ { "Opaque Data", "nmas.opaque",
+ FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_data,
- { "Data", "nmas.data",
- FT_BYTES, BASE_NONE, NULL, 0x0,
- NULL, HFILL }},
+ { "Data", "nmas.data",
+ FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_return_code,
- { "Return Code", "nmas.return_code", FT_UINT32, BASE_HEX, VALS(nmas_errors_enum), 0x0,
- NULL, HFILL }},
+ { "Return Code", "nmas.return_code",
+ FT_UINT32, BASE_HEX, VALS(nmas_errors_enum), 0x0, NULL, HFILL }},
{ &hf_lsm_verb,
- { "Login Store Message Verb", "nmas.lsm_verb", FT_UINT8, BASE_HEX, VALS(nmas_lsmverb_enum), 0x0,
- NULL, HFILL }},
+ { "Login Store Message Verb", "nmas.lsm_verb",
+ FT_UINT8, BASE_HEX, VALS(nmas_lsmverb_enum), 0x0, NULL, HFILL }},
{ &hf_squeue_bytes,
- { "Server Queue Number of Bytes", "nmas.squeue_bytes", FT_UINT32, BASE_DEC, NULL, 0x0,
- NULL, HFILL }},
+ { "Server Queue Number of Bytes", "nmas.squeue_bytes",
+ FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_cqueue_bytes,
- { "Client Queue Number of Bytes", "nmas.cqueue_bytes", FT_UINT32, BASE_DEC, NULL, 0x0,
- NULL, HFILL }},
+ { "Client Queue Number of Bytes", "nmas.cqueue_bytes",
+ FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_num_creds,
- { "Number of Credentials", "nmas.num_creds", FT_UINT32, BASE_DEC, NULL, 0x0,
- NULL, HFILL }},
+ { "Number of Credentials", "nmas.num_creds",
+ FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_cred_type,
- { "Credential Type", "nmas.cred_type", FT_UINT32, BASE_DEC, NULL, 0x0,
- NULL, HFILL }},
+ { "Credential Type", "nmas.cred_type",
+ FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_login_state,
- { "Login State", "nmas.login_state", FT_UINT32, BASE_DEC, NULL, 0x0,
- NULL, HFILL }},
+ { "Login State", "nmas.login_state",
+ FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_enc_cred,
- { "Encrypted Credential", "nmas.enc_cred",
- FT_BYTES, BASE_NONE, NULL, 0x0,
- NULL, HFILL }},
+ { "Encrypted Credential", "nmas.enc_cred",
+ FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_enc_data,
- { "Encrypted Data", "nmas.enc_data",
- FT_BYTES, BASE_NONE, NULL, 0x0,
- NULL, HFILL }},
+ { "Encrypted Data", "nmas.enc_data",
+ FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_reply_buffer_size,
- { "Reply Buffer Size", "nmas.buf_size", FT_UINT32, BASE_DEC, NULL, 0x0,
- NULL, HFILL }},
+ { "Reply Buffer Size", "nmas.buf_size",
+ FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_encrypt_error,
- { "Payload Error", "nmas.encrypt_error", FT_UINT32, BASE_HEX, VALS(nmas_errors_enum), 0x0,
- "Payload/Encryption Return Code", HFILL }},
-
+ { "Payload Error", "nmas.encrypt_error",
+ FT_UINT32, BASE_HEX, VALS(nmas_errors_enum), 0x0,
+ "Payload/Encryption Return Code", HFILL }}
};
static gint *ett[] = {
- &ett_nmas,
+ &ett_nmas
};
static ei_register_info ei[] = {
@@ -798,3 +760,17 @@ proto_register_nmas(void)
expert_nmas = expert_register_protocol(proto_nmas);
expert_register_field_array(expert_nmas, ei, array_length(ei));
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=4 expandtab:
+ * :indentSize=4:tabSize=4:noTabs=true:
+ */
+
diff --git a/epan/dissectors/packet-ncp-sss.c b/epan/dissectors/packet-ncp-sss.c
index 5152e715d5..ebb4324867 100644
--- a/epan/dissectors/packet-ncp-sss.c
+++ b/epan/dissectors/packet-ncp-sss.c
@@ -181,13 +181,10 @@ process_flags(proto_tree *sss_tree, tvbuff_t *tvb, guint32 foffset)
flags_str[0]='\0';
sep="";
flags = tvb_get_ntohl(tvb, foffset);
- for (i = 0 ; i < 256; i++)
- {
- if (flags & bvalue)
- {
+ for (i = 0 ; i < 256; i++) {
+ if (flags & bvalue) {
g_strlcat(flags_str, sep, 1024);
- switch(bvalue)
- {
+ switch(bvalue) {
case 0x00000001:
g_strlcat(flags_str, "Enhanced Protection", 1024);
break;
@@ -297,12 +294,9 @@ process_flags(proto_tree *sss_tree, tvbuff_t *tvb, guint32 foffset)
bvalue = 0x00000001;
- for (i = 0 ; i < 256; i++ )
- {
- if (flags & bvalue)
- {
- switch(bvalue)
- {
+ for (i = 0 ; i < 256; i++ ) {
+ if (flags & bvalue) {
+ switch(bvalue) {
case 0x00000001:
proto_tree_add_item(flags_tree, hfbit1, tvb, foffset, 4, ENC_BIG_ENDIAN);
break;
@@ -415,11 +409,9 @@ find_delimiter(tvbuff_t *tvb, int foffset)
int length = 0;
guint16 c_char;
- for (i=0; i < 256; i++)
- {
+ for (i=0; i < 256; i++) {
c_char = tvb_get_guint8(tvb, foffset);
- if (c_char == 0x2a || tvb_length_remaining(tvb, foffset)==0)
- {
+ if (c_char == 0x2a || tvb_length_remaining(tvb, foffset)==0) {
break;
}
foffset++;
@@ -431,91 +423,69 @@ find_delimiter(tvbuff_t *tvb, int foffset)
static int
sss_string(tvbuff_t* tvb, int hfinfo, proto_tree *sss_tree, int offset, gboolean little, guint32 length)
{
- int foffset = offset;
- guint32 str_length;
- char buffer[1024];
- guint32 i;
- guint16 c_char;
- guint32 length_remaining = 0;
-
- if (length==0)
- {
- if (little) {
- str_length = tvb_get_letohl(tvb, foffset);
- }
- else
- {
- str_length = tvb_get_ntohl(tvb, foffset);
- }
- foffset += 4;
- }
- else
- {
- str_length = length;
- }
- length_remaining = tvb_length_remaining(tvb, foffset);
- if(str_length > (guint)length_remaining || str_length > 1024)
- {
- proto_tree_add_string(sss_tree, hfinfo, tvb, foffset,
- length_remaining + 4, "<String too long to process>");
- foffset += length_remaining;
- return foffset;
+ int foffset = offset;
+ guint32 str_length;
+ char buffer[1024];
+ guint32 i;
+ guint16 c_char;
+ guint32 length_remaining = 0;
+
+ if (length==0) {
+ if (little) {
+ str_length = tvb_get_letohl(tvb, foffset);
+ } else {
+ str_length = tvb_get_ntohl(tvb, foffset);
}
- if(str_length == 0)
- {
- proto_tree_add_string(sss_tree, hfinfo, tvb, offset,
- 4, "<Not Specified>");
- return foffset;
+ foffset += 4;
+ } else {
+ str_length = length;
+ }
+ length_remaining = tvb_length_remaining(tvb, foffset);
+ if(str_length > (guint)length_remaining || str_length > 1024) {
+ proto_tree_add_string(sss_tree, hfinfo, tvb, foffset,
+ length_remaining + 4, "<String too long to process>");
+ foffset += length_remaining;
+ return foffset;
+ }
+ if(str_length == 0) {
+ proto_tree_add_string(sss_tree, hfinfo, tvb, offset, 4, "<Not Specified>");
+ return foffset;
+ }
+ for ( i = 0; i < str_length; i++ ) {
+ c_char = tvb_get_guint8(tvb, foffset );
+ if (c_char<0x20 || c_char>0x7e) {
+ if (c_char != 0x00) {
+ c_char = 0x2e;
+ buffer[i] = c_char & 0xff;
+ } else {
+ i--;
+ str_length--;
+ }
+ } else {
+ buffer[i] = c_char & 0xff;
}
- for ( i = 0; i < str_length; i++ )
- {
- c_char = tvb_get_guint8(tvb, foffset );
- if (c_char<0x20 || c_char>0x7e)
- {
- if (c_char != 0x00)
- {
- c_char = 0x2e;
- buffer[i] = c_char & 0xff;
- }
- else
- {
- i--;
- str_length--;
- }
- }
- else
- {
- buffer[i] = c_char & 0xff;
- }
- foffset++;
- length_remaining--;
+ foffset++;
+ length_remaining--;
- if(length_remaining==1)
- {
- i++;
- break;
- }
+ if(length_remaining==1) {
+ i++;
+ break;
}
- buffer[i] = '\0';
+ }
+ buffer[i] = '\0';
- if (length==0)
- {
- if (little) {
- str_length = tvb_get_letohl(tvb, offset);
- }
- else
- {
- str_length = tvb_get_ntohl(tvb, offset);
- }
- offset += 4;
- }
- else
- {
- str_length = length;
+ if (length==0) {
+ if (little) {
+ str_length = tvb_get_letohl(tvb, offset);
+ } else {
+ str_length = tvb_get_ntohl(tvb, offset);
}
- proto_tree_add_string(sss_tree, hfinfo, tvb, offset,
- str_length, buffer);
- return foffset;
+ offset += 4;
+ } else {
+ str_length = length;
+ }
+ proto_tree_add_string(sss_tree, hfinfo, tvb, offset, str_length, buffer);
+ return foffset;
}
void
@@ -553,8 +523,7 @@ dissect_sss_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, ncp
break;
case 2:
proto_tree_add_item(ncp_tree, hf_frag_handle, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
- if (tvb_get_letohl(tvb, foffset)==0xffffffff) /* Fragment handle of -1 means no fragment. So process packet */
- {
+ if (tvb_get_letohl(tvb, foffset)==0xffffffff) { /* Fragment handle of -1 means no fragment. So process packet */
foffset += 4;
proto_tree_add_item(ncp_tree, hf_buffer_size, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
foffset += 4;
@@ -587,24 +556,19 @@ dissect_sss_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, ncp
packets and then we will see these as malformed packets.
So check to make sure we still have data in the packet anytime
we read a secret. */
- if (tvb_length_remaining(tvb, foffset) > 4)
- {
+ if (tvb_length_remaining(tvb, foffset) > 4) {
foffset = sss_string(tvb, hf_user, atree, foffset, TRUE, 0);
}
break;
case 2:
foffset += 4;
foffset = sss_string(tvb, hf_secret, atree, foffset, TRUE, 0);
- if (tvb_length_remaining(tvb, foffset) > 4)
- {
+ if (tvb_length_remaining(tvb, foffset) > 4) {
msg_length = tvb_get_letohl(tvb, foffset);
foffset += 4;
- if (tvb_length_remaining(tvb, foffset) < (gint) msg_length)
- {
+ if (tvb_length_remaining(tvb, foffset) < (gint) msg_length) {
proto_tree_add_item(atree, hf_enc_data, tvb, foffset, -1, ENC_NA);
- }
- else
- {
+ } else {
proto_tree_add_item(atree, hf_enc_data, tvb, foffset, msg_length, ENC_NA);
}
}
@@ -612,8 +576,7 @@ dissect_sss_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, ncp
case 3:
case 4:
foffset = sss_string(tvb, hf_secret, atree, foffset, TRUE, 0);
- if (tvb_length_remaining(tvb, foffset) > 4)
- {
+ if (tvb_length_remaining(tvb, foffset) > 4) {
foffset = sss_string(tvb, hf_user, atree, foffset, TRUE, 0);
}
break;
@@ -621,8 +584,7 @@ dissect_sss_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, ncp
break;
case 6:
foffset = sss_string(tvb, hf_secret, atree, foffset, TRUE, 0);
- if (tvb_length_remaining(tvb, foffset) > 4)
- {
+ if (tvb_length_remaining(tvb, foffset) > 4) {
foffset = sss_string(tvb, hf_user, atree, foffset, TRUE, 0);
}
break;
@@ -636,10 +598,7 @@ dissect_sss_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, ncp
default:
break;
}
-
- }
- else
- {
+ } else {
col_set_str(pinfo->cinfo, COL_INFO, "C SecretStore - fragment");
proto_tree_add_text(ncp_tree, tvb, foffset, 4, "Fragment");
@@ -647,8 +606,7 @@ dissect_sss_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, ncp
if (request_value) {
request_value->req_nds_flags=255;
}
- if (tvb_length_remaining(tvb, foffset) > 8)
- {
+ if (tvb_length_remaining(tvb, foffset) > 8) {
foffset += 4;
proto_tree_add_item(ncp_tree, hf_enc_data, tvb, foffset, tvb_length_remaining(tvb, foffset), ENC_NA);
}
@@ -672,13 +630,12 @@ dissect_sss_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, guint
guint32 number_of_items=0;
gint32 length_of_string=0;
guint32 i = 0;
- const gchar *str;
+ const gchar *str;
proto_tree *atree;
proto_item *aitem;
proto_item *expert_item;
-
foffset = 8;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "NSSS");
if (tvb_length_remaining(tvb, foffset)<4) {
@@ -708,53 +665,40 @@ dissect_sss_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, guint
proto_tree_add_item(atree, hf_frag_handle, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
foffset += 4;
msg_length -= 4;
- if ((tvb_get_letohl(tvb, foffset-4)==0xffffffff) && (msg_length > 4))
- {
+ if ((tvb_get_letohl(tvb, foffset-4)==0xffffffff) && (msg_length > 4)) {
foffset += 4;
return_code = tvb_get_letohl(tvb, foffset);
str = try_val_to_str(return_code, sss_errors_enum);
- if (str)
- {
+ if (str) {
expert_item = proto_tree_add_item(atree, hf_return_code, tvb, foffset, 4, ENC_LITTLE_ENDIAN);
expert_add_info_format_text(pinfo, expert_item, &ei_return_code, "SSS Error: %s", str);
col_add_fstr(pinfo->cinfo, COL_INFO, "R Error - %s", val_to_str(return_code, sss_errors_enum, "Unknown (%d)"));
foffset+=4;
- }
- else
- {
+ } else {
proto_tree_add_text(atree, tvb, foffset, 4, "Return Code: Success (0x00000000)");
if (tvb_length_remaining(tvb, foffset) > 8) {
foffset += 4;
- if (request_value && subverb == 6)
- {
+ if (request_value && subverb == 6) {
foffset += 4;
number_of_items = tvb_get_letohl(tvb, foffset);
foffset += 8;
- for (i=0; i<number_of_items; i++)
- {
+ for (i=0; i<number_of_items; i++) {
length_of_string = find_delimiter(tvb, foffset);
- if (length_of_string > tvb_length_remaining(tvb, foffset))
- {
+ if (length_of_string > tvb_length_remaining(tvb, foffset)) {
return;
}
foffset = sss_string(tvb, hf_secret, atree, foffset, TRUE, length_of_string);
- if (tvb_length_remaining(tvb, foffset) < 8)
- {
+ if (tvb_length_remaining(tvb, foffset) < 8) {
return;
}
foffset++;
}
-
- }
- else
- {
+ } else {
proto_tree_add_item(atree, hf_enc_data, tvb, foffset, tvb_length_remaining(tvb, foffset), ENC_NA);
}
}
}
- }
- else
- {
+ } else {
proto_tree_add_text(atree, tvb, foffset, 4, "Return Code: Success (0x00000000)");
if (tvb_length_remaining(tvb, foffset) > 8) {
foffset += 4;
@@ -774,61 +718,43 @@ proto_register_sss(void)
{
static hf_register_info hf_sss[] = {
{ &hf_buffer_size,
- { "Buffer Size", "sss.buffer", FT_UINT32, BASE_DEC, NULL, 0x0,
- NULL, HFILL }},
+ { "Buffer Size", "sss.buffer", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_ping_version,
- { "Ping Version", "sss.ping_version", FT_UINT32, BASE_HEX, NULL, 0x0,
- NULL, HFILL }},
+ { "Ping Version", "sss.ping_version", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_flags,
- { "Flags", "sss.flags", FT_UINT32, BASE_HEX, NULL, 0x0,
- NULL, HFILL }},
+ { "Flags", "sss.flags", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_context,
- { "Context", "sss.context", FT_UINT32, BASE_HEX, NULL, 0x0,
- NULL, HFILL }},
+ { "Context", "sss.context", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_frag_handle,
- { "Fragment Handle", "sss.frag_handle", FT_UINT32, BASE_HEX, NULL, 0x0,
- NULL, HFILL }},
+ { "Fragment Handle", "sss.frag_handle", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_length,
- { "Length", "sss.length", FT_UINT32, BASE_DEC, NULL, 0x0,
- NULL, HFILL }},
+ { "Length", "sss.length", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_verb,
- { "Verb", "sss.verb",
- FT_UINT32, BASE_HEX, VALS(sss_verb_enum), 0x0,
- NULL, HFILL }},
+ { "Verb", "sss.verb", FT_UINT32, BASE_HEX, VALS(sss_verb_enum), 0x0, NULL, HFILL }},
{ &hf_user,
- { "User", "sss.user",
- FT_STRING, BASE_NONE, NULL, 0x0,
- NULL, HFILL }},
+ { "User", "sss.user", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_secret,
- { "Secret ID", "sss.secret",
- FT_STRING, BASE_NONE, NULL, 0x0,
- NULL, HFILL }},
+ { "Secret ID", "sss.secret", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_sss_version,
- { "SecretStore Protocol Version", "sss.version", FT_UINT32, BASE_HEX, NULL, 0x0,
- NULL, HFILL }},
+ { "SecretStore Protocol Version", "sss.version", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_return_code,
- { "Return Code", "sss.return_code", FT_UINT32, BASE_HEX, VALS(sss_errors_enum), 0x0,
- NULL, HFILL }},
+ { "Return Code", "sss.return_code", FT_UINT32, BASE_HEX, VALS(sss_errors_enum), 0x0, NULL, HFILL }},
{ &hf_enc_cred,
- { "Encrypted Credential", "sss.enc_cred",
- FT_BYTES, BASE_NONE, NULL, 0x0,
- NULL, HFILL }},
+ { "Encrypted Credential", "sss.enc_cred", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_enc_data,
- { "Encrypted Data", "sss.enc_data",
- FT_BYTES, BASE_NONE, NULL, 0x0,
- NULL, HFILL }},
+ { "Encrypted Data", "sss.enc_data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hfbit1,
{ "Enhanced Protection", "ncp.sss_bit1", FT_BOOLEAN, 32, NULL, 0x00000001, NULL, HFILL }},
@@ -924,24 +850,37 @@ proto_register_sss(void)
{ "Not Defined", "ncp.sss_bit31", FT_BOOLEAN, 32, NULL, 0x40000000, NULL, HFILL }},
{ &hfbit32,
- { "Not Defined", "ncp.sss_bit32", FT_BOOLEAN, 32, NULL, 0x80000000, NULL, HFILL }},
-
+ { "Not Defined", "ncp.sss_bit32", FT_BOOLEAN, 32, NULL, 0x80000000, NULL, HFILL }}
};
- static gint *ett[] = {
- &ett_sss,
- };
+ static gint *ett[] = {
+ &ett_sss
+ };
- static ei_register_info ei[] = {
- { &ei_return_code, { "sss.return_code.expert", PI_RESPONSE_CODE, PI_NOTE, "SSS Error", EXPFILL }},
- };
+ static ei_register_info ei[] = {
+ { &ei_return_code, { "sss.return_code.expert", PI_RESPONSE_CODE, PI_NOTE, "SSS Error", EXPFILL }}
+ };
- expert_module_t* expert_sss;
- /*module_t *sss_module;*/
+ expert_module_t* expert_sss;
+ /*module_t *sss_module;*/
- proto_sss = proto_register_protocol("Novell SecretStore Services", "SSS", "sss");
- proto_register_field_array(proto_sss, hf_sss, array_length(hf_sss));
- proto_register_subtree_array(ett, array_length(ett));
- expert_sss = expert_register_protocol(proto_sss);
- expert_register_field_array(expert_sss, ei, array_length(ei));
+ proto_sss = proto_register_protocol("Novell SecretStore Services", "SSS", "sss");
+ proto_register_field_array(proto_sss, hf_sss, array_length(hf_sss));
+ proto_register_subtree_array(ett, array_length(ett));
+ expert_sss = expert_register_protocol(proto_sss);
+ expert_register_field_array(expert_sss, ei, array_length(ei));
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=4 expandtab:
+ * :indentSize=4:tabSize=4:noTabs=true:
+ */
+
diff --git a/epan/dissectors/packet-ncp.c b/epan/dissectors/packet-ncp.c
index 248523f961..709b4abd9f 100644
--- a/epan/dissectors/packet-ncp.c
+++ b/epan/dissectors/packet-ncp.c
@@ -141,13 +141,13 @@ struct ncp_ip_rqhdr {
static const value_string ncp_ip_signature[] = {
{ NCPIP_RQST, "Demand Transport (Request)" },
{ NCPIP_RPLY, "Transport is NCP (Reply)" },
- { 0, NULL },
+ { 0, NULL }
};
static const value_string burst_command[] = {
{ 0x01000000, "Burst Read" },
{ 0x02000000, "Burst Write" },
- { 0, NULL },
+ { 0, NULL }
};
/* The information in this module comes from:
@@ -416,8 +416,7 @@ dissect_ncp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/* Get request value data */
request_value = mncp_hash_lookup(conversation, nw_connection, header.task);
if (request_value) {
- if ((request_value->session_start_packet_num == pinfo->fd->num) && ncp_echo_conn)
- {
+ if ((request_value->session_start_packet_num == pinfo->fd->num) && ncp_echo_conn) {
expert_add_info_format(pinfo, NULL, PI_RESPONSE_CODE, PI_CHAT, "Detected New Server Session. Connection %d, Task %d", nw_connection, header.task);
}
}
@@ -450,8 +449,7 @@ dissect_ncp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
} else {
request_value = mncp_hash_lookup(conversation, nw_connection, header.task);
if (request_value) {
- if ((request_value->session_start_packet_num == pinfo->fd->num) && ncp_echo_conn)
- {
+ if ((request_value->session_start_packet_num == pinfo->fd->num) && ncp_echo_conn) {
expert_add_info_format(pinfo, NULL, PI_RESPONSE_CODE, PI_CHAT, "Detected New Server Session. Connection %d, Task %d", nw_connection, header.task);
}
}
@@ -474,8 +472,7 @@ dissect_ncp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
proto_tree_add_item(ncp_tree, hf_ncp_task, tvb, commhdr + 4, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(ncp_tree, hf_ncp_oplock_flag, tvb, commhdr + 9, 1, tvb_get_guint8(tvb, commhdr+9));
proto_tree_add_item(ncp_tree, hf_ncp_oplock_handle, tvb, commhdr + 10, 4, ENC_BIG_ENDIAN);
- if ((tvb_get_guint8(tvb, commhdr+9)==0x24) && ncp_echo_file)
- {
+ if ((tvb_get_guint8(tvb, commhdr+9)==0x24) && ncp_echo_file) {
expert_add_info_format(pinfo, NULL, PI_RESPONSE_CODE, PI_CHAT, "Server requesting station to clear oplock on handle - %08x", tvb_get_ntohl(tvb, commhdr+10));
}
break;
@@ -838,24 +835,24 @@ dissect_ncp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
static guint
get_ncp_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset)
{
- guint32 signature;
-
- /*
- * Check the NCP-over-TCP header signature, to make sure it's there.
- * If it's not there, we cannot trust the next 4 bytes to be a
- * packet length+"has signature" flag, so we just say the length is
- * "what remains in the packet".
- */
- signature = tvb_get_ntohl(tvb, offset);
- if (signature != NCPIP_RQST && signature != NCPIP_RPLY)
- return tvb_length_remaining(tvb, offset);
-
- /*
- * Get the length of the NCP-over-TCP packet. Strip off the "has
- * signature" flag.
- */
-
- return tvb_get_ntohl(tvb, offset + 4) & 0x7fffffff;
+ guint32 signature;
+
+ /*
+ * Check the NCP-over-TCP header signature, to make sure it's there.
+ * If it's not there, we cannot trust the next 4 bytes to be a
+ * packet length+"has signature" flag, so we just say the length is
+ * "what remains in the packet".
+ */
+ signature = tvb_get_ntohl(tvb, offset);
+ if (signature != NCPIP_RQST && signature != NCPIP_RPLY)
+ return tvb_length_remaining(tvb, offset);
+
+ /*
+ * Get the length of the NCP-over-TCP packet. Strip off the "has
+ * signature" flag.
+ */
+
+ return tvb_get_ntohl(tvb, offset + 4) & 0x7fffffff;
}
static void
@@ -1035,15 +1032,14 @@ proto_register_ncp(void)
"Packet Burst File Handle", HFILL }},
{ &hf_ncp_burst_reserved,
{ "Reserved", "ncp.burst_reserved",
- FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
-
+ FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }}
};
static gint *ett[] = {
&ett_ncp,
&ett_ncp_system_flags,
&ett_nds,
&ett_nds_segments,
- &ett_nds_segment,
+ &ett_nds_segment
};
module_t *ncp_module;
@@ -1107,3 +1103,17 @@ proto_reg_handoff_ncp(void)
data_handle = find_dissector("data");
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=4 expandtab:
+ * :indentSize=4:tabSize=4:noTabs=true:
+ */
+