本文整理汇总了C++中TLV_CHECK函数的典型用法代码示例。如果您正苦于以下问题:C++ TLV_CHECK函数的具体用法?C++ TLV_CHECK怎么用?C++ TLV_CHECK使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TLV_CHECK函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tipc_cfg_reply_error_string
static struct sk_buff *cfg_set_own_addr(void)
{
u32 addr;
if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR))
return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
addr = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
if (addr == tipc_own_addr)
return tipc_cfg_reply_none();
if (!tipc_addr_node_valid(addr))
return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
" (node address)");
if (tipc_mode == TIPC_NET_MODE)
return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
" (cannot change node address once assigned)");
tipc_own_addr = addr;
/*
* Must release all spinlocks before calling start_net() because
* Linux version of TIPC calls eth_media_start() which calls
* register_netdevice_notifier() which may block!
*
* Temporarily releasing the lock should be harmless for non-Linux TIPC,
* but Linux version of eth_media_start() should really be reworked
* so that it can be called with spinlocks held.
*/
spin_unlock_bh(&config_lock);
tipc_core_start_net();
spin_lock_bh(&config_lock);
return tipc_cfg_reply_none();
}
示例2: tipc_cfg_reply_error_string
static struct sk_buff *tipc_show_stats(void)
{
struct sk_buff *buf;
struct tlv_desc *rep_tlv;
struct print_buf pb;
int str_len;
u32 value;
if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
value = ntohl(*(u32 *)TLV_DATA(req_tlv_area));
if (value != 0)
return tipc_cfg_reply_error_string("unsupported argument");
buf = tipc_cfg_reply_alloc(TLV_SPACE(MAX_STATS_INFO));
if (buf == NULL)
return NULL;
rep_tlv = (struct tlv_desc *)buf->data;
tipc_printbuf_init(&pb, (char *)TLV_DATA(rep_tlv), MAX_STATS_INFO);
tipc_printf(&pb, "TIPC version " TIPC_MOD_VER "\n");
/* Use additional tipc_printf()'s to return more info ... */
str_len = tipc_printbuf_validate(&pb);
skb_put(buf, TLV_SPACE(str_len));
TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len);
return buf;
}
示例3: tipc_cfg_reply_error_string
static struct sk_buff *tipc_show_stats(void)
{
struct sk_buff *buf;
struct tlv_desc *rep_tlv;
char *pb;
int pb_len;
int str_len;
u32 value;
if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
value = ntohl(*(u32 *)TLV_DATA(req_tlv_area));
if (value != 0)
return tipc_cfg_reply_error_string("unsupported argument");
buf = tipc_cfg_reply_alloc(TLV_SPACE(ULTRA_STRING_MAX_LEN));
if (buf == NULL)
return NULL;
rep_tlv = (struct tlv_desc *)buf->data;
pb = TLV_DATA(rep_tlv);
pb_len = ULTRA_STRING_MAX_LEN;
str_len = tipc_snprintf(pb, pb_len, "TIPC version " TIPC_MOD_VER "\n");
str_len += 1; /* for "\0" */
skb_put(buf, TLV_SPACE(str_len));
TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len);
return buf;
}
示例4: tipc_cfg_reply_error_string
struct sk_buff *tipc_log_resize(const void *req_tlv_area, int req_tlv_space)
{
u32 value;
if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
if (value != delimit(value, 0, 32768))
return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
" (log size must be 0-32768)");
tipc_log_reinit(value);
return tipc_cfg_reply_none();
}
示例5: tipc_cfg_reply_error_string
struct sk_buff *tipc_log_resize_cmd(const void *req_tlv_area, int req_tlv_space)
{
u32 value;
if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
if (value > 32768)
return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
" (log size must be 0-32768)");
if (tipc_log_resize(value))
return tipc_cfg_reply_error_string(
"unable to create specified log (log size is now 0)");
return tipc_cfg_reply_none();
}
示例6: tipc_cfg_reply_error_string
static struct sk_buff *cfg_set_own_addr(void)
{
u32 addr;
if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR))
return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
addr = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
if (addr == tipc_own_addr)
return tipc_cfg_reply_none();
if (!tipc_addr_node_valid(addr))
return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
" (node address)");
if (tipc_own_addr)
return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
" (cannot change node address once assigned)");
tipc_net_start(addr);
return tipc_cfg_reply_none();
}
示例7: dissect_pgmopts
static void
dissect_pgmopts(ptvcursor_t* cursor, packet_info *pinfo, const char *pktname)
{
proto_item *tf, *ti, *ti_len;
proto_tree *opts_tree = NULL;
proto_tree *opt_tree = NULL;
tvbuff_t *tvb = ptvcursor_tvbuff(cursor);
gboolean theend = FALSE;
guint16 opts_total_len;
guint8 genopts_type;
guint8 genopts_len;
guint8 opts_type;
opts_tree = proto_tree_add_subtree_format(ptvcursor_tree(cursor), tvb, ptvcursor_current_offset(cursor), -1,
ett_pgm_opts, &tf, "%s Options", pktname);
ptvcursor_set_tree(cursor, opts_tree);
opts_type = tvb_get_guint8(tvb, ptvcursor_current_offset(cursor));
ti = ptvcursor_add(cursor, hf_pgm_opt_type, 1, ENC_BIG_ENDIAN);
if (opts_type != PGM_OPT_LENGTH) {
expert_add_info_format(pinfo, ti, &ei_pgm_opt_type,
"%s Options - initial option is %s, should be %s",
pktname,
val_to_str(opts_type, opt_vals, "Unknown (0x%02x)"),
val_to_str(PGM_OPT_LENGTH, opt_vals, "Unknown (0x%02x)"));
return;
}
ptvcursor_add(cursor, hf_pgm_opt_len, 1, ENC_BIG_ENDIAN);
opts_total_len = tvb_get_ntohs(tvb, ptvcursor_current_offset(cursor));
proto_item_append_text(tf, " (Total Length %d)", opts_total_len);
proto_item_set_len(tf, opts_total_len);
ti_len = ptvcursor_add(cursor, hf_pgm_opt_tlen, 2, ENC_BIG_ENDIAN);
if (opts_total_len < 4) {
expert_add_info_format(pinfo, ti_len, &ei_pgm_opt_tlen,
"%s Options (Total Length %u - invalid, must be >= 4)",
pktname, opts_total_len);
return;
}
for (opts_total_len -= 4; !theend && opts_total_len != 0;){
if (opts_total_len < 4) {
expert_add_info_format(pinfo, ti_len, &ei_pgm_opt_tlen,
"Remaining total options length doesn't have enough for an options header");
break;
}
genopts_type = tvb_get_guint8(tvb, ptvcursor_current_offset(cursor));
genopts_len = tvb_get_guint8(tvb, ptvcursor_current_offset(cursor)+1);
if (genopts_type & PGM_OPT_END) {
genopts_type &= ~PGM_OPT_END;
theend = TRUE;
}
switch(genopts_type) {
case PGM_OPT_JOIN:{
TLV_CHECK(ett_pgm_opts_join);
ptvcursor_set_tree(cursor, opt_tree);
ptvcursor_add_no_advance(cursor, hf_pgm_genopt_end, 1, ENC_BIG_ENDIAN);
ptvcursor_add(cursor, hf_pgm_genopt_type, 1, ENC_BIG_ENDIAN);
if (genopts_len < PGM_OPT_JOIN_SIZE) {
proto_tree_add_uint_format_value(opt_tree, hf_pgm_genopt_len, tvb,
ptvcursor_current_offset(cursor), 1, genopts_len,
"%u (bogus, must be >= %u)",
genopts_len, PGM_OPT_JOIN_SIZE);
break;
}
ptvcursor_add(cursor, hf_pgm_genopt_len, 1, ENC_BIG_ENDIAN);
ptvcursor_add(cursor, hf_pgm_genopt_opx, 1, ENC_BIG_ENDIAN);
ptvcursor_add(cursor, hf_pgm_opt_join_res, 1, ENC_BIG_ENDIAN);
ptvcursor_add(cursor, hf_pgm_opt_join_minjoin, 4, ENC_BIG_ENDIAN);
break;
}
case PGM_OPT_PARITY_PRM:{
guint8 optdata_po;
TLV_CHECK(ett_pgm_opts_parityprm);
ptvcursor_set_tree(cursor, opt_tree);
ptvcursor_add_no_advance(cursor, hf_pgm_genopt_end, 1, ENC_BIG_ENDIAN);
ptvcursor_add(cursor, hf_pgm_genopt_type, 1, ENC_BIG_ENDIAN);
if (genopts_len < PGM_OPT_PARITY_PRM_SIZE) {
proto_tree_add_uint_format_value(opt_tree, hf_pgm_genopt_len, ptvcursor_tvbuff(cursor),
ptvcursor_current_offset(cursor), 1, genopts_len,
"%u (bogus, must be >= %u)",
genopts_len, PGM_OPT_PARITY_PRM_SIZE);
break;
}
ptvcursor_add(cursor, hf_pgm_genopt_len, 1, ENC_BIG_ENDIAN);
ptvcursor_add(cursor, hf_pgm_genopt_opx, 1, ENC_BIG_ENDIAN);
optdata_po = tvb_get_guint8(tvb, ptvcursor_current_offset(cursor));
proto_tree_add_uint_format_value(opt_tree, hf_pgm_opt_parity_prm_po, tvb,
ptvcursor_current_offset(cursor), 1, optdata_po, "%s (0x%x)",
paritystr(optdata_po), optdata_po);
//.........这里部分代码省略.........