aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-rtmpt.c
diff options
context:
space:
mode:
authorBill Meier <wmeier@newsguy.com>2013-12-12 19:59:23 +0000
committerBill Meier <wmeier@newsguy.com>2013-12-12 19:59:23 +0000
commitbacfeda9e90297f40996d62c3af2fda6d3e6ce74 (patch)
tree0abd0c0ffbd8822e7d04a0dfc10bbc377850dfc5 /epan/dissectors/packet-rtmpt.c
parent0b2dc7041fe8209d6adf95ef6c0513776ef0988a (diff)
Move proto_reg_handoff...() to the file end as per convevntion;
Reformat certain lines to use a consistent style; tabs --> spaces (to match the editor modelines); Rework some whitespace; svn path=/trunk/; revision=53974
Diffstat (limited to 'epan/dissectors/packet-rtmpt.c')
-rw-r--r--epan/dissectors/packet-rtmpt.c471
1 files changed, 255 insertions, 216 deletions
diff --git a/epan/dissectors/packet-rtmpt.c b/epan/dissectors/packet-rtmpt.c
index c68daa1690..04925f9569 100644
--- a/epan/dissectors/packet-rtmpt.c
+++ b/epan/dissectors/packet-rtmpt.c
@@ -465,7 +465,7 @@ typedef struct rtmpt_packet {
guint8 fmt; /* byte 0 */
guint32 id; /* byte 0 */
- /* Chunk Message Header (offsets assume bhlen==1) */
+ /* Chunk Message Header (offsets assume bhlen == 1) */
guint32 ts; /* bytes 1-3, or from ETS @ mhlen-4 if -1 */
guint32 len; /* bytes 4-6 */
guint8 cmd; /* byte 7 */
@@ -563,19 +563,22 @@ rtmpt_get_amf_length(tvbuff_t *tvb, gint offset)
gint itemlen = 0;
gint rv = 0;
- while (rv==0 || depth>0) {
+ while (rv == 0 || depth > 0) {
- if (depth>0) {
- if (remain-rv<2) return remain;
+ if (depth > 0) {
+ if (remain-rv < 2)
+ return remain;
itemlen = tvb_get_ntohs(tvb, offset+rv) + 2;
- if (remain-rv<itemlen+1) return remain;
+ if (remain-rv<itemlen+1)
+ return remain;
rv += itemlen;
}
- if (remain-rv<1) return remain;
+ if (remain-rv < 1)
+ return remain;
iObjType = tvb_get_guint8(tvb, offset+rv);
- if (depth>0 && itemlen==2 && iObjType==AMF0_END_OF_OBJECT) {
+ if (depth > 0 && itemlen == 2 && iObjType == AMF0_END_OF_OBJECT) {
rv++;
depth--;
continue;
@@ -589,7 +592,8 @@ rtmpt_get_amf_length(tvbuff_t *tvb, gint offset)
itemlen = 2;
break;
case AMF0_STRING:
- if (remain-rv<3) return remain;
+ if (remain-rv < 3)
+ return remain;
itemlen = tvb_get_ntohs(tvb, offset+rv+1) + 3;
break;
case AMF0_NULL:
@@ -602,7 +606,8 @@ rtmpt_get_amf_length(tvbuff_t *tvb, gint offset)
break;
case AMF0_LONG_STRING:
case AMF0_XML:
- if (remain-rv<5) return remain;
+ if (remain-rv < 5)
+ return remain;
itemlen = tvb_get_ntohl(tvb, offset+rv+1) + 5;
break;
case AMF0_INT64:
@@ -620,7 +625,8 @@ rtmpt_get_amf_length(tvbuff_t *tvb, gint offset)
return remain;
}
- if (remain-rv<itemlen) return remain;
+ if (remain-rv < itemlen)
+ return remain;
rv += itemlen;
}
@@ -628,43 +634,46 @@ rtmpt_get_amf_length(tvbuff_t *tvb, gint offset)
return rv;
}
-static gchar*
+static gchar *
rtmpt_get_amf_param(tvbuff_t *tvb, gint offset, gint param, const gchar *prop)
{
guint32 remain = tvb_length_remaining(tvb, offset);
guint32 itemlen;
guint32 iStringLength;
- while (remain>0 && param>0) {
+ while (remain > 0 && param > 0) {
itemlen = rtmpt_get_amf_length(tvb, offset);
offset += itemlen;
remain -= itemlen;
param--;
}
- if (remain>0 && param==0) {
+ if (remain > 0 && param == 0) {
guint8 iObjType = tvb_get_guint8(tvb, offset);
- if (!prop && iObjType==AMF0_STRING && remain>=3) {
+ if (!prop && iObjType == AMF0_STRING && remain >= 3) {
iStringLength = tvb_get_ntohs(tvb, offset+1);
- if (remain>=iStringLength+3) {
+ if (remain >= iStringLength+3) {
return tvb_get_string(wmem_packet_scope(), tvb, offset+3, iStringLength);
}
}
- if (prop && iObjType==AMF0_OBJECT) {
+ if (prop && iObjType == AMF0_OBJECT) {
offset++;
remain--;
- while (remain>2) {
+ while (remain > 2) {
guint32 iPropLength = tvb_get_ntohs(tvb, offset);
- if (remain<2+iPropLength+3) break;
+ if (remain < 2+iPropLength+3)
+ break;
- if (tvb_strneql(tvb, offset+2, prop, strlen(prop))==0) {
- if (tvb_get_guint8(tvb, offset+2+iPropLength)!=AMF0_STRING) break;
+ if (tvb_strneql(tvb, offset+2, prop, strlen(prop)) == 0) {
+ if (tvb_get_guint8(tvb, offset+2+iPropLength) != AMF0_STRING)
+ break;
iStringLength = tvb_get_ntohs(tvb, offset+2+iPropLength+1);
- if (remain<2+iPropLength+3+iStringLength) break;
+ if (remain < 2+iPropLength+3+iStringLength)
+ break;
return tvb_get_string(wmem_packet_scope(), tvb, offset+2+iPropLength+3, iStringLength);
}
@@ -684,15 +693,16 @@ rtmpt_get_amf_txid(tvbuff_t *tvb, gint offset)
{
guint32 remain = tvb_length_remaining(tvb, offset);
- if (remain>0) {
+ if (remain > 0) {
guint32 itemlen = rtmpt_get_amf_length(tvb, offset);
- if (remain<itemlen) return 0;
+ if (remain<itemlen)
+ return 0;
offset += itemlen;
remain -= itemlen;
}
- if (remain>=9) {
+ if (remain >= 9) {
guint8 iObjType = tvb_get_guint8(tvb, offset);
- if (iObjType==AMF0_NUMBER) {
+ if (iObjType == AMF0_NUMBER) {
return (guint32)tvb_get_ntohieee_double(tvb, offset+1);
}
}
@@ -703,20 +713,20 @@ rtmpt_get_amf_txid(tvbuff_t *tvb, gint offset)
/* Generate a useful description for various packet types */
-static gchar*
+static gchar *
rtmpt_get_packet_desc(tvbuff_t *tvb, guint32 offset, guint32 remain, rtmpt_conv_t *rconv, int cdir, rtmpt_packet_t *tp, gint *deschasopcode)
{
- if (tp->cmd==RTMPT_TYPE_CHUNK_SIZE || tp->cmd==RTMPT_TYPE_ABORT_MESSAGE ||
- tp->cmd==RTMPT_TYPE_ACKNOWLEDGEMENT || tp->cmd==RTMPT_TYPE_WINDOW) {
- if (tp->len>=4 && remain>=4) {
+ if (tp->cmd == RTMPT_TYPE_CHUNK_SIZE || tp->cmd == RTMPT_TYPE_ABORT_MESSAGE ||
+ tp->cmd == RTMPT_TYPE_ACKNOWLEDGEMENT || tp->cmd == RTMPT_TYPE_WINDOW) {
+ if (tp->len >= 4 && remain >= 4) {
*deschasopcode = TRUE;
return wmem_strdup_printf(wmem_packet_scope(), "%s %d",
val_to_str(tp->cmd, rtmpt_opcode_vals, "Unknown (0x%01x)"),
tvb_get_ntohl(tvb, offset));
}
- } else if (tp->cmd==RTMPT_TYPE_PEER_BANDWIDTH) {
- if (tp->len>=5 && remain>=5) {
+ } else if (tp->cmd == RTMPT_TYPE_PEER_BANDWIDTH) {
+ if (tp->len >= 5 && remain >= 5) {
*deschasopcode = TRUE;
return wmem_strdup_printf(wmem_packet_scope(), "%s %d,%s",
val_to_str(tp->cmd, rtmpt_opcode_vals, "Unknown (0x%01x)"),
@@ -724,27 +734,28 @@ rtmpt_get_packet_desc(tvbuff_t *tvb, guint32 offset, guint32 remain, rtmpt_conv_
val_to_str(tvb_get_guint8(tvb, offset+4), rtmpt_limit_vals, "Unknown (%d)"));
}
- } else if (tp->cmd==RTMPT_TYPE_UCM) {
+ } else if (tp->cmd == RTMPT_TYPE_UCM) {
guint16 iUCM = -1;
const gchar *sFunc = NULL;
const gchar *sParam = "";
- if (tp->len<2 || remain<2) return NULL;
+ if (tp->len < 2 || remain < 2)
+ return NULL;
iUCM = tvb_get_ntohs(tvb, offset);
sFunc = try_val_to_str(iUCM, rtmpt_ucm_vals);
- if (sFunc==NULL) {
+ if (sFunc == NULL) {
*deschasopcode = TRUE;
sFunc = wmem_strdup_printf(wmem_packet_scope(), "User Control Message 0x%01x", iUCM);
}
- if (iUCM==RTMPT_UCM_STREAM_BEGIN || iUCM==RTMPT_UCM_STREAM_EOF ||
- iUCM==RTMPT_UCM_STREAM_DRY || iUCM==RTMPT_UCM_STREAM_ISRECORDED) {
- if (tp->len>=6 && remain>=6) {
+ if (iUCM == RTMPT_UCM_STREAM_BEGIN || iUCM == RTMPT_UCM_STREAM_EOF ||
+ iUCM == RTMPT_UCM_STREAM_DRY || iUCM == RTMPT_UCM_STREAM_ISRECORDED) {
+ if (tp->len >= 6 && remain >= 6) {
sParam = wmem_strdup_printf(wmem_packet_scope(), " %d", tvb_get_ntohl(tvb, offset+2));
}
- } else if (iUCM==RTMPT_UCM_SET_BUFFER) {
- if (tp->len>=10 && remain>=10) {
+ } else if (iUCM == RTMPT_UCM_SET_BUFFER) {
+ if (tp->len >= 10 && remain >= 10) {
sParam = wmem_strdup_printf(wmem_packet_scope(), " %d,%dms",
tvb_get_ntohl(tvb, offset+2),
tvb_get_ntohl(tvb, offset+6));
@@ -753,52 +764,52 @@ rtmpt_get_packet_desc(tvbuff_t *tvb, guint32 offset, guint32 remain, rtmpt_conv_
return wmem_strdup_printf(wmem_packet_scope(), "%s%s", sFunc, sParam);
- } else if (tp->cmd==RTMPT_TYPE_COMMAND_AMF0 || tp->cmd==RTMPT_TYPE_COMMAND_AMF3 ||
- tp->cmd==RTMPT_TYPE_DATA_AMF0 || tp->cmd==RTMPT_TYPE_DATA_AMF3) {
+ } else if (tp->cmd == RTMPT_TYPE_COMMAND_AMF0 || tp->cmd == RTMPT_TYPE_COMMAND_AMF3 ||
+ tp->cmd == RTMPT_TYPE_DATA_AMF0 || tp->cmd == RTMPT_TYPE_DATA_AMF3) {
guint32 slen = 0;
guint32 soff = 0;
gchar *sFunc = NULL;
gchar *sParam = NULL;
- if (tp->cmd==RTMPT_TYPE_COMMAND_AMF3 || tp->cmd==RTMPT_TYPE_DATA_AMF3) {
+ if (tp->cmd == RTMPT_TYPE_COMMAND_AMF3 || tp->cmd == RTMPT_TYPE_DATA_AMF3) {
soff = 1;
}
- if (tp->len>=3+soff && remain>=3+soff) {
+ if (tp->len >= 3+soff && remain >= 3+soff) {
slen = tvb_get_ntohs(tvb, offset+1+soff);
}
- if (slen>0) {
+ if (slen > 0) {
sFunc = tvb_get_string(wmem_packet_scope(), tvb, offset+3+soff, slen);
RTMPT_DEBUG("got function call '%s'\n", sFunc);
- if (strcmp(sFunc, "connect")==0) {
+ if (strcmp(sFunc, "connect") == 0) {
sParam = rtmpt_get_amf_param(tvb, offset+soff, 2, "app");
- } else if (strcmp(sFunc, "play")==0) {
+ } else if (strcmp(sFunc, "play") == 0) {
sParam = rtmpt_get_amf_param(tvb, offset+soff, 3, NULL);
- } else if (strcmp(sFunc, "play2")==0) {
+ } else if (strcmp(sFunc, "play2") == 0) {
sParam = rtmpt_get_amf_param(tvb, offset+soff, 3, "streamName");
- } else if (strcmp(sFunc, "releaseStream")==0) {
+ } else if (strcmp(sFunc, "releaseStream") == 0) {
sParam = rtmpt_get_amf_param(tvb, offset+soff, 3, NULL);
- } else if (strcmp(sFunc, "FCPublish")==0) {
+ } else if (strcmp(sFunc, "FCPublish") == 0) {
sParam = rtmpt_get_amf_param(tvb, offset+soff, 3, NULL);
- } else if (strcmp(sFunc, "publish")==0) {
+ } else if (strcmp(sFunc, "publish") == 0) {
sParam = rtmpt_get_amf_param(tvb, offset+soff, 3, NULL);
- } else if (strcmp(sFunc, "onStatus")==0) {
- if (tp->cmd==RTMPT_TYPE_COMMAND_AMF0 || tp->cmd==RTMPT_TYPE_COMMAND_AMF3) {
+ } else if (strcmp(sFunc, "onStatus") == 0) {
+ if (tp->cmd == RTMPT_TYPE_COMMAND_AMF0 || tp->cmd == RTMPT_TYPE_COMMAND_AMF3) {
sParam = rtmpt_get_amf_param(tvb, offset+soff, 3, "code");
} else {
sParam = rtmpt_get_amf_param(tvb, offset+soff, 1, "code");
}
- } else if (strcmp(sFunc, "onPlayStatus")==0) {
+ } else if (strcmp(sFunc, "onPlayStatus") == 0) {
sParam = rtmpt_get_amf_param(tvb, offset+soff, 1, "code");
- } else if (strcmp(sFunc, "_result")==0) {
+ } else if (strcmp(sFunc, "_result") == 0) {
sParam = rtmpt_get_amf_param(tvb, offset+soff, 3, "code");
tp->isresponse = TRUE;
- } else if (strcmp(sFunc, "_error")==0) {
+ } else if (strcmp(sFunc, "_error") == 0) {
sParam = rtmpt_get_amf_param(tvb, offset+soff, 3, "code");
tp->isresponse = TRUE;
}
- if (tp->txid!=0 && tp->otherframe==0) {
+ if (tp->txid != 0 && tp->otherframe == 0) {
tp->otherframe = GPOINTER_TO_INT(wmem_tree_lookup32(rconv->txids[cdir^1], tp->txid));
if (tp->otherframe) {
RTMPT_DEBUG("got otherframe=%d\n", tp->otherframe);
@@ -1066,7 +1077,7 @@ dissect_amf0_value_type(tvbuff_t *tvb, gint offset, proto_tree *tree, gboolean *
iValueOffset += 4;
iStringValue = tvb_get_string_enc(wmem_packet_scope(), tvb, iValueOffset, iStringLength, ENC_UTF_8|ENC_NA);
if (iStringLength != 0)
- proto_tree_add_string(val_tree, (iObjType==AMF0_XML) ? hf_amf_xml_doc : hf_amf_longstring, tvb, iValueOffset, iStringLength, iStringValue);
+ proto_tree_add_string(val_tree, (iObjType == AMF0_XML) ? hf_amf_xml_doc : hf_amf_longstring, tvb, iValueOffset, iStringLength, iStringValue);
iValueOffset += iStringLength;
proto_item_append_text(ti, " '%s'", iStringValue);
if (parent_ti != NULL)
@@ -1110,11 +1121,11 @@ dissect_amf0_value_type(tvbuff_t *tvb, gint offset, proto_tree *tree, gboolean *
static guint32
amf_get_u29(tvbuff_t *tvb, int offset, guint *lenp)
{
- guint len = 0;
- guint8 iByte;
- guint32 iValue;
+ guint len = 0;
+ guint8 iByte;
+ guint32 iValue;
- iByte = tvb_get_guint8(tvb, offset);
+ iByte = tvb_get_guint8(tvb, offset);
iValue = (iByte & 0x7F);
offset++;
len++;
@@ -1430,7 +1441,7 @@ dissect_amf3_value_type(tvbuff_t *tvb, gint offset, proto_tree *tree, proto_item
for (i = 0; i < iTraitCount; i++)
iValueOffset = dissect_amf3_value_type(tvb, iValueOffset, traits_tree, NULL);
if (iTypeIsDynamic) {
- for (;;) {
+ for (;;) {
/* Fetch the name */
iIntegerValue = amf_get_u29(tvb, iValueOffset, &iValueLength);
if (iIntegerValue & 0x00000001) {
@@ -1461,7 +1472,7 @@ dissect_amf3_value_type(tvbuff_t *tvb, gint offset, proto_tree *tree, proto_item
subval_tree = proto_item_add_subtree(subval_ti, ett_amf_array_element);
proto_tree_add_uint(subval_tree, hf_amf_string_reference, tvb, iValueOffset, iValueLength, iIntegerValue >> 1);
iValueOffset += iValueLength;
- }
+ }
/* Fetch the value */
iValueOffset = dissect_amf3_value_type(tvb, iValueOffset, subval_tree, subval_ti);
@@ -1623,14 +1634,14 @@ dissect_rtmpt_body_aggregate(tvbuff_t *tvb, gint offset, proto_tree *rtmpt_tree)
while (tvb_length_remaining(tvb, offset) > 0) {
guint8 iTagType;
- guint iDataSize;
+ guint iDataSize;
- iTagType = tvb_get_guint8(tvb, offset + 0);
+ iTagType = tvb_get_guint8(tvb, offset + 0);
iDataSize = tvb_get_ntoh24(tvb, offset + 1);
- tag_item = proto_tree_add_text(rtmpt_tree, tvb, offset, 11+iDataSize+4, "%s",
+ tag_item = proto_tree_add_text(rtmpt_tree, tvb, offset, 11+iDataSize+4, "%s",
val_to_str_const(iTagType, rtmpt_tag_vals, "Unknown Tag"));
- tag_tree = proto_item_add_subtree(tag_item, ett_rtmpt_tag);
+ tag_tree = proto_item_add_subtree(tag_item, ett_rtmpt_tag);
proto_tree_add_item(tag_tree, hf_rtmpt_tag_type, tvb, offset+0, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tag_tree, hf_rtmpt_tag_datasize, tvb, offset+1, 3, ENC_BIG_ENDIAN);
proto_tree_add_item(tag_tree, hf_rtmpt_tag_timestamp, tvb, offset+4, 3, ENC_BIG_ENDIAN);
@@ -1664,16 +1675,16 @@ dissect_rtmpt_body_aggregate(tvbuff_t *tvb, gint offset, proto_tree *rtmpt_tree)
static void
dissect_rtmpt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rtmpt_conv_t *rconv, int cdir, rtmpt_packet_t *tp)
{
- proto_tree *rtmpt_tree = NULL;
- proto_tree *rtmptroot_tree = NULL;
- proto_item *ti = NULL;
- gint offset = 0;
+ proto_tree *rtmpt_tree = NULL;
+ proto_tree *rtmptroot_tree = NULL;
+ proto_item *ti = NULL;
+ gint offset = 0;
- gchar *sDesc = NULL;
- gint deschasopcode = FALSE;
- gboolean haveETS = FALSE;
- guint32 iBodyOffset = 0;
- guint32 iBodyRemain = 0;
+ gchar *sDesc = NULL;
+ gint deschasopcode = FALSE;
+ gboolean haveETS = FALSE;
+ guint32 iBodyOffset = 0;
+ guint32 iBodyRemain = 0;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "RTMP");
@@ -1686,32 +1697,32 @@ dissect_rtmpt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rtmpt_conv_t
if (tvb_length_remaining(tvb, offset) < 1) return;
- if (tp->id<=RTMPT_ID_MAX) {
- if (tp->fmt<3
- && tvb_length_remaining(tvb, offset)>=tp->bhlen+3
- && tvb_get_ntoh24(tvb, offset+tp->bhlen)==0xffffff) {
+ if (tp->id <= RTMPT_ID_MAX) {
+ if (tp->fmt < 3
+ && tvb_length_remaining(tvb, offset) >= tp->bhlen+3
+ && tvb_get_ntoh24(tvb, offset+tp->bhlen) == 0xffffff) {
haveETS = TRUE;
}
iBodyOffset = offset + tp->bhlen + tp->mhlen;
iBodyRemain = tvb_length_remaining(tvb, iBodyOffset);
- if (tp->cmd==RTMPT_TYPE_CHUNK_SIZE && tp->len>=4 && iBodyRemain>=4) {
+ if (tp->cmd == RTMPT_TYPE_CHUNK_SIZE && tp->len >= 4 && iBodyRemain >= 4) {
guint32 newchunksize = tvb_get_ntohl(tvb, iBodyOffset);
- if (newchunksize<rtmpt_max_packet_size) {
+ if (newchunksize < rtmpt_max_packet_size) {
wmem_tree_insert32(rconv->chunksize[cdir], tp->lastseq, GINT_TO_POINTER(newchunksize));
}
}
if (!PINFO_FD_VISITED(pinfo)) {
- if (tp->cmd==RTMPT_TYPE_COMMAND_AMF0 || tp->cmd==RTMPT_TYPE_COMMAND_AMF3 ||
- tp->cmd==RTMPT_TYPE_DATA_AMF0 || tp->cmd==RTMPT_TYPE_DATA_AMF3) {
+ if (tp->cmd == RTMPT_TYPE_COMMAND_AMF0 || tp->cmd == RTMPT_TYPE_COMMAND_AMF3 ||
+ tp->cmd == RTMPT_TYPE_DATA_AMF0 || tp->cmd == RTMPT_TYPE_DATA_AMF3) {
guint32 soff = 0;
- if (tp->cmd==RTMPT_TYPE_COMMAND_AMF3 || tp->cmd==RTMPT_TYPE_DATA_AMF3) {
+ if (tp->cmd == RTMPT_TYPE_COMMAND_AMF3 || tp->cmd == RTMPT_TYPE_DATA_AMF3) {
soff = 1;
}
tp->txid = rtmpt_get_amf_txid(tvb, iBodyOffset+soff);
- if (tp->txid!=0) {
+ if (tp->txid != 0) {
RTMPT_DEBUG("got txid=%d\n", tp->txid);
wmem_tree_insert32(rconv->txids[cdir], tp->txid, GINT_TO_POINTER(pinfo->fd->num));
}
@@ -1719,7 +1730,7 @@ dissect_rtmpt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rtmpt_conv_t
}
}
- if (tree && tp->id<=RTMPT_ID_MAX)
+ if (tree && tp->id <= RTMPT_ID_MAX)
{
sDesc = rtmpt_get_packet_desc(tvb, iBodyOffset, iBodyRemain, rconv, cdir, tp, &deschasopcode);
}
@@ -1741,7 +1752,7 @@ dissect_rtmpt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rtmpt_conv_t
{
ti = proto_tree_add_item(tree, proto_rtmpt, tvb, offset, -1, ENC_NA);
- if (tp->id>RTMPT_ID_MAX) {
+ if (tp->id > RTMPT_ID_MAX) {
/* Dissect handshake */
proto_item_append_text(ti, " (%s)",
val_to_str(tp->id, rtmpt_handshake_vals, "Unknown (0x%01x)"));
@@ -1781,7 +1792,7 @@ dissect_rtmpt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rtmpt_conv_t
rtmptroot_tree = proto_item_add_subtree(ti, ett_rtmpt);
/* Function call/response matching */
- if (tp->otherframe!=0) {
+ if (tp->otherframe != 0) {
proto_tree_add_uint(rtmptroot_tree,
tp->isresponse ? hf_rtmpt_function_response : hf_rtmpt_function_call,
tvb, offset, tp->bhlen+tp->mhlen+tp->len,
@@ -1796,7 +1807,7 @@ dissect_rtmpt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rtmpt_conv_t
if (tp->fmt <= 3) proto_tree_add_item(rtmpt_tree, hf_rtmpt_header_format, tvb, offset + 0, 1, ENC_BIG_ENDIAN);
if (tp->fmt <= 3) proto_tree_add_item(rtmpt_tree, hf_rtmpt_header_csid, tvb, offset + 0, tp->bhlen, ENC_BIG_ENDIAN);
if (tp->fmt <= 2) {
- if (tp->fmt>0) {
+ if (tp->fmt > 0) {
proto_tree_add_item(rtmpt_tree, hf_rtmpt_header_timestamp_delta, tvb, offset + tp->bhlen, 3, ENC_BIG_ENDIAN);
} else {
proto_tree_add_item(rtmpt_tree, hf_rtmpt_header_timestamp, tvb, offset + tp->bhlen, 3, ENC_BIG_ENDIAN);
@@ -1805,7 +1816,7 @@ dissect_rtmpt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rtmpt_conv_t
proto_tree_add_item(rtmpt_tree, hf_rtmpt_header_ets, tvb, offset + tp->bhlen + tp->mhlen - 4, 4, ENC_BIG_ENDIAN);
}
}
- if ((tp->fmt>0 && !haveETS) || tp->fmt==3) {
+ if ((tp->fmt>0 && !haveETS) || tp->fmt == 3) {
proto_tree_add_text(rtmpt_tree, tvb, offset + tp->bhlen, 0, "Timestamp: %d (calculated)", tp->ts);
}
if (tp->fmt <= 1) proto_tree_add_item(rtmpt_tree, hf_rtmpt_header_body_size, tvb, offset + tp->bhlen + 3, 3, ENC_BIG_ENDIAN);
@@ -1813,7 +1824,7 @@ dissect_rtmpt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rtmpt_conv_t
if (tp->fmt <= 0) proto_tree_add_item(rtmpt_tree, hf_rtmpt_header_streamid, tvb, offset + tp->bhlen + 7, 4, ENC_LITTLE_ENDIAN);
/* Dissect body */
- if (tp->len==0) return;
+ if (tp->len == 0) return;
offset = iBodyOffset;
ti = proto_tree_add_text(rtmptroot_tree, tvb, offset, -1, RTMPT_TEXT_RTMP_BODY);
@@ -1854,29 +1865,30 @@ dissect_rtmpt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rtmpt_conv_t
static void
dissect_rtmpt_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rtmpt_conv_t *rconv, int cdir, guint32 seq, guint32 lastackseq)
{
- int offset = 0;
- int remain;
- int want;
+ int offset = 0;
+ int remain;
+ int want;
- guint8 header_type;
- int basic_hlen;
- int message_hlen;
+ guint8 header_type;
+ int basic_hlen;
+ int message_hlen;
guint32 id;
- guint32 ts = 0;
- guint32 tsd = 0;
- int body_len;
- guint8 cmd;
+ guint32 ts = 0;
+ guint32 tsd = 0;
+ int body_len;
+ guint8 cmd;
guint32 src;
- int chunk_size;
+ int chunk_size;
- rtmpt_frag_t *tf;
- rtmpt_id_t *ti;
+ rtmpt_frag_t *tf;
+ rtmpt_id_t *ti;
rtmpt_packet_t *tp;
- tvbuff_t *pktbuf;
+ tvbuff_t *pktbuf;
remain = tvb_length(tvb);
- if (!remain) return;
+ if (!remain)
+ return;
RTMPT_DEBUG("Segment: cdir=%d seq=%d-%d\n", cdir, seq, seq+remain-1);
@@ -1890,14 +1902,14 @@ dissect_rtmpt_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rtmpt_
wmem_stack_push(packets, 0);
tp = (rtmpt_packet_t *)wmem_tree_lookup32_le(rconv->packets[cdir], seq+remain-1);
- while (tp && tp->lastseq>=seq) {
+ while (tp && tp->lastseq >= seq) {
wmem_stack_push(packets, tp);
tp = (rtmpt_packet_t *)wmem_tree_lookup32_le(rconv->packets[cdir], tp->lastseq-1);
}
/* Dissect the generated list in reverse order (beginning to end) */
- while ((tp=(rtmpt_packet_t *)wmem_stack_pop(packets))!=NULL) {
+ while ((tp=(rtmpt_packet_t *)wmem_stack_pop(packets)) != NULL) {
if (tp->resident) {
pktbuf = tvb_new_child_real_data(tvb, tp->data.p, tp->have, tp->have);
add_new_data_source(pinfo, pktbuf, "Unchunked RTMP");
@@ -1917,17 +1929,19 @@ dissect_rtmpt_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rtmpt_
/* Check for outstanding fragmented headers/chunks first */
- if (offset==0) {
+ if (offset == 0) {
tf = (rtmpt_frag_t *)wmem_tree_lookup32_le(rconv->frags[cdir], seq+offset-1);
if (tf) {
/* May need to reassemble cross-TCP-segment fragments */
RTMPT_DEBUG(" tf seq=%d lseq=%d h=%d l=%d\n", tf->seq, tf->lastseq, tf->have, tf->len);
- if (tf->have>=tf->len || seq+offset<tf->seq || seq+offset>tf->lastseq+tf->len-tf->have) {
+ if (tf->have >= tf->len || seq+offset < tf->seq || seq+offset > tf->lastseq+tf->len-tf->have) {
tf = NULL;
} else if (!tf->ishdr) {
ti = (rtmpt_id_t *)wmem_tree_lookup32(rconv->ids[cdir], tf->saved.id);
- if (ti) tp = (rtmpt_packet_t *)wmem_tree_lookup32_le(ti->packets, seq+offset-1);
+ if (ti) {
+ tp = (rtmpt_packet_t *)wmem_tree_lookup32_le(ti->packets, seq+offset-1);
+ }
if (tp && tp->chunkwant) {
goto unchunk;
}
@@ -1940,7 +1954,8 @@ dissect_rtmpt_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rtmpt_
/* The preceding segment contained an incomplete chunk header */
want = tf->len - tf->have;
- if (remain<want) want = remain;
+ if (remain<want)
+ want = remain;
tvb_memcpy(tvb, tf->saved.d+tf->have, offset, want);
@@ -1948,8 +1963,8 @@ dissect_rtmpt_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rtmpt_
header_type = (id>>6) & 3;
basic_hlen = rtmpt_basic_header_length(id);
- if (header_type<3 && tf->have<basic_hlen+3 && tf->have+want>=basic_hlen+3) {
- if (pntoh24(tf->saved.d+basic_hlen)==0xffffff) {
+ if ((header_type < 3) && (tf->have < (basic_hlen+3)) && (tf->have+want >= (basic_hlen+3))) {
+ if (pntoh24(tf->saved.d+basic_hlen) == 0xffffff) {
tf->len += 4;
}
}
@@ -1959,7 +1974,7 @@ dissect_rtmpt_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rtmpt_
remain -= want;
offset += want;
- if (tf->have<tf->len) {
+ if (tf->have < tf->len) {
return;
}
}
@@ -1970,12 +1985,12 @@ dissect_rtmpt_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rtmpt_
/* No preceeding data, get header data starting at current position */
id = tvb_get_guint8(tvb, offset);
- if (id==RTMPT_MAGIC && seq+offset==RTMPT_HANDSHAKE_OFFSET_1) {
+ if (id == RTMPT_MAGIC && seq+offset == RTMPT_HANDSHAKE_OFFSET_1) {
header_type = 4;
basic_hlen = 1;
message_hlen = 0;
- id = lastackseq==1 ? RTMPT_TYPE_HANDSHAKE_1 : RTMPT_TYPE_HANDSHAKE_2;
- } else if (seq+offset==RTMPT_HANDSHAKE_OFFSET_2) {
+ id = lastackseq == 1 ? RTMPT_TYPE_HANDSHAKE_1 : RTMPT_TYPE_HANDSHAKE_2;
+ } else if (seq+offset == RTMPT_HANDSHAKE_OFFSET_2) {
header_type = 4;
basic_hlen = 0;
message_hlen = 0;
@@ -1985,13 +2000,13 @@ dissect_rtmpt_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rtmpt_
basic_hlen = rtmpt_basic_header_length(id);
message_hlen = rtmpt_message_header_length(id);
- if (header_type<3 && remain>=basic_hlen+3) {
- if (tvb_get_ntoh24(tvb, offset+basic_hlen)==0xffffff) {
+ if ((header_type < 3) && (remain >= (basic_hlen+3))) {
+ if (tvb_get_ntoh24(tvb, offset+basic_hlen) == 0xffffff) {
message_hlen += 4;
}
}
- if (remain<basic_hlen+message_hlen) {
+ if (remain < (basic_hlen+message_hlen)) {
/* Ran out of packet mid-header, save and try again next time */
tf = wmem_new(wmem_file_scope(), rtmpt_frag_t);
tf->ishdr = 1;
@@ -2005,8 +2020,10 @@ dissect_rtmpt_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rtmpt_
}
id = id & 0x3f;
- if (id==0) id = tvb_get_guint8(tvb, offset+1) + 64;
- else if (id==1) id = tvb_get_letohs(tvb, offset+1) + 64;
+ if (id == 0)
+ id = tvb_get_guint8(tvb, offset+1) + 64;
+ else if (id == 1)
+ id = tvb_get_letohs(tvb, offset+1) + 64;
}
} else {
@@ -2017,42 +2034,58 @@ dissect_rtmpt_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rtmpt_
message_hlen = tf->len - basic_hlen;
id = id & 0x3f;
- if (id==0) id = tf->saved.d[1] + 64;
- else if (id==1) id = pletoh16(tf->saved.d+1) + 64;
+ if (id == 0)
+ id = tf->saved.d[1] + 64;
+ else if (id == 1)
+ id = pletoh16(tf->saved.d+1) + 64;
}
/* Calculate header values, defaulting from previous packets with same id */
- if (id<=RTMPT_ID_MAX) ti = (rtmpt_id_t *)wmem_tree_lookup32(rconv->ids[cdir], id);
- if (ti) tp = (rtmpt_packet_t *)wmem_tree_lookup32_le(ti->packets, seq+offset-1);
+ if (id <= RTMPT_ID_MAX)
+ ti = (rtmpt_id_t *)wmem_tree_lookup32(rconv->ids[cdir], id);
+ if (ti)
+ tp = (rtmpt_packet_t *)wmem_tree_lookup32_le(ti->packets, seq+offset-1);
- if (header_type==0) src = tf ? pntoh32(tf->saved.d+basic_hlen+7) : tvb_get_ntohl(tvb, offset+basic_hlen+7);
- else if (ti) src = ti->src;
+ if (header_type == 0)
+ src = tf ? pntoh32(tf->saved.d+basic_hlen+7) : tvb_get_ntohl(tvb, offset+basic_hlen+7);
+ else if (ti)
+ src = ti->src;
else src = 0;
- if (header_type<2) cmd = tf ? tf->saved.d[basic_hlen+6] : tvb_get_guint8(tvb, offset+basic_hlen+6);
- else if (ti) cmd = ti->cmd;
- else cmd = 0;
+ if (header_type < 2)
+ cmd = tf ? tf->saved.d[basic_hlen+6] : tvb_get_guint8(tvb, offset+basic_hlen+6);
+ else if (ti)
+ cmd = ti->cmd;
+ else
+ cmd = 0;
/* Calculate chunk_size now as a last-resort default payload length */
- if (id>RTMPT_ID_MAX) {
- if (id==RTMPT_TYPE_HANDSHAKE_1) chunk_size = body_len = 1536;
- else if (id==RTMPT_TYPE_HANDSHAKE_2) chunk_size = body_len = 3072;
- else /* if (id==RTMPT_TYPE_HANDSHAKE_3) */ chunk_size = body_len = 1536;
+ if (id > RTMPT_ID_MAX) {
+ if (id == RTMPT_TYPE_HANDSHAKE_1)
+ chunk_size = body_len = 1536;
+ else if (id == RTMPT_TYPE_HANDSHAKE_2)
+ chunk_size = body_len = 3072;
+ else /* if (id == RTMPT_TYPE_HANDSHAKE_3) */
+ chunk_size = body_len = 1536;
} else {
chunk_size = GPOINTER_TO_INT(wmem_tree_lookup32_le(rconv->chunksize[cdir], seq+offset-1));
- if (!chunk_size) chunk_size = RTMPT_DEFAULT_CHUNK_SIZE;
+ if (!chunk_size)
+ chunk_size = RTMPT_DEFAULT_CHUNK_SIZE;
- if (header_type<2) body_len = tf ? pntoh24(tf->saved.d+basic_hlen+3) : tvb_get_ntoh24(tvb, offset+basic_hlen+3);
- else if (ti) body_len = ti->len;
- else body_len = chunk_size;
+ if (header_type < 2)
+ body_len = tf ? pntoh24(tf->saved.d+basic_hlen+3) : tvb_get_ntoh24(tvb, offset+basic_hlen+3);
+ else if (ti)
+ body_len = ti->len;
+ else
+ body_len = chunk_size;
- if (body_len>(gint)rtmpt_max_packet_size) {
+ if (body_len > (gint)rtmpt_max_packet_size) {
return;
}
}
- if (!ti || !tp || header_type<3 || tp->have==tp->want || tp->chunkhave!=tp->chunkwant) {
+ if (!ti || !tp || header_type<3 || tp->have == tp->want || tp->chunkhave != tp->chunkwant) {
/* Start a new packet if:
* no previous packet with same id
* not a short 1-byte header
@@ -2066,52 +2099,54 @@ dissect_rtmpt_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rtmpt_
if (!ti) {
ti = wmem_new(wmem_file_scope(), rtmpt_id_t);
ti->packets = wmem_tree_new(wmem_file_scope());
- ti->ts = 0;
+ ti->ts = 0;
ti->tsd = 0;
wmem_tree_insert32(rconv->ids[cdir], id, ti);
}
- if (header_type==0) {
+ if (header_type == 0) {
ts = tf ? pntoh24(tf->saved.d+basic_hlen) : tvb_get_ntoh24(tvb, offset+basic_hlen);
- if (ts==0xffffff) {
+ if (ts == 0xffffff) {
ts = tf ? pntoh32(tf->saved.d+basic_hlen+11) : tvb_get_ntohl(tvb, offset+basic_hlen+11);
}
tsd = ts - ti->ts;
- } else if (header_type<3) {
+ } else if (header_type < 3) {
tsd = tf ? pntoh24(tf->saved.d+basic_hlen) : tvb_get_ntoh24(tvb, offset+basic_hlen);
- if (tsd==0xffffff) {
- ts = tf ? pntoh32(tf->saved.d+basic_hlen+message_hlen-4) : tvb_get_ntohl(tvb, offset+basic_hlen+message_hlen-4);
+ if (tsd == 0xffffff) {
+ ts = tf ? pntoh32(tf->saved.d+basic_hlen+message_hlen-4) : tvb_get_ntohl(tvb, offset+basic_hlen+message_hlen-4);
tsd = ti->tsd; /* questionable */
} else {
- ts = ti->ts + tsd;
+ ts = ti->ts + tsd;
}
} else {
- ts = ti->ts + ti->tsd;
+ ts = ti->ts + ti->tsd;
tsd = ti->tsd;
}
/* create a new packet structure */
- tp = wmem_new(wmem_file_scope(), rtmpt_packet_t);
- tp->seq = tp->lastseq = tf ? tf->seq : seq+offset;
- tp->have = 0;
- tp->want = basic_hlen + message_hlen + body_len;
- tp->chunkwant = 0;
- tp->chunkhave = 0;
- tp->bhlen = basic_hlen;
- tp->mhlen = message_hlen;
- tp->fmt = header_type;
- tp->id = id;
- tp->ts = ts;
- tp->len = body_len;
- if (id>RTMPT_ID_MAX) tp->cmd = id;
- else tp->cmd = cmd & 0x7f;
- tp->src = src;
- tp->txid = 0;
+ tp = wmem_new(wmem_file_scope(), rtmpt_packet_t);
+ tp->seq = tp->lastseq = tf ? tf->seq : seq+offset;
+ tp->have = 0;
+ tp->want = basic_hlen + message_hlen + body_len;
+ tp->chunkwant = 0;
+ tp->chunkhave = 0;
+ tp->bhlen = basic_hlen;
+ tp->mhlen = message_hlen;
+ tp->fmt = header_type;
+ tp->id = id;
+ tp->ts = ts;
+ tp->len = body_len;
+ if (id > RTMPT_ID_MAX)
+ tp->cmd = id;
+ else
+ tp->cmd = cmd & 0x7f;
+ tp->src = src;
+ tp->txid = 0;
tp->isresponse = FALSE;
tp->otherframe = 0;
/* Save the header information for future defaulting needs */
- ti->ts = ts;
+ ti->ts = ts;
ti->tsd = tsd;
ti->len = body_len;
ti->cmd = cmd;
@@ -2120,12 +2155,12 @@ dissect_rtmpt_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rtmpt_
/* store against the id only until unchunking is complete */
wmem_tree_insert32(ti->packets, tp->seq, tp);
- if (!tf && body_len<=chunk_size && tp->want<=remain) {
+ if (!tf && body_len <= chunk_size && tp->want <= remain) {
/* The easy case - a whole packet contiguous and fully within this segment */
- tp->resident = FALSE;
+ tp->resident = FALSE;
tp->data.offset = offset;
- tp->lastseq = seq+offset+tp->want-1;
- tp->have = tp->want;
+ tp->lastseq = seq+offset+tp->want-1;
+ tp->have = tp->want;
wmem_tree_insert32(rconv->packets[cdir], tp->lastseq, tp);
@@ -2152,7 +2187,7 @@ dissect_rtmpt_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rtmpt_
tp->lastseq = seq+offset-1;
tp->have = basic_hlen + message_hlen;
- if (tp->have==tp->want) {
+ if (tp->have == tp->want) {
wmem_tree_insert32(rconv->packets[cdir], tp->lastseq, tp);
pktbuf = tvb_new_child_real_data(tvb, tp->data.p, tp->have, tp->have);
@@ -2162,7 +2197,8 @@ dissect_rtmpt_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rtmpt_
}
tp->chunkwant = chunk_size;
- if (tp->chunkwant>tp->want-tp->have) tp->chunkwant = tp->want - tp->have;
+ if (tp->chunkwant > tp->want-tp->have)
+ tp->chunkwant = tp->want - tp->have;
}
} else {
RTMPT_DEBUG("Old packet cdir=%d seq=%d ti=%p tp=%p header_len=%d id=%d tph=%d tpw=%d len=%d cs=%d\n",
@@ -2170,7 +2206,8 @@ dissect_rtmpt_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rtmpt_
ti, tp, basic_hlen+message_hlen, id, tp?tp->have:0, tp?tp->want:0, body_len, chunk_size);
tp->chunkwant = chunk_size;
- if (tp->chunkwant>tp->want-tp->have) tp->chunkwant = tp->want - tp->have;
+ if (tp->chunkwant > tp->want-tp->have)
+ tp->chunkwant = tp->want - tp->have;
offset += basic_hlen + message_hlen;
remain -= basic_hlen + message_hlen;
@@ -2181,7 +2218,8 @@ dissect_rtmpt_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rtmpt_
/* Last case to deal with is unchunking the packet body */
unchunk:
want = tp->chunkwant - tp->chunkhave;
- if (want > remain) want = remain;
+ if (want > remain)
+ want = remain;
RTMPT_DEBUG(" cw=%d ch=%d r=%d w=%d\n", tp->chunkwant, tp->chunkhave, remain, want);
tvb_memcpy(tvb, tp->data.p+tp->have, offset, want);
@@ -2197,27 +2235,27 @@ dissect_rtmpt_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rtmpt_
offset += want;
remain -= want;
- if (tp->chunkhave==tp->chunkwant) {
+ if (tp->chunkhave == tp->chunkwant) {
/* Chunk is complete - wait for next header */
tp->chunkhave = 0;
tp->chunkwant = 0;
}
- if (tp->have==tp->want) {
+ if (tp->have == tp->want) {
/* Whole packet is complete */
wmem_tree_insert32(rconv->packets[cdir], tp->lastseq, tp);
pktbuf = tvb_new_child_real_data(tvb, tp->data.p, tp->have, tp->have);
add_new_data_source(pinfo, pktbuf, "Unchunked RTMP");
dissect_rtmpt(pktbuf, pinfo, tree, rconv, cdir, tp);
- } else if (tp->chunkhave<tp->chunkwant) {
+ } else if (tp->chunkhave < tp->chunkwant) {
/* Chunk is split across segment boundary */
rtmpt_frag_t *tf2 = wmem_new(wmem_file_scope(), rtmpt_frag_t);
- tf2->ishdr = 0;
- tf2->seq = seq + offset - want;
- tf2->lastseq = tf2->seq + remain - 1 + want;
- tf2->have = tp->chunkhave;
- tf2->len = tp->chunkwant;
+ tf2->ishdr = 0;
+ tf2->seq = seq + offset - want;
+ tf2->lastseq = tf2->seq + remain - 1 + want;
+ tf2->have = tp->chunkhave;
+ tf2->len = tp->chunkwant;
tf2->saved.id = tp->id;
RTMPT_DEBUG(" inserting tf @ %d\n", seq+offset-want-1);
wmem_tree_insert32(rconv->frags[cdir], seq+offset-want-1, tf2);
@@ -2225,7 +2263,7 @@ dissect_rtmpt_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rtmpt_
}
}
-static rtmpt_conv_t*
+static rtmpt_conv_t *
rtmpt_init_rconv(conversation_t *conv)
{
rtmpt_conv_t *rconv = wmem_new(wmem_file_scope(), rtmpt_conv_t);
@@ -2273,8 +2311,8 @@ dissect_rtmpt_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dat
cdir = (ADDRESSES_EQUAL(&conv->key_ptr->addr1, &pinfo->src) &&
ADDRESSES_EQUAL(&conv->key_ptr->addr2, &pinfo->dst) &&
- conv->key_ptr->port1==pinfo->srcport &&
- conv->key_ptr->port2==pinfo->destport) ? 0 : 1;
+ conv->key_ptr->port1 == pinfo->srcport &&
+ conv->key_ptr->port2 == pinfo->destport) ? 0 : 1;
dissect_rtmpt_common(tvb, pinfo, tree, rconv, cdir, tcpinfo->seq, tcpinfo->lastackseq);
return tvb_length(tvb);
@@ -2328,7 +2366,7 @@ dissect_rtmpt_http(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
* likely easily confused.
*/
- cdir = pinfo->srcport==pinfo->match_uint;
+ cdir = pinfo->srcport == pinfo->match_uint;
if (cdir) {
conv = find_conversation(pinfo->fd->num, &pinfo->dst, &pinfo->src, pinfo->ptype, 0, pinfo->srcport, 0);
@@ -2359,13 +2397,13 @@ dissect_rtmpt_http(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
lastackseq = GPOINTER_TO_INT(wmem_tree_lookup32_le(rconv->seqs[cdir ^ 1], pinfo->fd->num))+1;
- if (cdir==1 && lastackseq<2 && remain==17) {
+ if (cdir == 1 && lastackseq < 2 && remain == 17) {
/* Session startup: the client makes an /open/ request and
* the server responds with a 16 bytes client
* identifier followed by a newline */
offset += 17;
remain -= 17;
- } else if (cdir || remain==1) {
+ } else if (cdir || remain == 1) {
/* All other server responses start with one byte which
* is not part of the RTMP stream. Client /idle/ requests
* contain a single byte also not part of the stream. We
@@ -2376,7 +2414,7 @@ dissect_rtmpt_http(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
seq = GPOINTER_TO_INT(wmem_tree_lookup32(rconv->seqs[cdir], pinfo->fd->num));
- if (seq==0) {
+ if (seq == 0) {
seq = GPOINTER_TO_INT(wmem_tree_lookup32_le(rconv->seqs[cdir], pinfo->fd->num));
seq += remain;
wmem_tree_insert32(rconv->seqs[cdir], pinfo->fd->num, GINT_TO_POINTER(seq));
@@ -2386,9 +2424,10 @@ dissect_rtmpt_http(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
RTMPT_DEBUG("RTMPT f=%d cdir=%d seq=%d lastackseq=%d len=%d\n", pinfo->fd->num, cdir, seq, lastackseq, remain);
- if (remain<1) return;
+ if (remain < 1)
+ return;
- if (offset>0) {
+ if (offset > 0) {
tvbuff_t *tvbrtmp = tvb_new_subset(tvb, offset, remain, remain);
dissect_rtmpt_common(tvbrtmp, pinfo, tree, rconv, cdir, seq, lastackseq);
} else {
@@ -2400,7 +2439,7 @@ dissect_rtmpt_http(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
static gboolean
dissect_rtmpt_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
- conversation_t * conversation;
+ conversation_t *conversation;
if (tvb_length(tvb) >= 12)
{
/* To avoid a too high rate of false positive, this heuristics only matches the protocol
@@ -2434,11 +2473,11 @@ dissect_amf(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
{
proto_item *ti;
proto_tree *amf_tree, *headers_tree, *messages_tree;
- int offset;
- guint header_count, message_count, i;
- guint string_length;
- guint header_length, message_length;
- gboolean amf3_encoding = FALSE;
+ int offset;
+ guint header_count, message_count, i;
+ guint string_length;
+ guint header_length, message_length;
+ gboolean amf3_encoding = FALSE;
/*
* XXX - is "application/x-amf" just AMF3?
@@ -2697,23 +2736,6 @@ proto_register_rtmpt(void)
}
void
-proto_reg_handoff_rtmpt(void)
-{
- dissector_handle_t amf_handle;
-
-/* heur_dissector_add("tcp", dissect_rtmpt_heur, proto_rtmpt); */
- rtmpt_tcp_handle = new_create_dissector_handle(dissect_rtmpt_tcp, proto_rtmpt);
-/* dissector_add_handle("tcp.port", rtmpt_tcp_handle); */
- dissector_add_uint("tcp.port", RTMP_PORT, rtmpt_tcp_handle);
-
- rtmpt_http_handle = create_dissector_handle(dissect_rtmpt_http, proto_rtmpt);
- dissector_add_string("media_type", "application/x-fcs", rtmpt_http_handle);
-
- amf_handle = create_dissector_handle(dissect_amf, proto_amf);
- dissector_add_string("media_type", "application/x-amf", amf_handle);
-}
-
-void
proto_register_amf(void)
{
static hf_register_info hf[] = {
@@ -2901,6 +2923,23 @@ proto_register_amf(void)
proto_register_subtree_array(ett, array_length(ett));
}
+void
+proto_reg_handoff_rtmpt(void)
+{
+ dissector_handle_t amf_handle;
+
+/* heur_dissector_add("tcp", dissect_rtmpt_heur, proto_rtmpt); */
+ rtmpt_tcp_handle = new_create_dissector_handle(dissect_rtmpt_tcp, proto_rtmpt);
+/* dissector_add_handle("tcp.port", rtmpt_tcp_handle); */
+ dissector_add_uint("tcp.port", RTMP_PORT, rtmpt_tcp_handle);
+
+ rtmpt_http_handle = create_dissector_handle(dissect_rtmpt_http, proto_rtmpt);
+ dissector_add_string("media_type", "application/x-fcs", rtmpt_http_handle);
+
+ amf_handle = create_dissector_handle(dissect_amf, proto_amf);
+ dissector_add_string("media_type", "application/x-amf", amf_handle);
+}
+
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*