您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ tvb_find_line_end函数代码示例

51自学网 2021-06-03 09:01:07
  C++
这篇教程C++ tvb_find_line_end函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中tvb_find_line_end函数的典型用法代码示例。如果您正苦于以下问题:C++ tvb_find_line_end函数的具体用法?C++ tvb_find_line_end怎么用?C++ tvb_find_line_end使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了tvb_find_line_end函数的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: dissect_msnms

static voiddissect_msnms(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){        proto_tree      *msnms_tree;	proto_item	*ti;	gint		offset = 0;	const guchar	*line;	gint		next_offset;	int		linelen;	/* int		tokenlen; */	/* const guchar	*next_token; */	col_set_str(pinfo->cinfo, COL_PROTOCOL, "MSNMS");	/*	 * Find the end of the first line.	 *	 * Note that "tvb_find_line_end()" will return a value that is	 * not longer than what's in the buffer, so the "tvb_get_ptr()"	 * call won't throw an exception.	 */	linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);	line = tvb_get_ptr(tvb, offset, linelen);	if (check_col(pinfo->cinfo, COL_INFO)) {		/*		 * Put the first line from the buffer into the summary.		 */		col_add_str(pinfo->cinfo, COL_INFO, 			    format_text(line, linelen));	}	if (tree) {		ti = proto_tree_add_item(tree, proto_msnms, tvb, offset, -1,		    FALSE);		msnms_tree = proto_item_add_subtree(ti, ett_msnms);		/*		 * Show the rest of the packet as text,		 * a line at a time.		 */		while (tvb_offset_exists(tvb, offset)) {			/*			 * Find the end of the line.			 */			linelen = tvb_find_line_end(tvb, offset, -1,			    &next_offset, FALSE);			/*			 * Put this line.			 */			proto_tree_add_text(msnms_tree, tvb, offset,			    next_offset - offset, "%s",			    tvb_format_text(tvb, offset, next_offset - offset));			offset = next_offset;		}	}}
开发者ID:AkhilaAG,项目名称:gluster-wireshark-1.4,代码行数:59,


示例2: dissect_rsh

static voiddissect_rsh(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){	proto_tree	*rsh_tree;	proto_item	*ti, *hidden_item;	gint		offset = 0;	gint		next_offset;	int		linelen;	col_set_str(pinfo->cinfo, COL_PROTOCOL, "RSH");	if (check_col(pinfo->cinfo, COL_INFO)) {		/* Put the first line from the buffer into the summary. */		tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);		linelen = next_offset - offset;	/* include the line terminator */		/*		 * Make sure the line terminator isn't past the end of		 * the captured data in the packet, so we don't throw		 * an exception in the "tvb_get_ptr()" call.		 */		if (linelen > (int) tvb_length(tvb))			linelen = tvb_length(tvb);		col_add_str(pinfo->cinfo, COL_INFO,		    tvb_format_text(tvb, offset, linelen));	}	if (tree) {		ti = proto_tree_add_item(tree, proto_rsh, tvb, offset, -1,		    FALSE);		rsh_tree = proto_item_add_subtree(ti, ett_rsh);		/*		 * Process the packet data, a line at a time.		 */		while (tvb_offset_exists(tvb, offset)) {			/*			 * Find the end of the line.			 */			tvb_find_line_end(tvb, offset, -1, &next_offset,			    FALSE);			/*			 * Put this line.			 */			proto_tree_add_text(rsh_tree, tvb, offset,			    next_offset - offset, "%s",			    tvb_format_text(tvb, offset, next_offset - offset));			offset = next_offset;		}		if (pinfo->match_port == pinfo->destport) {			hidden_item = proto_tree_add_boolean(rsh_tree,			    hf_rsh_request, tvb, 0, 0, 1);                } else {			hidden_item = proto_tree_add_boolean(rsh_tree,			    hf_rsh_response, tvb, 0, 0, 1);                }                PROTO_ITEM_SET_HIDDEN(hidden_item);	}}
开发者ID:AkhilaAG,项目名称:gluster-wireshark-1.4,代码行数:59,


示例3: dissect_proxy_to_host

static int dissect_proxy_to_host(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {    int offset = 0;    gint next_offset;    gint proxy_to_length;    gchar *pmproxy_host_and_port_string;    gchar **host_and_port;    gchar *host;    gchar *port;    col_set_str(pinfo->cinfo, COL_INFO, "Proxy");    proxy_to_length = tvb_find_line_end(tvb, offset, tvb_ensure_captured_length_remaining(tvb, offset), &next_offset, FALSE);    if(proxy_to_length != -1) {        pmproxy_host_and_port_string = (gchar *) tvb_get_string_enc(wmem_packet_scope(), tvb, offset, proxy_to_length, ENC_ASCII);        host_and_port = wmem_strsplit(wmem_packet_scope(), pmproxy_host_and_port_string, " ", -1);        if(host_and_port != NULL) {            host = host_and_port[0];            if (host) {                proto_tree_add_string(tree, hf_pmproxy_host, tvb, offset, (guint32)strlen(host), host);                offset += (int)strlen(host) + PMPROXY_HOST_AND_PORT_DELIMETER_LENGTH;                port = host_and_port[1];                if (port) {                    proto_tree_add_string(tree, hf_pmproxy_port, tvb, offset, (guint32)strlen(port), port);                }            } else {                port = NULL;            }            col_append_fstr(pinfo->cinfo, COL_INFO, " Host=%s, Port=%s", host ? host : "", port ? port : "");        }    }    return proxy_to_length;}
开发者ID:acaceres2176,项目名称:wireshark,代码行数:33,


示例4: dissect_smtp_data

static voiddissect_smtp_data(tvbuff_t *tvb, int offset, proto_tree *smtp_tree){  gint next_offset;  if (smtp_tree) {    while (tvb_offset_exists(tvb, offset)) {      /*       * Find the end of the line.       */      tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);      /*       * Put this line.       */      proto_tree_add_item(smtp_tree, hf_smtp_message, tvb,                          offset, next_offset - offset, ENC_ASCII|ENC_NA);      /*       * Step to the next line.       */      offset = next_offset;    }  }}
开发者ID:hubolo,项目名称:wireshark-1.8.0,代码行数:25,


示例5: find_dir_tokens

static gbooleanfind_dir_tokens(tvbuff_t *tvb, gint name_start, gint *sel_start, gint *host_start, gint *port_start, gint *line_len, gint *next_offset) {    gint remain;    if (tvb_length_remaining(tvb, name_start) < MIN_DIR_LINE_LEN)        return FALSE;    if (! (sel_start && host_start && port_start && line_len && next_offset) )        return FALSE;    *line_len = tvb_find_line_end(tvb, name_start, MAX_DIR_LINE_LEN, next_offset, FALSE);    if (*line_len < MIN_DIR_LINE_LEN)        return FALSE;    remain = *line_len;    *sel_start = tvb_find_guint8(tvb, name_start, remain, '/t') + 1;    if (*sel_start < name_start + 1)        return FALSE;    remain -= *sel_start - name_start;    *host_start = tvb_find_guint8(tvb, *sel_start, remain, '/t') + 1;    if (*host_start < *sel_start + 1)        return FALSE;    remain -= *host_start - *sel_start;    *port_start = tvb_find_guint8(tvb, *host_start, remain, '/t') + 1;    if (*port_start < *host_start + 1)        return FALSE;    return TRUE;}
开发者ID:RayHightower,项目名称:wireshark,代码行数:31,


示例6: find_next_boundary

/* * Unless the first boundary, subsequent boundaries include a line-end sequence * before the dashed boundary string. * * Return the offset to the 1st byte of the boundary delimiter line. * Set boundary_line_len to the length of the entire boundary delimiter. * Set last_boundary to TRUE if we've seen the last-boundary delimiter. */static gintfind_next_boundary(tvbuff_t *tvb, gint start, const guint8 *boundary,                   gint boundary_len, gint *boundary_line_len, gboolean *last_boundary){    gint offset = start, next_offset, line_len, boundary_start;    while (tvb_offset_exists(tvb, offset + 2 + boundary_len)) {        line_len =  tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);        if (line_len == -1) {            return -1;        }        boundary_start = offset + line_len;        if (((tvb_strneql(tvb, next_offset, (const guint8 *)"--", 2) == 0)                && (tvb_strneql(tvb, next_offset + 2, boundary, boundary_len) == 0)))        {            /* Boundary string; now check if last */            if ((tvb_reported_length_remaining(tvb, next_offset + 2 + boundary_len + 2) >= 0)                    && (tvb_strneql(tvb, next_offset + 2 + boundary_len,                                    (const guint8 *)"--", 2) == 0)) {                *last_boundary = TRUE;            } else {                *last_boundary = FALSE;            }            /* Look for line end of the boundary line */            line_len =  tvb_find_line_end(tvb, next_offset, -1, &offset, FALSE);            if (line_len == -1) {                *boundary_line_len = -1;            } else {                *boundary_line_len = offset - boundary_start;            }            return boundary_start;            /* check if last before CRLF; some ignore the standard, so there is no CRLF before the boundary */        } else if ((tvb_strneql(tvb, boundary_start - 2, (const guint8 *)"--", 2) == 0)                   && (tvb_strneql(tvb, boundary_start - (2 + boundary_len), boundary, boundary_len) == 0)                   && (tvb_strneql(tvb, boundary_start - (2 + boundary_len + 2),                                   (const guint8 *)"--", 2) == 0)) {            boundary_start -= 2 + boundary_len + 2;            *boundary_line_len = next_offset - boundary_start;            *last_boundary = TRUE;            return boundary_start;        }        offset = next_offset;    }    return -1;}
开发者ID:aminema,项目名称:wireshark,代码行数:54,


示例7: dissect_irc

static voiddissect_irc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){	proto_tree      *irc_tree, *ti;	gint		offset = 0;	gint		next_offset;	int		linelen;	col_set_str(pinfo->cinfo, COL_PROTOCOL, "IRC");	if (check_col(pinfo->cinfo, COL_INFO))	{		col_set_str(pinfo->cinfo, COL_INFO,		    (pinfo->match_uint == pinfo->destport) ? "Request" : "Response");	}	if (tree)	{		ti = proto_tree_add_item(tree, proto_irc, tvb, 0, -1, ENC_NA);		irc_tree = proto_item_add_subtree(ti, ett_irc);		/*		 * Process the packet data, a line at a time.		 */		while (tvb_reported_length_remaining(tvb, offset) > 0)		{			/*			 * Find the end of the line.			 */			linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);			if (next_offset == offset) {				/*				 * XXX - we really want the "show data a				 * line at a time" loops in various				 * dissectors to do reassembly and to				 * throw an exception if there's no				 * line ending in the current packet				 * and we're not doing reassembly.				 */				break;			}			if (linelen != 0)			{				if (pinfo->match_uint == pinfo->destport)				{					dissect_irc_request(irc_tree, tvb, pinfo, offset, linelen);				}				else				{					dissect_irc_response(irc_tree, tvb, pinfo, offset, linelen);				}			}			offset = next_offset;		}	}}
开发者ID:hubolo,项目名称:wireshark-1.8.0,代码行数:57,


示例8: check_msrp_header

/* This code is modeled on the code in packet-sip.c *  ABNF code for the MSRP header: *  The following syntax specification uses the augmented Backus-Naur *  Form (BNF) as described in RFC-2234 [6]. * * *  msrp-req-or-resp = msrp-request / msrp-response *  msrp-request = req-start headers [content-stuff] end-line *  msrp-response = resp-start headers end-line * *  req-start  = pMSRP SP transact-id SP method CRLF *  resp-start = pMSRP SP transact-id SP status-code [SP phrase] CRLF *  phrase = utf8text * *  pMSRP = %x4D.53.52.50 ; MSRP in caps *  transact-id = ident *  method = mSEND / mREPORT / other-method *  mSEND = %x53.45.4e.44 ; SEND in caps *  mREPORT = %x52.45.50.4f.52.54; REPORT in caps *  other-method = 1*UPALPHA *  Examples: *  "MSRP 1234 SEND(CRLF)" *	"MSRP 1234 200 OK(CRLF) */static gbooleancheck_msrp_header(tvbuff_t *tvb){	gint offset = 0;	gint linelen;	gint space_offset;	gint next_offset = 0;	guint token_1_len;	gint token_2_start;	/*	 * Note that "tvb_find_line_end()" will return a value that	 * is not longer than what's in the buffer, so the	 * "tvb_get_ptr()" calls below won't throw exceptions.	 *	 */	offset = 0;	if(tvb_length(tvb) < 4 ||  tvb_get_ntohl(tvb, 0) != 0x4d535250 /* MSRP */){		return FALSE;	}	linelen = tvb_find_line_end(tvb, 0, -1, &next_offset, FALSE);	/* Find the first SP */	space_offset = tvb_find_guint8(tvb, 0, -1, ' ');	if (space_offset <= 0) {		/*		 * Either there's no space in the line (which means		 * the line is empty or doesn't have a token followed		 * by a space; neither is valid for a request or response), or		 * the first character in the line is a space ( which isn't valid		 * for a MSRP header.)		 */		return FALSE;	}	token_1_len = space_offset;	token_2_start = space_offset + 1;	space_offset = tvb_find_guint8(tvb, token_2_start, -1, ' ');	if (space_offset == -1) {		/*		 * There's no space after the second token, so we don't		 * have a third token.		 */		return FALSE;	}	/*	 * Is the first token "MSRP"?	 */	if (token_1_len == MSRP_HDR_LEN) { /*  && tvb_strneql(tvb, 0, MSRP_HDR, MSRP_HDR_LEN) == 0){ */		/* This check can be made more strict but accept we do have MSRP for now */		return TRUE;	}	return FALSE;}
开发者ID:flaub,项目名称:HotFuzz,代码行数:79,


示例9: dissect_nasdaq_soup

/* ---------------------------- */static voiddissect_nasdaq_soup(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){    proto_item *ti;    proto_tree *nasdaq_soup_tree = NULL;    guint8 nasdaq_soup_type;    int  linelen;    gint next_offset;    int  offset = 0;    gint col_info;    gint counter = 0;    col_info = check_col(pinfo->cinfo, COL_INFO);    while (tvb_offset_exists(tvb, offset)) {        /* there's only a /n no /r */        linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, nasdaq_soup_desegment && pinfo->can_desegment);        if (linelen == -1) {            /*             * We didn't find a line ending, and we're doing desegmentation;             * tell the TCP dissector where the data for this message starts             * in the data it handed us, and tell it we need one more byte             * (we may need more, but we'll try again if what we get next             * isn't enough), and return.             */            pinfo->desegment_offset = offset;            pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;            return;        }        nasdaq_soup_type = tvb_get_guint8(tvb, offset);        if (counter == 0) {            col_set_str(pinfo->cinfo, COL_PROTOCOL, "Nasdaq-SOUP");            if (col_info)                col_clear(pinfo->cinfo, COL_INFO);        }        if (col_info ) {            if (counter) {                col_append_str(pinfo->cinfo, COL_INFO, "; ");                col_set_fence(pinfo->cinfo, COL_INFO);            }            col_append_str(pinfo->cinfo, COL_INFO, val_to_str(nasdaq_soup_type, message_types_val, "Unknown packet type (0x%02x)"));        }        counter++;        if (tree) {            ti = proto_tree_add_item(tree, proto_nasdaq_soup, tvb, offset, linelen +1, ENC_NA);            nasdaq_soup_tree = proto_item_add_subtree(ti, ett_nasdaq_soup);        }        dissect_nasdaq_soup_packet(tvb, pinfo, tree, nasdaq_soup_tree, offset, linelen);        offset = next_offset;    }}
开发者ID:giuliano108,项目名称:wireshark-rtpmon,代码行数:52,


示例10: find_next_boundary

/* * Unless the first boundary, subsequent boundaries include a line-end sequence * before the dashed boundary string. * * Return the offset to the 1st byte of the boundary delimiter line. * Set boundary_line_len to the length of the entire boundary delimiter. * Set last_boundary to TRUE if we've seen the last-boundary delimiter. */static gintfind_next_boundary(tvbuff_t *tvb, gint start, const guint8 *boundary,        gint boundary_len, gint *boundary_line_len, gboolean *last_boundary){    gint offset = start, next_offset, line_len, boundary_start;    while (tvb_length_remaining(tvb, offset + 2 + boundary_len) > 0) {        line_len =  tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);        if (line_len == -1) {            return -1;        }        boundary_start = offset + line_len;        if (((tvb_strneql(tvb, next_offset, (const guint8 *)"--", 2) == 0)                    && (tvb_strneql(tvb, next_offset + 2, boundary, boundary_len) == 0)))        {            /* Boundary string; now check if last */            if ((tvb_length_remaining(tvb, next_offset + 2 + boundary_len + 2) >= 0)                    && (tvb_strneql(tvb, next_offset + 2 + boundary_len,                            (const guint8 *)"--", 2) == 0)) {                *last_boundary = TRUE;            } else {                *last_boundary = FALSE;            }            /* Look for line end of the boundary line */            line_len =  tvb_find_line_end(tvb, next_offset, -1, &offset, FALSE);            if (line_len == -1) {                *boundary_line_len = -1;            } else {                *boundary_line_len = offset - boundary_start;            }            return boundary_start;        }        offset = next_offset;    }    return -1;}
开发者ID:dot-Sean,项目名称:wireshark-http2,代码行数:45,


示例11: tvb_raw_text_add

/* * Display the entire message as raw text. */static voidtvb_raw_text_add(tvbuff_t *tvb, proto_tree *tree){	int offset, next_offset, linelen;	offset = 0;	while (tvb_offset_exists(tvb, offset)) {		/* 'desegment' is FALSE so will set next_offset to beyond the end of		   the buffer if no line ending is found */		tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);		linelen = next_offset - offset;		if(tree) {			proto_tree_add_text(tree, tvb, offset, linelen,			                    "%s", tvb_format_text(tvb, offset, linelen));		}		offset = next_offset;	}}
开发者ID:flaub,项目名称:HotFuzz,代码行数:21,


示例12: find_end_line

/* ABNF of line-end: * end-line = "-------" transact-id continuation-flag CRLF * This code is modeled on the code in packet-multipart.c */static intfind_end_line(tvbuff_t *tvb, gint start){	gint offset = start, next_offset, linelen;	while (tvb_length_remaining(tvb, offset) > 0) {		/* 'desegment' is FALSE so will set next_offset to beyond the end of		   the buffer if no line ending is found */		linelen =  tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);		if (linelen == -1) {			return -1;		}		if (tvb_strneql(tvb, next_offset, (const gchar *)"-------", 7) == 0)			return next_offset;		offset = next_offset;	}	return -1;}
开发者ID:flaub,项目名称:HotFuzz,代码行数:23,


示例13: dissect_smtp

//.........这里部分代码省略.........   */  spd_frame_data = p_get_proto_data(pinfo->fd, proto_smtp);  if (!spd_frame_data) {    /*     * No frame data.     */    if(request) {      /*       * Create a frame data structure and attach it to the packet.       */      spd_frame_data = se_alloc0(sizeof(struct smtp_proto_data));      spd_frame_data->conversation_id = conversation->index;      spd_frame_data->more_frags = TRUE;      p_add_proto_data(pinfo->fd, proto_smtp, spd_frame_data);    }    /*     * Get the first line from the buffer.     *     * Note that "tvb_find_line_end()" will, if it doesn't return     * -1, return a value that is not longer than what's in the buffer,     * and "tvb_find_line_end()" will always return a value that is not     * longer than what's in the buffer, so the "tvb_get_ptr()" call     * won't throw an exception.     */    loffset = offset;    while (tvb_offset_exists(tvb, loffset)) {      linelen = tvb_find_line_end(tvb, loffset, -1, &next_offset,                                  smtp_desegment && pinfo->can_desegment);      if (linelen == -1) {        if (offset == loffset) {          /*           * We didn't find a line ending, and we're doing desegmentation;           * tell the TCP dissector where the data for this message starts           * in the data it handed us, and tell it we need more bytes           */          pinfo->desegment_offset = loffset;          pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;          return;        } else {          linelen = tvb_length_remaining(tvb, loffset);          next_offset = loffset + linelen;        }      }      line = tvb_get_ptr(tvb, loffset, linelen);      /*       * Check whether or not this packet is an end of message packet       * We should look for CRLF.CRLF and they may be split.       * We have to keep in mind that we may see what we want on       * two passes through here ...       */      if (session_state->smtp_state == SMTP_STATE_READING_DATA) {        /*         * The order of these is important ... We want to avoid         * cases where there is a CRLF at the end of a packet and a         * .CRLF at the begining of the same packet.         */        if ((session_state->crlf_seen && tvb_strneql(tvb, loffset, "./r/n", 3) == 0) ||            tvb_strneql(tvb, loffset, "/r/n./r/n", 5) == 0)
开发者ID:hubolo,项目名称:wireshark-1.8.0,代码行数:67,


示例14: dissect_pop

static voiddissect_pop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){  struct pop_proto_data  *frame_data_p;  gboolean               is_request;  gboolean               is_continuation;  proto_tree             *pop_tree, *reqresp_tree;  proto_item             *ti;  gint                   offset = 0;  const guchar           *line;  gint                   next_offset;  int                    linelen;  int                    tokenlen;  const guchar           *next_token;  fragment_data          *frag_msg = NULL;  tvbuff_t               *next_tvb = NULL;  conversation_t         *conversation = NULL;  struct pop_data_val    *data_val = NULL;  gint                   length_remaining;  col_set_str(pinfo->cinfo, COL_PROTOCOL, "POP");  /*   * Find the end of the first line.   *   * Note that "tvb_find_line_end()" will return a value that is   * not longer than what's in the buffer, so the "tvb_get_ptr()"   * call won't throw an exception.   */  linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);  line = tvb_get_ptr(tvb, offset, linelen);  if (pinfo->match_port == pinfo->destport) {    is_request = TRUE;    is_continuation = FALSE;  } else {    is_request = FALSE;    is_continuation = response_is_continuation(line);  }  frame_data_p = p_get_proto_data(pinfo->fd, proto_pop);  if (!frame_data_p) {    conversation = find_conversation(pinfo->fd->num,              &pinfo->src, &pinfo->dst,              pinfo->ptype,             pinfo->srcport, pinfo->destport, 0);    if (conversation == NULL) { /* No conversation, create one */      conversation = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst,                                      pinfo->ptype, pinfo->srcport,                                      pinfo->destport, 0);    }    data_val = conversation_get_proto_data(conversation, proto_pop);    if (!data_val) {      /*       * No - create one and attach it.       */      data_val = se_alloc0(sizeof(struct pop_data_val));            conversation_add_proto_data(conversation, proto_pop, data_val);    }  }  if (check_col(pinfo->cinfo, COL_INFO)) {    /*     * Put the first line from the buffer into the summary     * if it's a POP request or reply (but leave out the     * line terminator).     * Otherwise, just call it a continuation.     */    if (is_continuation) {      length_remaining = tvb_length_remaining(tvb, offset);      col_add_fstr(pinfo->cinfo, COL_INFO, "S: DATA fragment, %d byte%s",                    length_remaining, plurality (length_remaining, "", "s"));    }    else      col_add_fstr(pinfo->cinfo, COL_INFO, "%s: %s", is_request ? "C" : "S",                   format_text(line, linelen));  }  ti = proto_tree_add_item(tree, proto_pop, tvb, offset, -1, FALSE);  pop_tree = proto_item_add_subtree(ti, ett_pop);  if (is_continuation) {    if (pop_data_desegment) {      if (!frame_data_p) {        data_val->msg_read_len += tvb_length(tvb);        frame_data_p = se_alloc(sizeof(struct pop_proto_data));        frame_data_p->conversation_id = conversation->index;        frame_data_p->more_frags = data_val->msg_read_len < data_val->msg_tot_len;//.........这里部分代码省略.........
开发者ID:flaub,项目名称:HotFuzz,代码行数:101,


示例15: dissect_icap

static voiddissect_icap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){	proto_tree	*icap_tree = NULL;	proto_item	*ti = NULL;	proto_item	*hidden_item;	gint		offset = 0;	const guchar	*line;	gint		next_offset;	const guchar	*linep, *lineend;	int		linelen;	guchar		c;	icap_type_t     icap_type;	int		datalen;	col_set_str(pinfo->cinfo, COL_PROTOCOL, "ICAP");	/*	 * Put the first line from the buffer into the summary	 * if it's an ICAP header (but leave out the	 * line terminator).	 * Otherwise, just call it a continuation.	 *	 * Note that "tvb_find_line_end()" will return a value that	 * is not longer than what's in the buffer, so the	 * "tvb_get_ptr()" call won't throw an exception.	 */	linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);	line = tvb_get_ptr(tvb, offset, linelen);	icap_type = ICAP_OTHER;	/* type not known yet */	if (is_icap_message(line, linelen, &icap_type))		col_add_str(pinfo->cinfo, COL_INFO,		    format_text(line, linelen));	else		col_set_str(pinfo->cinfo, COL_INFO, "Continuation");	if (tree) {		ti = proto_tree_add_item(tree, proto_icap, tvb, offset, -1,		    ENC_NA);		icap_tree = proto_item_add_subtree(ti, ett_icap);	}	/*	 * Process the packet data, a line at a time.	 */	icap_type = ICAP_OTHER;	/* type not known yet */	while (tvb_offset_exists(tvb, offset)) {		gboolean is_icap = FALSE;		gboolean loop_done = FALSE;		/*		 * Find the end of the line.		 */		linelen = tvb_find_line_end(tvb, offset, -1, &next_offset,		    FALSE);		/*		 * Get a buffer that refers to the line.		 */		line = tvb_get_ptr(tvb, offset, linelen);		lineend = line + linelen;		/*		 * find header format		 */		if (is_icap_message(line, linelen, &icap_type)) {			goto is_icap_header;		}		/*		 * if it looks like a blank line, end of header perhaps?		 */		if (linelen == 0) {			goto is_icap_header;		}		/*		 * No.  Does it look like a header?		 */		linep = line;		loop_done = FALSE;		while (linep < lineend && (!loop_done)) {			c = *linep++;			/*			 * This must be a CHAR to be part of a token; that			 * means it must be ASCII.			 */			if (!isascii(c)) {				is_icap = FALSE;				break;	/* not ASCII, thus not a CHAR */			}			/*			 * This mustn't be a CTL to be part of a token.			 *			 * XXX - what about leading LWS on continuation			 * lines of a header?			 */			if (iscntrl(c)) {				is_icap = FALSE;//.........这里部分代码省略.........
开发者ID:dot-Sean,项目名称:wireshark-http2,代码行数:101,


示例16: dissect_ldss_transfer

/* Transfers happen in response to broadcasts, they are always TCP and are * used to send the file to the port mentioned in the broadcast. There are * 2 types of transfers: Pushes, which are direct responses to searches, * in which the peer that has the file connects to the peer that doesn't and * sends it, then disconnects. The other type of transfer is a pull, where * the peer that doesn't have the file connects to the peer that does and * requests it be sent. * * Pulls have a file request which identifies the desired file, * while pushes simply send the file. In practice this works because every * file the implementation sends searches for is on a different TCP port * on the searcher's machine. */static intdissect_ldss_transfer (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data){	conversation_t *transfer_conv;	ldss_transfer_info_t *transfer_info;	struct tcpinfo *transfer_tcpinfo;	proto_tree *ti, *line_tree = NULL, *ldss_tree = NULL;	nstime_t broadcast_response_time;	/* Reject the packet if data is NULL */	if (data == NULL)		return 0;	transfer_tcpinfo = (struct tcpinfo *)data;	col_set_str(pinfo->cinfo, COL_PROTOCOL, "LDSS");	/* Look for the transfer conversation; this was created during	 * earlier broadcast dissection (see prepare_ldss_transfer_conv) */	transfer_conv = find_conversation (pinfo->num, &pinfo->src, &pinfo->dst,					   PT_TCP, pinfo->srcport, pinfo->destport, 0);	transfer_info = (ldss_transfer_info_t *)conversation_get_proto_data(transfer_conv, proto_ldss);	/* For a pull, the first packet in the TCP connection is the file request.	 * First packet is identified by relative seq/ack numbers of 1.	 * File request only appears on a pull (triggered by an offer - see above	 * about broadcasts) */	if (transfer_tcpinfo->seq == 1 &&	    transfer_tcpinfo->lastackseq == 1 &&	    transfer_info->broadcast->message_id == MESSAGE_ID_WILLSEND) {		/* LDSS pull transfers look a lot like HTTP.		 * Sample request:		 * md5:01234567890123...		 * Size: 2550		 * Start: 0		 * Compression: 0		 * (remote end sends the file identified by the digest) */		guint offset = 0;		gboolean already_dissected = TRUE;		col_set_str(pinfo->cinfo, COL_INFO, "LDSS File Transfer (Requesting file - pull)");		if (highest_num_seen == 0 ||		    highest_num_seen < pinfo->num) {			already_dissected = FALSE;			transfer_info->req = wmem_new0(wmem_file_scope(), ldss_file_request_t);			transfer_info->req->file = wmem_new0(wmem_file_scope(), ldss_file_t);			highest_num_seen = pinfo->num;		}		if (tree) {			ti = proto_tree_add_item(tree, proto_ldss,						 tvb, 0, tvb_reported_length(tvb), ENC_NA);			ldss_tree = proto_item_add_subtree(ti, ett_ldss_transfer);		}		/* Populate digest data into the file struct in the request */		transfer_info->file = transfer_info->req->file;		/* Grab each line from the packet, there should be 4 but lets		 * not walk off the end looking for more. */		while (tvb_offset_exists(tvb, offset)) {			gint next_offset;			const guint8 *line;			int linelen;			gboolean is_digest_line;			guint digest_type_len;			linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);			/* Include new-line in line */			line = (guint8 *)tvb_memdup(NULL, tvb, offset, linelen+1); /* XXX - memory leak? */			line_tree = proto_tree_add_subtree(ldss_tree, tvb, offset, linelen,							 ett_ldss_transfer_req, NULL,							 tvb_format_text(tvb, offset, next_offset-offset));			/* Reduce code duplication processing digest lines.			 * There are too many locals to pass to a function - the signature			 * looked pretty ugly when I tried! */			is_digest_line = FALSE;			if (strncmp(line,"md5:",4)==0) {				is_digest_line = TRUE;				digest_type_len = 4;				transfer_info->file->digest_type = DIGEST_TYPE_MD5;			}			else if (strncmp(line, "sha1:", 5)==0) {//.........这里部分代码省略.........
开发者ID:glocklueng,项目名称:wireshark,代码行数:101,


示例17: dissect_ftp

static voiddissect_ftp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){    gboolean        is_request;    proto_tree     *ftp_tree          = NULL;    proto_tree     *reqresp_tree      = NULL;    proto_item     *ti, *hidden_item;    gint            offset            = 0;    const guchar   *line;    guint32         code;    gchar           code_str[4];    gboolean        is_port_request   = FALSE;    gboolean        is_pasv_response  = FALSE;    gboolean        is_epasv_response = FALSE;    gint            next_offset;    int             linelen;    int             tokenlen;    const guchar   *next_token;    guint32         pasv_ip;    guint32         ftp_ip;    guint16         ftp_port;    address         ftp_ip_address;    gboolean        ftp_nat;    conversation_t *conversation;    ftp_ip_address = pinfo->src;    if (pinfo->match_uint == pinfo->destport)        is_request = TRUE;    else        is_request = FALSE;    col_set_str(pinfo->cinfo, COL_PROTOCOL, "FTP");    /*     * Find the end of the first line.     *     * Note that "tvb_find_line_end()" will return a value that is     * not longer than what's in the buffer, so the "tvb_get_ptr()"     * call won't throw an exception.     */    linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);    line    = tvb_get_ptr(tvb, offset, linelen);    /*     * Put the first line from the buffer into the summary     * (but leave out the line terminator).     */    col_add_fstr(pinfo->cinfo, COL_INFO, "%s: %s",        is_request ? "Request" : "Response",        format_text(line, linelen));    if (tree) {        ti = proto_tree_add_item(tree, proto_ftp, tvb, offset, -1, ENC_NA);        ftp_tree = proto_item_add_subtree(ti, ett_ftp);        if (is_request) {            hidden_item = proto_tree_add_boolean(ftp_tree,                hf_ftp_request, tvb, 0, 0, TRUE);            PROTO_ITEM_SET_HIDDEN(hidden_item);            hidden_item = proto_tree_add_boolean(ftp_tree,                hf_ftp_response, tvb, 0, 0, FALSE);            PROTO_ITEM_SET_HIDDEN(hidden_item);        } else {            hidden_item = proto_tree_add_boolean(ftp_tree,                hf_ftp_request, tvb, 0, 0, FALSE);            PROTO_ITEM_SET_HIDDEN(hidden_item);            hidden_item = proto_tree_add_boolean(ftp_tree,                hf_ftp_response, tvb, 0, 0, TRUE);            PROTO_ITEM_SET_HIDDEN(hidden_item);        }        /*         * Put the line into the protocol tree.         */        ti = proto_tree_add_text(ftp_tree, tvb, offset,            next_offset - offset, "%s",            tvb_format_text(tvb, offset, next_offset - offset));        reqresp_tree = proto_item_add_subtree(ti, ett_ftp_reqresp);    }    if (is_request) {        /*         * Extract the first token, and, if there is a first         * token, add it as the request.         */        tokenlen = get_token_len(line, line + linelen, &next_token);        if (tokenlen != 0) {            if (tree) {                proto_tree_add_item(reqresp_tree,                    hf_ftp_request_command, tvb, offset,                    tokenlen, ENC_ASCII|ENC_NA);            }            if (strncmp(line, "PORT", tokenlen) == 0)                is_port_request = TRUE;        }    } else {        /*         * This is a response; the response code is 3 digits,         * followed by a space or hyphen, possibly followed by//.........这里部分代码省略.........
开发者ID:hubolo,项目名称:wireshark-1.8.0,代码行数:101,


示例18: dissect_imap

static voiddissect_imap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){	gboolean        is_request;	proto_tree      *imap_tree, *reqresp_tree;	proto_item      *ti, *hidden_item;	gint		offset = 0;	const guchar	*line;	gint		next_offset;	int		linelen;	int		tokenlen;	const guchar	*next_token;	col_set_str(pinfo->cinfo, COL_PROTOCOL, "IMAP");	if (pinfo->match_uint == pinfo->destport)		is_request = TRUE;	else		is_request = FALSE;	if (check_col(pinfo->cinfo, COL_INFO)) {		/*		 * Put the first line from the buffer into the summary		 * (but leave out the line terminator).		 */		linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);		line = tvb_get_ptr(tvb, offset, linelen);		col_add_fstr(pinfo->cinfo, COL_INFO, "%s: %s",			     is_request ? "Request" : "Response",			     format_text(line, linelen));	}	if (tree) {		ti = proto_tree_add_item(tree, proto_imap, tvb, offset, -1, ENC_NA);		imap_tree = proto_item_add_subtree(ti, ett_imap);		hidden_item = proto_tree_add_boolean(imap_tree, hf_imap_isrequest, tvb, 0, 0, is_request);		PROTO_ITEM_SET_HIDDEN(hidden_item);		while(tvb_length_remaining(tvb, offset) > 2) {			/*			 * Find the end of each line			 *			 * Note that "tvb_find_line_end()" will return a value that is			 * not longer than what's in the buffer, so the "tvb_get_ptr()"			 * call won't throw an exception.			 */			linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);			line = tvb_get_ptr(tvb, offset, linelen);			/*			 * Put the line into the protocol tree.			 */			ti = proto_tree_add_item(imap_tree, hf_imap_line, tvb, offset,					next_offset - offset, ENC_ASCII|ENC_NA);			reqresp_tree = proto_item_add_subtree(ti, ett_imap_reqresp);			/*			 * Show each line as tags + requests or replies.			 */			/*			 * Extract the first token, and, if there is a first			 * token, add it as the request or reply tag.			 */			tokenlen = get_token_len(line, line + linelen, &next_token);			if (tokenlen != 0) {				proto_tree_add_item(reqresp_tree, (is_request) ? hf_imap_request_tag : hf_imap_response_tag,									tvb, offset, tokenlen, ENC_ASCII|ENC_NA);				offset += (gint) (next_token - line);				linelen -= (int) (next_token - line);				line = next_token;			}			/*			 * Add the rest of the line as request or reply data.			 */			if (linelen != 0) {				proto_tree_add_item(reqresp_tree, (is_request) ? hf_imap_request : hf_imap_response,									tvb, offset, linelen, ENC_ASCII|ENC_NA);			}			offset += linelen+2; /* Skip over last line and /r/n at the end of it */		}	}}
开发者ID:hubolo,项目名称:wireshark-1.8.0,代码行数:92,


示例19: col_set_str

    icap_type_t   icap_type;    int           datalen;    col_set_str(pinfo->cinfo, COL_PROTOCOL, "ICAP");    /*     * Put the first line from the buffer into the summary     * if it's an ICAP header (but leave out the     * line terminator).     * Otherwise, just call it a continuation.     *     * Note that "tvb_find_line_end()" will return a value that     * is not longer than what's in the buffer, so the     * "tvb_get_ptr()" call won't throw an exception.     */    linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);    line = tvb_get_ptr(tvb, offset, linelen);    icap_type = ICAP_OTHER; /* type not known yet */    if (is_icap_message(line, linelen, &icap_type))        col_add_str(pinfo->cinfo, COL_INFO,            format_text(line, linelen));    else        col_set_str(pinfo->cinfo, COL_INFO, "Continuation");    if (tree) {        ti = proto_tree_add_item(tree, proto_icap, tvb, offset, -1,            ENC_NA);        icap_tree = proto_item_add_subtree(ti, ett_icap);    }    /*
开发者ID:appneta,项目名称:wireshark,代码行数:31,


示例20: dissect_kismet

static gbooleandissect_kismet(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree){	gboolean is_request;	gboolean is_continuation;	proto_tree *kismet_tree=NULL, *reqresp_tree=NULL;	proto_item *ti;	proto_item *tmp_item;	gint offset = 0;	const guchar *line;	gint next_offset;	int linelen;	int tokenlen;	int i;	const guchar *next_token;	/*	 * Find the end of the first line.	 *	 * Note that "tvb_find_line_end()" will return a value that is	 * not longer than what's in the buffer, so the "tvb_get_ptr()"	 * call won't throw an exception.	 */	linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);	line = tvb_get_ptr(tvb, offset, linelen);	/*	 * Check if it is an ASCII based protocol with reasonable length	 * packets, if not return, and try annother dissector.	 */	if (linelen < 8) {		/*		 * Packet is too short		 */		return FALSE;	} else {		for (i = 0; i < 8; ++i) {			/*			 * Packet contains non-ASCII data			 */			if (line[i] < 32 || line[i] > 128)				return FALSE;		}	}	/*	 * If it is Kismet traffic set COL_PROTOCOL.	 */	col_set_str(pinfo->cinfo, COL_PROTOCOL, "kismet");	/*	 * Check if it is request, reply or continuation.	 */	if (pinfo->match_port == pinfo->destport) {		is_request = TRUE;		is_continuation = FALSE;	} else {		is_request = FALSE;		is_continuation = response_is_continuation (line);	}	if (check_col(pinfo->cinfo, COL_INFO)) {		/*		 * Put the first line from the buffer into the summary		 * if it's a kismet request or reply (but leave out the		 * line terminator).		 * Otherwise, just call it a continuation.		 */		if (is_continuation)			col_set_str(pinfo->cinfo, COL_INFO, "Continuation");		else			col_add_fstr(pinfo->cinfo, COL_INFO, "%s: %s",				is_request ? "Request" : "Response",				format_text(line, linelen));	}	if (tree) {		ti = proto_tree_add_item(tree, proto_kismet, tvb, offset, -1, FALSE);		kismet_tree = proto_item_add_subtree(ti, ett_kismet);	}	if (is_continuation) {		/*		 * Put the whole packet into the tree as data.		 */		call_dissector(data_handle, tvb, pinfo, kismet_tree);		return TRUE;	}	if (is_request) {		tmp_item = proto_tree_add_boolean(kismet_tree,				hf_kismet_request, tvb, 0, 0, TRUE);	} else {		tmp_item = proto_tree_add_boolean(kismet_tree,				hf_kismet_response, tvb, 0, 0, TRUE);	}	PROTO_ITEM_SET_GENERATED (tmp_item);	while (tvb_offset_exists(tvb, offset)) {		/*//.........这里部分代码省略.........
开发者ID:AkhilaAG,项目名称:gluster-wireshark-1.4,代码行数:101,


示例21: dissect_nntp

static voiddissect_nntp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){        const gchar     *type;	proto_tree	*nntp_tree;	proto_item	*ti;	gint		offset = 0;	gint		next_offset;	int		linelen;        if (pinfo->match_uint == pinfo->destport)        	type = "Request";        else        	type = "Response";	col_set_str(pinfo->cinfo, COL_PROTOCOL, "NNTP");	/*	 * Put the first line from the buffer into the summary	 * (but leave out the line terminator).	 *	 * Note that "tvb_find_line_end()" will return a value that	 * is not longer than what's in the buffer, so the	 * "tvb_get_ptr()" call won't throw an exception.	 */	linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);	col_add_fstr(pinfo->cinfo, COL_INFO, "%s: %s", type,		    tvb_format_text(tvb, offset, linelen));	if (tree) {		ti = proto_tree_add_item(tree, proto_nntp, tvb, offset, -1,		    ENC_NA);		nntp_tree = proto_item_add_subtree(ti, ett_nntp);		if (pinfo->match_uint == pinfo->destport) {			ti = proto_tree_add_boolean(nntp_tree,			    hf_nntp_request, tvb, 0, 0, TRUE);		} else {			ti = proto_tree_add_boolean(nntp_tree,			    hf_nntp_response, tvb, 0, 0, TRUE);		}		PROTO_ITEM_SET_HIDDEN(ti);		/*		 * Show the request or response as text, a line at a time.		 * XXX - for requests, we could display the stuff after the		 * first line, if any, based on what the request was, and		 * for responses, we could display it based on what the		 * matching request was, although the latter requires us to		 * know what the matching request was....		 */		while (tvb_offset_exists(tvb, offset)) {			/*			 * Find the end of the line.			 */			tvb_find_line_end(tvb, offset, -1, &next_offset,			    FALSE);			/*			 * Put this line.			 */			proto_tree_add_text(nntp_tree, tvb, offset,			    next_offset - offset, "%s",			    tvb_format_text(tvb, offset, next_offset - offset));			offset = next_offset;		}	}}
开发者ID:dot-Sean,项目名称:wireshark-http2,代码行数:68,


示例22: dissect_l1_events

/* Subtrees */static gint ett_l1_events = -1;static intdissect_l1_events(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_){	proto_tree	*subtree;	proto_item	*ti;	gint		offset = 0, next_offset;	gint		len;	col_set_str(pinfo->cinfo, COL_PROTOCOL, "Layer1");	col_set_str(pinfo->cinfo, COL_DEF_SRC,			    pinfo->pseudo_header->l1event.uton? "TE" : "NT");	len = tvb_find_line_end(tvb, 0, tvb_ensure_length_remaining(tvb, 0),					&next_offset, FALSE);	if(len>0)		col_add_str(pinfo->cinfo, COL_INFO, tvb_format_text(tvb, 0, len));	if (tree) {		ti = proto_tree_add_item(tree, proto_l1_events,				tvb, 0, -1, ENC_NA);		subtree = proto_item_add_subtree(ti, ett_l1_events);		/* Read the media line by line */		while (tvb_offset_exists(tvb, offset)) {			/*			 * XXX - we need to be passed the parameters			 * of the content type via data parameter,			 * so that we know the character set.  We'd			 * have to handle that character set, which			 * might be a multibyte character set such
开发者ID:ajitlakhwani,项目名称:wireshark,代码行数:31,


示例23: req_resp_hdrs_do_reassembly

/* * Optionally do reassembly of the request/response line, headers, and body. */gbooleanreq_resp_hdrs_do_reassembly(tvbuff_t *tvb, const int offset, packet_info *pinfo,    const gboolean desegment_headers, const gboolean desegment_body){	gint		next_offset;	gint		next_offset_sav;	gint		length_remaining, reported_length_remaining;	int			linelen;	gchar		*header_val;	long int	content_length;	gboolean	content_length_found = FALSE;	gboolean	content_type_found = FALSE;	gboolean	chunked_encoding = FALSE;	gboolean	keepalive_found = FALSE;	gchar		*line;	gchar		*content_type = NULL;	/*	 * Do header desegmentation if we've been told to.	 *	 * RFC 2616 defines HTTP messages as being either of the	 * Request or the Response type	 * (HTTP-message = Request | Response).	 * Request and Response are defined as:	 *     Request = Request-Line	 *         *(( general-header	 *         | request-header	 *         | entity-header ) CRLF)	 *         CRLF	 *         [ message-body ]	 *     Response = Status-Line	 *         *(( general-header	 *         | response-header	 *         | entity-header ) CRLF)	 *         CRLF	 *         [ message-body ]	 * that's why we can always assume two consecutive line	 * endings (we allow CR, LF, or CRLF, as some clients	 * or servers might not use a full CRLF) to mark the end	 * of the headers.  The worst thing that would happen	 * otherwise would be the packet not being desegmented	 * or being interpreted as only headers.	 *	 * RFC 2326 says RTSP works the same way; RFC 3261 says SIP	 * works the same way.	 */	/*	 * If header desegmentation is activated, check that all	 * headers are in this tvbuff (search for an empty line	 * marking end of headers) or request one more byte (we	 * don't know how many bytes we'll need, so we just ask	 * for one).	 */	if (desegment_headers && pinfo->can_desegment) {		next_offset = offset;		for (;;) {			next_offset_sav = next_offset;			reported_length_remaining =			    tvb_reported_length_remaining(tvb, next_offset);			/*			 * Request one more byte if there're no			 * bytes left in the reported data (if there're			 * bytes left in the reported data, but not in			 * the available data, requesting more bytes			 * won't help, as those bytes weren't captured).			 */			if (reported_length_remaining < 1) {				pinfo->desegment_offset = offset;				pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;				return FALSE;			}			length_remaining = tvb_length_remaining(tvb,			    next_offset);			/*			 * Request one more byte if we cannot find a			 * header (i.e. a line end).			 */			linelen = tvb_find_line_end(tvb, next_offset,			    -1, &next_offset, TRUE);			if (linelen == -1 &&			    length_remaining >= reported_length_remaining) {				/*				 * Not enough data; ask for one more				 * byte.				 */				pinfo->desegment_offset = offset;				pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;				return FALSE;			}                        if (linelen == 0) {				/*//.........这里部分代码省略.........
开发者ID:hubolo,项目名称:wireshark-1.8.0,代码行数:101,


示例24: dissect_text_lines

static intdissect_text_lines(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data){	proto_tree	*subtree;	proto_item	*ti;	gint		offset = 0, next_offset;	gint		len;	http_message_info_t *message_info;	const char	*data_name;	int length = tvb_captured_length(tvb);	/* Check if this is actually xml	 * If there is less than 38 characters this is not XML	 * <?xml version="1.0" encoding="UTF-8"?>	 */	if(length > 38){		if (tvb_strncaseeql(tvb, 0, "<?xml", 5) == 0){			call_dissector(xml_handle, tvb, pinfo, tree);			return length;		}	}	data_name = pinfo->match_string;	if (! (data_name && data_name[0])) {		/*		 * No information from "match_string"		 */		message_info = (http_message_info_t *)data;		if (message_info == NULL) {			/*			 * No information from dissector data			 */			data_name = NULL;		} else {			data_name = message_info->media_str;			if (! (data_name && data_name[0])) {				/*				 * No information from dissector data				 */				data_name = NULL;			}		}	}	if (data_name)		col_append_sep_fstr(pinfo->cinfo, COL_INFO, " ", "(%s)",				data_name);	if (tree) {		guint lines_read = 0;		ti = proto_tree_add_item(tree, proto_text_lines,				tvb, 0, -1, ENC_NA);		if (data_name)			proto_item_append_text(ti, ": %s", data_name);		subtree = proto_item_add_subtree(ti, ett_text_lines);		/* Read the media line by line */		while (tvb_offset_exists(tvb, offset)) {			/*			 * XXX - we need to be passed the parameters			 * of the content type via data parameter,			 * so that we know the character set.  We'd			 * have to handle that character set, which			 * might be a multibyte character set such			 * as "iso-10646-ucs-2", or might require other			 * special processing.			 */			len = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);			if (len == -1)				break;			/* We use next_offset - offset instead of len in the			 * call to proto_tree_add_format_text() so it will include the			 * line terminator(s) (/r and/or /n) in the display.			 */			proto_tree_add_format_text(subtree, tvb, offset, next_offset - offset);			lines_read++;			offset = next_offset;		}		proto_item_append_text(subtree, " (%u lines)", lines_read);	}	return length;}
开发者ID:HeartFlying,项目名称:wireshark,代码行数:83,


示例25: dissect_imap

static voiddissect_imap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){  gboolean        is_request;  proto_tree      *imap_tree, *reqresp_tree;  proto_item      *ti, *hidden_item;  gint            offset = 0;  gint            uid_offset = 0;  gint            folder_offset = 0;  const guchar    *line;  const guchar    *uid_line;  const guchar    *folder_line;  gint            next_offset;  int             linelen;  int             tokenlen;  int             uid_tokenlen;  int             folder_tokenlen;  const guchar    *next_token;  const guchar    *uid_next_token;  const guchar    *folder_next_token;  guchar          *tokenbuf;  guchar          *command_token;  int             iter;  int             commandlen;  conversation_t *conversation;  imap_state_t   *session_state;  conversation = find_or_create_conversation(pinfo);  session_state = (imap_state_t *)conversation_get_proto_data(conversation, proto_imap);  if (!session_state) {    session_state = wmem_new0(wmem_file_scope(), imap_state_t);    session_state->ssl_requested = FALSE;    conversation_add_proto_data(conversation, proto_imap, session_state);  }  tokenbuf = (guchar *)wmem_alloc0(wmem_packet_scope(), MAX_BUFFER);  command_token = (guchar *)wmem_alloc0(wmem_packet_scope(), MAX_BUFFER);  commandlen = 0;  folder_offset = 0;  folder_tokenlen = 0;  folder_line = NULL;  col_set_str(pinfo->cinfo, COL_PROTOCOL, "IMAP");  if (pinfo->match_uint == pinfo->destport)    is_request = TRUE;  else    is_request = FALSE;  /*   * Put the first line from the buffer into the summary   * (but leave out the line terminator).   */  linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);  line = tvb_get_ptr(tvb, offset, linelen);  col_add_fstr(pinfo->cinfo, COL_INFO, "%s: %s", is_request ? "Request" : "Response", format_text(line, linelen));  {    ti = proto_tree_add_item(tree, proto_imap, tvb, offset, -1, ENC_NA);    imap_tree = proto_item_add_subtree(ti, ett_imap);    hidden_item = proto_tree_add_boolean(imap_tree, hf_imap_isrequest, tvb, 0, 0, is_request);    PROTO_ITEM_SET_HIDDEN(hidden_item);    while(tvb_offset_exists(tvb, offset)) {      /*       * Find the end of each line       *       * Note that "tvb_find_line_end()" will return a value that is       * not longer than what's in the buffer, so the "tvb_get_ptr()"       * call won't throw an exception.       */      linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);      line = tvb_get_ptr(tvb, offset, linelen);      /*       * Put the line into the protocol tree.       */      ti = proto_tree_add_item(imap_tree, hf_imap_line, tvb, offset, next_offset - offset, ENC_ASCII|ENC_NA);      reqresp_tree = proto_item_add_subtree(ti, ett_imap_reqresp);      /*       * Check that the line doesn't begin with '*', because that's a continuation line.       * Otherwise if a tag is present then extract tokens.       */      if ( (line) && ((line[0] != '*') || (TRUE == is_request)) ) {        /*         * Show each line as tags + requests or replies.         */        /*         * Extract the first token, and, if there is a first         * token, add it as the request or reply tag.         */        tokenlen = get_token_len(line, line + linelen, &next_token);        if (tokenlen != 0) {          proto_tree_add_item(reqresp_tree, (is_request) ? hf_imap_request_tag : hf_imap_response_tag, tvb, offset, tokenlen, ENC_ASCII|ENC_NA);//.........这里部分代码省略.........
开发者ID:MultipathDTLS,项目名称:wireshark,代码行数:101,



注:本文中的tvb_find_line_end函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ tvb_format_text函数代码示例
C++ tvb_find_guint8函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。