Wireshark自定义协议RPUDPDL(UDP下载)插件 (c版)

/* packet-rpudpdl.c
 *
 * RecordPlayer UDP Download Protocol
 */

/* include files */

#include "config.h"

#include <glib.h>
#include <epan/packet.h>
#include <epan/reassemble.h>
#include <epan/etypes.h>
#include <epan/expert.h>
#include <epan/tap.h>
#include <epan/stats_tree.h>

#include <stat_menu.h>
#include <epan/funnel.h>

#define RPUDPDL_PORT 1730

/* Define the rpudpdl proto */
static int proto_rpudpdl = -1;
static int hf_rpudpdl_sn = -1;
static int hf_rpudpdl_ssid = -1;
static int hf_rpudpdl_datasize = -1;
static int hf_rpudpdl_msgtype = -1;
static int hf_rpudpdl_msg_probe = -1;
static int hf_rpudpdl_msg_request = -1;
static int hf_rpudpdl_request_starttime = -1;
static int hf_rpudpdl_request_stoptime = -1;
static int hf_rpudpdl_request_smallfile = -1;
static int hf_rpudpdl_request_filepathlen = -1;
static int hf_rpudpdl_request_filenamelen = -1;
static int hf_rpudpdl_request_reserved = -1;
static int hf_rpudpdl_request_reserved1 = -1;
static int hf_rpudpdl_request_filepathname = -1;
static int hf_rpudpdl_sp_duration = -1;
static int hf_rpudpdl_sp_streamid = -1;
static int hf_rpudpdl_sp_mediatype = -1;
static int hf_rpudpdl_sp_videowidth = -1;
static int hf_rpudpdl_sp_videoheight = -1;
static int hf_rpudpdl_sp_reserved1 = -1;
static int hf_rpudpdl_sp_reserved2 = -1;

static gint ett_rpudpdl = -1;
static gint ett_rpudpdl_request = -1;
static gint ett_rpudpdl_streamproperty = -1;

#define MSGTYPE_PROBE           1
#define MSGTYPE_REQUEST         2
#define MSGTYPE_STREAM_PROPERTY 3
#define MSGTYPE_FRAME_DATA      4
#define MSGTYPE_ACK             5
#define MSGTYPE_SEND_DATA_END   6
#define MSGTYPE_CHECK_PARAM     7
#define MSGTYPE_PROBE_ACK       8
#define MSGTYPE_UDP_PACKET      9
#define MSGTYPE_RESEND          10
#define MSGTYPE_REFUSE          11

static const value_string msgtypenames[] = {
    { MSGTYPE_PROBE,            "Probe" },
    { MSGTYPE_REQUEST,          "Request" },
    { MSGTYPE_STREAM_PROPERTY,  "StreamProperty" },
    { MSGTYPE_FRAME_DATA,       "FrameData" },
    { MSGTYPE_ACK,              "Ack" },
    { MSGTYPE_SEND_DATA_END,    "SendDataEnd" },
    { MSGTYPE_CHECK_PARAM,      "CheckParam" },
    { MSGTYPE_PROBE_ACK,        "ProbeAck" },
    { MSGTYPE_UDP_PACKET,       "UdpPacket" },
    { MSGTYPE_RESEND,           "Resend" },
    { MSGTYPE_REFUSE,           "Refuse" },
    { 0, NULL }
};

static dissector_handle_t data_handle;

/* A tap is basically a way of allowing other items to see whats happening as a protocol is dissected. A tap
is registered with the main program, and then called on each dissection. Some arbitrary protocol specific
data is provided with the routine that can be used. */

/* To create a tap, you first need to register a tap. A tap is registered with an integer handle, and registered
   with the routine register_tap. This takes a string name with which to find it again. */
static int rpudpdl_tap = -1;

struct rpudpdl_tap_info {
    guint sn;
    guint ssid;
    guint msgtype;
};

static void dissect_rpudpdl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
    guint32 msgtype, ssid, sn;
    gint offset = 0;
    guint32 request_filepathlen, request_filenamelen;
    tvbuff_t *next_tvb;
    gint len, reported_len;
    struct rpudpdl_tap_info *tapinfo;


    if (
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值