本文整理汇总了C++中NLA_PUT_U8函数的典型用法代码示例。如果您正苦于以下问题:C++ NLA_PUT_U8函数的具体用法?C++ NLA_PUT_U8怎么用?C++ NLA_PUT_U8使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NLA_PUT_U8函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ieee802154_nl_scan_confirm
int ieee802154_nl_scan_confirm(struct net_device *dev,
u8 status, u8 scan_type, u32 unscanned, u8 page,
u8 *edl/* */)
{
struct sk_buff *msg;
pr_debug("%s\n", __func__);
msg = ieee802154_nl_create(0, IEEE802154_SCAN_CONF);
if (!msg)
return -ENOBUFS;
NLA_PUT_STRING(msg, IEEE802154_ATTR_DEV_NAME, dev->name);
NLA_PUT_U32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex);
NLA_PUT(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN,
dev->dev_addr);
NLA_PUT_U8(msg, IEEE802154_ATTR_STATUS, status);
NLA_PUT_U8(msg, IEEE802154_ATTR_SCAN_TYPE, scan_type);
NLA_PUT_U32(msg, IEEE802154_ATTR_CHANNELS, unscanned);
NLA_PUT_U8(msg, IEEE802154_ATTR_PAGE, page);
if (edl)
NLA_PUT(msg, IEEE802154_ATTR_ED_LIST, 27, edl);
return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id);
nla_put_failure:
nlmsg_free(msg);
return -ENOBUFS;
}
开发者ID:romanbb,项目名称:android_kernel_lge_d851,代码行数:31,代码来源:nl-mac.c
示例2: __near_netlink_dep_link_up
int __near_netlink_dep_link_up(uint32_t idx, uint32_t target_idx,
uint8_t comm_mode, uint8_t rf_mode)
{
struct nl_msg *msg;
void *hdr;
int err;
DBG("");
msg = nlmsg_alloc();
if (!msg)
return -ENOMEM;
hdr = genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, nfc_state->nfc_id, 0,
NLM_F_REQUEST, NFC_CMD_DEP_LINK_UP, NFC_GENL_VERSION);
if (!hdr) {
err = -EINVAL;
goto nla_put_failure;
}
err = -EMSGSIZE;
NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, idx);
NLA_PUT_U32(msg, NFC_ATTR_TARGET_INDEX, target_idx);
NLA_PUT_U8(msg, NFC_ATTR_COMM_MODE, comm_mode);
NLA_PUT_U8(msg, NFC_ATTR_RF_MODE, rf_mode);
err = nl_send_msg(nfc_state->cmd_sock, msg, NULL, NULL);
nla_put_failure:
nlmsg_free(msg);
return err;
}
开发者ID:aklein53,项目名称:neard,代码行数:34,代码来源:netlink.c
示例3: l2tp_nl_session_send
static int l2tp_nl_session_send(struct sk_buff *skb, u32 pid, u32 seq, int flags,
struct l2tp_session *session)
{
void *hdr;
struct nlattr *nest;
struct l2tp_tunnel *tunnel = session->tunnel;
struct sock *sk = NULL;
sk = tunnel->sock;
hdr = genlmsg_put(skb, pid, seq, &l2tp_nl_family, flags, L2TP_CMD_SESSION_GET);
if (IS_ERR(hdr))
return PTR_ERR(hdr);
NLA_PUT_U32(skb, L2TP_ATTR_CONN_ID, tunnel->tunnel_id);
NLA_PUT_U32(skb, L2TP_ATTR_SESSION_ID, session->session_id);
NLA_PUT_U32(skb, L2TP_ATTR_PEER_CONN_ID, tunnel->peer_tunnel_id);
NLA_PUT_U32(skb, L2TP_ATTR_PEER_SESSION_ID, session->peer_session_id);
NLA_PUT_U32(skb, L2TP_ATTR_DEBUG, session->debug);
NLA_PUT_U16(skb, L2TP_ATTR_PW_TYPE, session->pwtype);
NLA_PUT_U16(skb, L2TP_ATTR_MTU, session->mtu);
if (session->mru)
NLA_PUT_U16(skb, L2TP_ATTR_MRU, session->mru);
if (session->ifname && session->ifname[0])
NLA_PUT_STRING(skb, L2TP_ATTR_IFNAME, session->ifname);
if (session->cookie_len)
NLA_PUT(skb, L2TP_ATTR_COOKIE, session->cookie_len, &session->cookie[0]);
if (session->peer_cookie_len)
NLA_PUT(skb, L2TP_ATTR_PEER_COOKIE, session->peer_cookie_len, &session->peer_cookie[0]);
NLA_PUT_U8(skb, L2TP_ATTR_RECV_SEQ, session->recv_seq);
NLA_PUT_U8(skb, L2TP_ATTR_SEND_SEQ, session->send_seq);
NLA_PUT_U8(skb, L2TP_ATTR_LNS_MODE, session->lns_mode);
#ifdef CONFIG_XFRM
if ((sk) && (sk->sk_policy[0] || sk->sk_policy[1]))
NLA_PUT_U8(skb, L2TP_ATTR_USING_IPSEC, 1);
#endif
if (session->reorder_timeout)
NLA_PUT_MSECS(skb, L2TP_ATTR_RECV_TIMEOUT, session->reorder_timeout);
nest = nla_nest_start(skb, L2TP_ATTR_STATS);
if (nest == NULL)
goto nla_put_failure;
NLA_PUT_U64(skb, L2TP_ATTR_TX_PACKETS, session->stats.tx_packets);
NLA_PUT_U64(skb, L2TP_ATTR_TX_BYTES, session->stats.tx_bytes);
NLA_PUT_U64(skb, L2TP_ATTR_TX_ERRORS, session->stats.tx_errors);
NLA_PUT_U64(skb, L2TP_ATTR_RX_PACKETS, session->stats.rx_packets);
NLA_PUT_U64(skb, L2TP_ATTR_RX_BYTES, session->stats.rx_bytes);
NLA_PUT_U64(skb, L2TP_ATTR_RX_SEQ_DISCARDS, session->stats.rx_seq_discards);
NLA_PUT_U64(skb, L2TP_ATTR_RX_OOS_PACKETS, session->stats.rx_oos_packets);
NLA_PUT_U64(skb, L2TP_ATTR_RX_ERRORS, session->stats.rx_errors);
nla_nest_end(skb, nest);
return genlmsg_end(skb, hdr);
nla_put_failure:
genlmsg_cancel(skb, hdr);
return -1;
}
开发者ID:0xroot,项目名称:Blackphone-BP1-Kernel,代码行数:59,代码来源:l2tp_netlink.c
示例4: l2tp_nl_tunnel_send
static int l2tp_nl_tunnel_send(struct sk_buff *skb, u32 pid, u32 seq, int flags,
struct l2tp_tunnel *tunnel)
{
void *hdr;
struct nlattr *nest;
struct sock *sk = NULL;
struct inet_sock *inet;
hdr = genlmsg_put(skb, pid, seq, &l2tp_nl_family, flags,
L2TP_CMD_TUNNEL_GET);
if (IS_ERR(hdr))
return PTR_ERR(hdr);
NLA_PUT_U8(skb, L2TP_ATTR_PROTO_VERSION, tunnel->version);
NLA_PUT_U32(skb, L2TP_ATTR_CONN_ID, tunnel->tunnel_id);
NLA_PUT_U32(skb, L2TP_ATTR_PEER_CONN_ID, tunnel->peer_tunnel_id);
NLA_PUT_U32(skb, L2TP_ATTR_DEBUG, tunnel->debug);
NLA_PUT_U16(skb, L2TP_ATTR_ENCAP_TYPE, tunnel->encap);
nest = nla_nest_start(skb, L2TP_ATTR_STATS);
if (nest == NULL)
goto nla_put_failure;
NLA_PUT_U64(skb, L2TP_ATTR_TX_PACKETS, tunnel->stats.tx_packets);
NLA_PUT_U64(skb, L2TP_ATTR_TX_BYTES, tunnel->stats.tx_bytes);
NLA_PUT_U64(skb, L2TP_ATTR_TX_ERRORS, tunnel->stats.tx_errors);
NLA_PUT_U64(skb, L2TP_ATTR_RX_PACKETS, tunnel->stats.rx_packets);
NLA_PUT_U64(skb, L2TP_ATTR_RX_BYTES, tunnel->stats.rx_bytes);
NLA_PUT_U64(skb, L2TP_ATTR_RX_SEQ_DISCARDS, tunnel->stats.rx_seq_discards);
NLA_PUT_U64(skb, L2TP_ATTR_RX_OOS_PACKETS, tunnel->stats.rx_oos_packets);
NLA_PUT_U64(skb, L2TP_ATTR_RX_ERRORS, tunnel->stats.rx_errors);
nla_nest_end(skb, nest);
sk = tunnel->sock;
if (!sk)
goto out;
inet = inet_sk(sk);
switch (tunnel->encap) {
case L2TP_ENCAPTYPE_UDP:
NLA_PUT_U16(skb, L2TP_ATTR_UDP_SPORT, ntohs(inet->inet_sport));
NLA_PUT_U16(skb, L2TP_ATTR_UDP_DPORT, ntohs(inet->inet_dport));
NLA_PUT_U8(skb, L2TP_ATTR_UDP_CSUM, (sk->sk_no_check != UDP_CSUM_NOXMIT));
/* NOBREAK */
case L2TP_ENCAPTYPE_IP:
NLA_PUT_BE32(skb, L2TP_ATTR_IP_SADDR, inet->inet_saddr);
NLA_PUT_BE32(skb, L2TP_ATTR_IP_DADDR, inet->inet_daddr);
break;
}
out:
return genlmsg_end(skb, hdr);
nla_put_failure:
genlmsg_cancel(skb, hdr);
return -1;
}
开发者ID:0xroot,项目名称:Blackphone-BP1-Kernel,代码行数:58,代码来源:l2tp_netlink.c
示例5: scan_request
static iz_res_t scan_request(struct iz_cmd *cmd, struct nl_msg *msg) {
int type;
int duration;
char *dummy;
int channels;
if (cmd->argc != 5) {
printf("Incorrect number of arguments!\n");
return IZ_STOP_ERR;
}
if (!cmd->argv[1])
return IZ_STOP_ERR;
NLA_PUT_STRING(msg, IEEE802154_ATTR_DEV_NAME, cmd->argv[1]);
if (!cmd->argv[2])
return IZ_STOP_ERR;
if (!strcmp(cmd->argv[2], "ed")) {
type = IEEE802154_MAC_SCAN_ED;
} else if (!strcmp(cmd->argv[2], "active")) {
type = IEEE802154_MAC_SCAN_ACTIVE;
} else if (!strcmp(cmd->argv[2], "passive")) {
type = IEEE802154_MAC_SCAN_PASSIVE;
} else if (!strcmp(cmd->argv[2], "orphan")) {
type = IEEE802154_MAC_SCAN_ORPHAN;
} else {
printf("Unknown scan type %s!\n", cmd->argv[2]);
return IZ_STOP_ERR;
}
if (!cmd->argv[3])
return IZ_STOP_ERR;
channels = strtol(cmd->argv[3], &dummy, 16);
if (*dummy) {
printf("Bad channels %s!\n", cmd->argv[3]);
return IZ_STOP_ERR;
}
if (!cmd->argv[4])
return IZ_STOP_ERR;
duration = strtol(cmd->argv[4], &dummy, 10);
if (*dummy) {
printf("Bad duration %s!\n", cmd->argv[4]);
return IZ_STOP_ERR;
}
NLA_PUT_U8(msg, IEEE802154_ATTR_SCAN_TYPE, type);
NLA_PUT_U32(msg, IEEE802154_ATTR_CHANNELS, channels);
NLA_PUT_U8(msg, IEEE802154_ATTR_DURATION, duration);
return IZ_CONT_OK;
nla_put_failure:
return IZ_STOP_ERR;
}
开发者ID:FabianKnapp,项目名称:android-wmon,代码行数:55,代码来源:iz-mac.c
示例6: icmpv6_tuple_to_nlattr
static int icmpv6_tuple_to_nlattr(struct sk_buff *skb,
const struct nf_conntrack_tuple *t)
{
NLA_PUT_BE16(skb, CTA_PROTO_ICMPV6_ID, t->src.u.icmp.id);
NLA_PUT_U8(skb, CTA_PROTO_ICMPV6_TYPE, t->dst.u.icmp.type);
NLA_PUT_U8(skb, CTA_PROTO_ICMPV6_CODE, t->dst.u.icmp.code);
return 0;
nla_put_failure:
return -1;
}
开发者ID:AdrianHuang,项目名称:uclinux-robutest,代码行数:12,代码来源:nf_conntrack_proto_icmpv6.c
示例7: parse_4addr_flag
static int parse_4addr_flag(const char *value, struct nl_msg *msg)
{
if (strcmp(value, "on") == 0)
NLA_PUT_U8(msg, NL80211_ATTR_4ADDR, 1);
else if (strcmp(value, "off") == 0)
NLA_PUT_U8(msg, NL80211_ATTR_4ADDR, 0);
else
return 1;
return 0;
nla_put_failure:
return 1;
}
开发者ID:791254467,项目名称:android_device_lenovo_s899t,代码行数:13,代码来源:interface.c
示例8: join_mesh
int join_mesh(char* ifname, char *mesh_id, int mesh_id_len, char *vendor_ie, int vendor_ie_len)
{
struct nl_msg *msg;
uint8_t cmd = NL80211_CMD_JOIN_MESH;
int ret;
char *pret;
int ifindex = if_nametoindex(ifname);
msg = nlmsg_alloc();
if (!msg)
return -ENOMEM;
if (!mesh_id || !mesh_id_len)
return -EINVAL;
printf("o11s-pathseld: Staring mesh with mesh id = %s\n", mesh_id);
pret = genlmsg_put(msg, 0, 0,
genl_family_get_id(nlcfg.nl80211), 0, 0, cmd, 0);
if (pret == NULL)
goto nla_put_failure;
if (vendor_ie) {
struct nlattr *container = nla_nest_start(msg,
NL80211_ATTR_MESH_PARAMS);
if (!container)
return -ENOBUFS;
NLA_PUT(msg, NL80211_MESHCONF_VENDOR_PATH_SEL_IE,
vendor_ie_len, vendor_ie);
NLA_PUT_U8(msg, NL80211_MESHCONF_ENABLE_VENDOR_PATH_SEL, 1);
NLA_PUT_U8(msg, NL80211_MESHCONF_ENABLE_VENDOR_METRIC, 1);
nla_nest_end(msg, container);
}
NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, ifindex);
NLA_PUT(msg, NL80211_ATTR_MESH_ID, mesh_id_len, mesh_id);
ret = send_and_recv_msgs(msg, NULL, NULL);
if (ret)
printf("Mesh start failed: %d (%s)\n", ret,
strerror(-ret));
else
printf("Mesh start succeeded. Yay!\n");
return ret;
nla_put_failure:
return -ENOBUFS;
}
开发者ID:cozybit,项目名称:o11s-pathseld,代码行数:51,代码来源:main.c
示例9: plt_get_rx_statcs
static int plt_get_rx_statcs(struct nl80211_state *state, struct nl_cb *cb,
struct nl_msg *msg, int argc, char **argv)
{
struct nlattr *key;
struct wl1271_radio_rx_statcs prms;
prms.test.id = TEST_CMD_RX_STAT_GET;
key = nla_nest_start(msg, NL80211_ATTR_TESTDATA);
if (!key) {
fprintf(stderr, "%s> fail to nla_nest_start()\n", __func__);
return 1;
}
NLA_PUT_U32(msg, WL1271_TM_ATTR_CMD_ID, WL1271_TM_CMD_TEST);
NLA_PUT(msg, WL1271_TM_ATTR_DATA, sizeof(prms), &prms);
NLA_PUT_U8(msg, WL1271_TM_ATTR_ANSWER, 1);
nla_nest_end(msg, key);
nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, display_rx_statcs, NULL);
/* Important: needed gap between tx_start and tx_get */
sleep(2);
return 0;
nla_put_failure:
fprintf(stderr, "%s> building message failed\n", __func__);
return 2;
}
开发者ID:PavanSavoy,项目名称:ti-utils,代码行数:31,代码来源:plt.c
示例10: nfc_genl_send_target
static int nfc_genl_send_target(struct sk_buff *msg, struct nfc_target *target,
struct netlink_callback *cb, int flags)
{
void *hdr;
hdr = genlmsg_put(msg, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq,
&nfc_genl_family, flags, NFC_CMD_GET_TARGET);
if (!hdr)
return -EMSGSIZE;
genl_dump_check_consistent(cb, hdr, &nfc_genl_family);
NLA_PUT_U32(msg, NFC_ATTR_TARGET_INDEX, target->idx);
NLA_PUT_U32(msg, NFC_ATTR_PROTOCOLS, target->supported_protocols);
NLA_PUT_U16(msg, NFC_ATTR_TARGET_SENS_RES, target->sens_res);
NLA_PUT_U8(msg, NFC_ATTR_TARGET_SEL_RES, target->sel_res);
if (target->nfcid1_len > 0)
NLA_PUT(msg, NFC_ATTR_TARGET_NFCID1, target->nfcid1_len,
target->nfcid1);
if (target->sensb_res_len > 0)
NLA_PUT(msg, NFC_ATTR_TARGET_SENSB_RES, target->sensb_res_len,
target->sensb_res);
if (target->sensf_res_len > 0)
NLA_PUT(msg, NFC_ATTR_TARGET_SENSF_RES, target->sensf_res_len,
target->sensf_res);
return genlmsg_end(msg, hdr);
nla_put_failure:
genlmsg_cancel(msg, hdr);
return -EMSGSIZE;
}
开发者ID:0xroot,项目名称:Blackphone-BP1-Kernel,代码行数:32,代码来源:netlink.c
示例11: ieee802154_nl_disassoc_indic
int ieee802154_nl_disassoc_indic(struct net_device *dev,
struct ieee802154_addr *addr, u8 reason)
{
struct sk_buff *msg;
pr_debug("%s\n", __func__);
msg = ieee802154_nl_create(0, IEEE802154_DISASSOCIATE_INDIC);
if (!msg)
return -ENOBUFS;
NLA_PUT_STRING(msg, IEEE802154_ATTR_DEV_NAME, dev->name);
NLA_PUT_U32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex);
NLA_PUT(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN,
dev->dev_addr);
if (addr->addr_type == IEEE802154_ADDR_LONG)
NLA_PUT(msg, IEEE802154_ATTR_SRC_HW_ADDR, IEEE802154_ADDR_LEN,
addr->hwaddr);
else
NLA_PUT_U16(msg, IEEE802154_ATTR_SRC_SHORT_ADDR,
addr->short_addr);
NLA_PUT_U8(msg, IEEE802154_ATTR_REASON, reason);
return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id);
nla_put_failure:
nlmsg_free(msg);
return -ENOBUFS;
}
开发者ID:romanbb,项目名称:android_kernel_lge_d851,代码行数:31,代码来源:nl-mac.c
示例12: nfc_genl_send_device
static int nfc_genl_send_device(struct sk_buff *msg, struct nfc_dev *dev,
u32 pid, u32 seq,
struct netlink_callback *cb,
int flags)
{
void *hdr;
hdr = genlmsg_put(msg, pid, seq, &nfc_genl_family, flags,
NFC_CMD_GET_DEVICE);
if (!hdr)
return -EMSGSIZE;
if (cb)
genl_dump_check_consistent(cb, hdr, &nfc_genl_family);
NLA_PUT_STRING(msg, NFC_ATTR_DEVICE_NAME, nfc_device_name(dev));
NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx);
NLA_PUT_U32(msg, NFC_ATTR_PROTOCOLS, dev->supported_protocols);
NLA_PUT_U8(msg, NFC_ATTR_DEVICE_POWERED, dev->dev_up);
return genlmsg_end(msg, hdr);
nla_put_failure:
genlmsg_cancel(msg, hdr);
return -EMSGSIZE;
}
开发者ID:0xroot,项目名称:Blackphone-BP1-Kernel,代码行数:26,代码来源:netlink.c
示例13: nfc_genl_device_added
int nfc_genl_device_added(struct nfc_dev *dev)
{
struct sk_buff *msg;
void *hdr;
msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
if (!msg)
return -ENOMEM;
hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
NFC_EVENT_DEVICE_ADDED);
if (!hdr)
goto free_msg;
NLA_PUT_STRING(msg, NFC_ATTR_DEVICE_NAME, nfc_device_name(dev));
NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx);
NLA_PUT_U32(msg, NFC_ATTR_PROTOCOLS, dev->supported_protocols);
NLA_PUT_U8(msg, NFC_ATTR_DEVICE_POWERED, dev->dev_up);
genlmsg_end(msg, hdr);
genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.id, GFP_KERNEL);
return 0;
nla_put_failure:
genlmsg_cancel(msg, hdr);
free_msg:
nlmsg_free(msg);
return -EMSGSIZE;
}
开发者ID:0xroot,项目名称:Blackphone-BP1-Kernel,代码行数:31,代码来源:netlink.c
示例14: ieee802154_nl_assoc_indic
int ieee802154_nl_assoc_indic(struct net_device *dev,
struct ieee802154_addr *addr, u8 cap)
{
struct sk_buff *msg;
pr_debug("%s\n", __func__);
if (addr->addr_type != IEEE802154_ADDR_LONG) {
pr_err("%s: received non-long source address!\n", __func__);
return -EINVAL;
}
msg = ieee802154_nl_create(0, IEEE802154_ASSOCIATE_INDIC);
if (!msg)
return -ENOBUFS;
NLA_PUT_STRING(msg, IEEE802154_ATTR_DEV_NAME, dev->name);
NLA_PUT_U32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex);
NLA_PUT(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN,
dev->dev_addr);
NLA_PUT(msg, IEEE802154_ATTR_SRC_HW_ADDR, IEEE802154_ADDR_LEN,
addr->hwaddr);
NLA_PUT_U8(msg, IEEE802154_ATTR_CAPABILITY, cap);
return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id);
nla_put_failure:
nlmsg_free(msg);
return -ENOBUFS;
}
开发者ID:romanbb,项目名称:android_kernel_lge_d851,代码行数:32,代码来源:nl-mac.c
示例15: ieee802154_nl_assoc_confirm
int ieee802154_nl_assoc_confirm(struct net_device *dev, u16 short_addr,
u8 status)
{
struct sk_buff *msg;
pr_debug("%s\n", __func__);
msg = ieee802154_nl_create(0, IEEE802154_ASSOCIATE_CONF);
if (!msg)
return -ENOBUFS;
NLA_PUT_STRING(msg, IEEE802154_ATTR_DEV_NAME, dev->name);
NLA_PUT_U32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex);
NLA_PUT(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN,
dev->dev_addr);
NLA_PUT_U16(msg, IEEE802154_ATTR_SHORT_ADDR, short_addr);
NLA_PUT_U8(msg, IEEE802154_ATTR_STATUS, status);
return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id);
nla_put_failure:
nlmsg_free(msg);
return -ENOBUFS;
}
开发者ID:romanbb,项目名称:android_kernel_lge_d851,代码行数:25,代码来源:nl-mac.c
示例16: br_fill_ifinfo
/*
* Create one netlink message for one interface
* Contains port and master info as well as carrier and bridge state.
*/
static int br_fill_ifinfo(struct sk_buff *skb, const struct net_bridge_port *port,
u32 pid, u32 seq, int event, unsigned int flags)
{
const struct net_bridge *br = port->br;
const struct net_device *dev = port->dev;
struct ifinfomsg *hdr;
struct nlmsghdr *nlh;
u8 operstate = netif_running(dev) ? dev->operstate : IF_OPER_DOWN;
br_debug(br, "br_fill_info event %d port %s master %s\n",
event, dev->name, br->dev->name);
nlh = nlmsg_put(skb, pid, seq, event, sizeof(*hdr), flags);
if (nlh == NULL)
return -EMSGSIZE;
hdr = nlmsg_data(nlh);
hdr->ifi_family = AF_BRIDGE;
hdr->__ifi_pad = 0;
hdr->ifi_type = dev->type;
hdr->ifi_index = dev->ifindex;
hdr->ifi_flags = dev_get_flags(dev);
hdr->ifi_change = 0;
NLA_PUT_STRING(skb, IFLA_IFNAME, dev->name);
NLA_PUT_U32(skb, IFLA_MASTER, br->dev->ifindex);
NLA_PUT_U32(skb, IFLA_MTU, dev->mtu);
NLA_PUT_U8(skb, IFLA_OPERSTATE, operstate);
if (dev->addr_len)
NLA_PUT(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr);
if (dev->ifindex != dev->iflink)
NLA_PUT_U32(skb, IFLA_LINK, dev->iflink);
if (event == RTM_NEWLINK)
NLA_PUT_U8(skb, IFLA_PROTINFO, port->state);
return nlmsg_end(skb, nlh);
nla_put_failure:
nlmsg_cancel(skb, nlh);
return -EMSGSIZE;
}
开发者ID:develersrl,项目名称:winmate-kernel,代码行数:48,代码来源:br_netlink.c
示例17: hash_net4_data_list
static bool
hash_net4_data_list(struct sk_buff *skb, const struct hash_net4_elem *data)
{
NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, data->ip);
NLA_PUT_U8(skb, IPSET_ATTR_CIDR, data->cidr);
return 0;
nla_put_failure:
return 1;
}
开发者ID:daveti,项目名称:prov-kernel,代码行数:10,代码来源:ip_set_hash_net.c
示例18: ieee802154_nl_fill_phy
static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 pid,
u32 seq, int flags, struct wpan_phy *phy)
{
void *hdr;
int i, pages = 0;
uint32_t *buf = kzalloc(32 * sizeof(uint32_t), GFP_KERNEL);
pr_debug("%s\n", __func__);
if (!buf)
return -EMSGSIZE;
hdr = genlmsg_put(msg, 0, seq, &nl802154_family, flags,
IEEE802154_LIST_PHY);
if (!hdr)
goto out;
mutex_lock(&phy->pib_lock);
NLA_PUT_STRING(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy));
NLA_PUT_U8(msg, IEEE802154_ATTR_PAGE, phy->current_page);
NLA_PUT_U8(msg, IEEE802154_ATTR_CHANNEL, phy->current_channel);
for (i = 0; i < 32; i++) {
if (phy->channels_supported[i])
buf[pages++] = phy->channels_supported[i] | (i << 27);
}
if (pages)
NLA_PUT(msg, IEEE802154_ATTR_CHANNEL_PAGE_LIST,
pages * sizeof(uint32_t), buf);
mutex_unlock(&phy->pib_lock);
kfree(buf);
return genlmsg_end(msg, hdr);
nla_put_failure:
mutex_unlock(&phy->pib_lock);
genlmsg_cancel(msg, hdr);
out:
kfree(buf);
return -EMSGSIZE;
}
开发者ID:CSCLOG,项目名称:beaglebone,代码行数:41,代码来源:nl-phy.c
示例19: hash_ipport4_data_list
static bool
hash_ipport4_data_list(struct sk_buff *skb,
const struct hash_ipport4_elem *data)
{
NLA_PUT_IPADDR4(skb, IPSET_ATTR_IP, data->ip);
NLA_PUT_NET16(skb, IPSET_ATTR_PORT, data->port);
NLA_PUT_U8(skb, IPSET_ATTR_PROTO, data->proto);
return 0;
nla_put_failure:
return 1;
}
开发者ID:1yankeedt,项目名称:D710BST_FL24_Kernel,代码行数:12,代码来源:ip_set_hash_ipport.c
示例20: inet6_fill_af
static int inet6_fill_af(struct rtnl_link *link, struct nl_msg *msg, void *data)
{
struct inet6_data *id = data;
if (id->i6_addr_gen_mode != I6_ADDR_GEN_MODE_UNKNOWN)
NLA_PUT_U8(msg, IFLA_INET6_ADDR_GEN_MODE, id->i6_addr_gen_mode);
return 0;
nla_put_failure:
return -NLE_MSGSIZE;
}
开发者ID:Domikk,项目名称:libnl,代码行数:12,代码来源:inet6.c
注:本文中的NLA_PUT_U8函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论