本文整理汇总了C++中NLA_PUT_U32函数的典型用法代码示例。如果您正苦于以下问题:C++ NLA_PUT_U32函数的具体用法?C++ NLA_PUT_U32怎么用?C++ NLA_PUT_U32使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NLA_PUT_U32函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: __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;
}
示例4: 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;
}
示例5: wifi_nl80211_set_mode
static gboolean
wifi_nl80211_set_mode (WifiData *data, const NM80211Mode mode)
{
WifiDataNl80211 *nl80211 = (WifiDataNl80211 *) data;
struct nl_msg *msg;
int err;
msg = nl80211_alloc_msg (nl80211, NL80211_CMD_SET_INTERFACE, 0);
switch (mode) {
case NM_802_11_MODE_INFRA:
NLA_PUT_U32 (msg, NL80211_ATTR_IFTYPE, NL80211_IFTYPE_STATION);
break;
case NM_802_11_MODE_ADHOC:
NLA_PUT_U32 (msg, NL80211_ATTR_IFTYPE, NL80211_IFTYPE_ADHOC);
break;
case NM_802_11_MODE_AP:
NLA_PUT_U32 (msg, NL80211_ATTR_IFTYPE, NL80211_IFTYPE_AP);
break;
default:
g_assert_not_reached ();
}
err = nl80211_send_and_recv (nl80211, msg, NULL, NULL);
return err ? FALSE : TRUE;
nla_put_failure:
nlmsg_free (msg);
return FALSE;
}
示例6: __near_netlink_activate_target
int __near_netlink_activate_target(uint32_t idx, uint32_t target_idx,
uint32_t protocol)
{
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_ACTIVATE_TARGET,
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_U32(msg, NFC_ATTR_PROTOCOLS, protocol);
err = nl_send_msg(nfc_state->cmd_sock, msg, NULL, NULL);
nla_put_failure:
nlmsg_free(msg);
return err;
}
示例7: iw_cqm_rssi
static int iw_cqm_rssi(struct nl80211_state *state, struct nl_cb *cb,
struct nl_msg *msg, int argc, char **argv)
{
struct nl_msg *cqm = NULL;
int thold = 0;
int hyst = 0;
int ret = -ENOSPC;
/* get the required args */
if (argc < 1 || argc > 2)
return 1;
if (strcmp(argv[0], "off")) {
thold = atoi(argv[0]);
if (thold == 0)
return -EINVAL;
if (argc == 2)
hyst = atoi(argv[1]);
}
/* connection quality monitor attributes */
cqm = nlmsg_alloc();
NLA_PUT_U32(cqm, NL80211_ATTR_CQM_RSSI_THOLD, thold);
NLA_PUT_U32(cqm, NL80211_ATTR_CQM_RSSI_HYST, hyst);
nla_put_nested(msg, NL80211_ATTR_CQM, cqm);
ret = 0;
nla_put_failure:
nlmsg_free(cqm);
return ret;
}
示例8: ipvs_stop_daemon
int ipvs_stop_daemon(ipvs_daemon_t *dm)
{
ipvs_func = ipvs_stop_daemon;
#ifdef LIBIPVS_USE_NL
if (try_nl) {
struct nlattr *nl_daemon;
struct nl_msg *msg = ipvs_nl_message(IPVS_CMD_DEL_DAEMON, 0);
if (!msg) return -1;
nl_daemon = nla_nest_start(msg, IPVS_CMD_ATTR_DAEMON);
if (!nl_daemon)
goto nla_put_failure;
NLA_PUT_U32(msg, IPVS_DAEMON_ATTR_STATE, dm->state);
NLA_PUT_STRING(msg, IPVS_DAEMON_ATTR_MCAST_IFN, dm->mcast_ifn);
NLA_PUT_U32(msg, IPVS_DAEMON_ATTR_SYNC_ID, dm->syncid);
nla_nest_end(msg, nl_daemon);
return ipvs_nl_send_message(msg, ipvs_nl_noop_cb, NULL);
nla_put_failure:
nlmsg_free(msg);
return -1;
}
#endif
return setsockopt(sockfd, IPPROTO_IP, IP_VS_SO_SET_STOPDAEMON,
(char *)dm, sizeof(*dm));
}
示例9: ath6kl_wlan_hb_event
void ath6kl_wlan_hb_event(struct ath6kl *ar, u8 value,
void *buf, size_t buf_len)
{
struct sk_buff *skb;
if (!buf || buf_len == 0) {
printk(KERN_ERR "buf buflen is empty\n");
return;
}
skb = cfg80211_testmode_alloc_event_skb(ar->wiphy, buf_len, GFP_ATOMIC);
if (!skb) {
printk(KERN_ERR "failed to allocate testmode event skb!\n");
return;
}
NLA_PUT_U32(skb, ATH6KL_TM_ATTR_CMD, ATH6KL_TM_CMD_WLAN_HB);
NLA_PUT_U32(skb, ATH6KL_TM_ATTR_TYPE, value);
NLA_PUT(skb, ATH6KL_TM_ATTR_DATA, buf_len, buf);
cfg80211_testmode_event(skb, GFP_ATOMIC);
return;
#ifdef _NLA_PUT_ERR_RTN
nla_put_failure:
kfree_skb(skb);
printk(KERN_ERR "nla_put failed on testmode event skb!\n");
#endif
}
示例10: nlmsg_alloc
static struct nl_msg *gen_msg(int iface, char* ssid, int chan) {
struct nl_msg *msg, *ssids, *freqs;
msg = nlmsg_alloc();
ssids = nlmsg_alloc();
freqs = nlmsg_alloc();
if (!msg || !ssids || !freqs) {
fprintf(stderr, "Failed to allocate netlink message");
if(msg)
nlmsg_free(msg);
if(ssids)
nlmsg_free(ssids);
if(freqs)
nlmsg_free(freqs);
return NULL;
}
genlmsg_put(msg, 0, 0, handle_id, 0, 0, NL80211_CMD_TRIGGER_SCAN, 0);
NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, iface);
NLA_PUT(ssids, 1, strlen(ssid), ssid);
nla_put_nested(msg, NL80211_ATTR_SCAN_SSIDS, ssids);
NLA_PUT_U32(freqs, 1, chan*5 + 2407);
nla_put_nested(msg, NL80211_ATTR_SCAN_FREQUENCIES, freqs);
return msg;
nla_put_failure:
nlmsg_free(msg);
return NULL;
}
示例11: 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;
}
示例12: u32_get_opts
static int u32_get_opts(struct rtnl_cls *cls, struct nl_msg *msg)
{
struct rtnl_u32 *u = rtnl_cls_data(cls);
if (u->cu_mask & U32_ATTR_DIVISOR)
NLA_PUT_U32(msg, TCA_U32_DIVISOR, u->cu_divisor);
if (u->cu_mask & U32_ATTR_HASH)
NLA_PUT_U32(msg, TCA_U32_HASH, u->cu_hash);
if (u->cu_mask & U32_ATTR_CLASSID)
NLA_PUT_U32(msg, TCA_U32_CLASSID, u->cu_classid);
if (u->cu_mask & U32_ATTR_LINK)
NLA_PUT_U32(msg, TCA_U32_LINK, u->cu_link);
if (u->cu_mask & U32_ATTR_SELECTOR)
NLA_PUT_DATA(msg, TCA_U32_SEL, u->cu_selector);
if (u->cu_mask & U32_ATTR_ACTION)
NLA_PUT_DATA(msg, TCA_U32_ACT, u->cu_act);
if (u->cu_mask & U32_ATTR_POLICE)
NLA_PUT_DATA(msg, TCA_U32_POLICE, u->cu_police);
if (u->cu_mask & U32_ATTR_INDEV)
NLA_PUT_STRING(msg, TCA_U32_INDEV, u->cu_indev);
return 0;
nla_put_failure:
return -NLE_NOMEM;
}
示例13: wpa_driver_set_power_save
static int wpa_driver_set_power_save(void *priv, int state)
{
struct i802_bss *bss = priv;
struct wpa_driver_nl80211_data *drv = bss->drv;
struct nl_msg *msg;
int ret = -1;
enum nl80211_ps_state ps_state;
msg = nlmsg_alloc();
if (!msg)
return -1;
genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, 0,
NL80211_CMD_SET_POWER_SAVE, 0);
if (state == WPA_PS_ENABLED)
ps_state = NL80211_PS_ENABLED;
else
ps_state = NL80211_PS_DISABLED;
NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, drv->ifindex);
NLA_PUT_U32(msg, NL80211_ATTR_PS_STATE, ps_state);
ret = send_and_recv_msgs(drv, msg, NULL, NULL);
msg = NULL;
if (ret < 0)
wpa_printf(MSG_ERROR, "nl80211: Set power mode fail: %d", ret);
nla_put_failure:
nlmsg_free(msg);
return ret;
}
示例14: nlmsg_alloc_simple
static struct nl_msg *build_rule_msg(struct rtnl_rule *tmpl, int cmd, int flags)
{
struct nl_msg *msg;
struct rtmsg rtm = {
.rtm_type = RTN_UNSPEC
};
if (cmd == RTM_NEWRULE)
rtm.rtm_type = RTN_UNICAST;
if (tmpl->ce_mask & RULE_ATTR_FAMILY)
rtm.rtm_family = tmpl->r_family;
if (tmpl->ce_mask & RULE_ATTR_TABLE)
rtm.rtm_table = tmpl->r_table;
if (tmpl->ce_mask & RULE_ATTR_DSFIELD)
rtm.rtm_tos = tmpl->r_dsfield;
if (tmpl->ce_mask & RULE_ATTR_TYPE)
rtm.rtm_type = tmpl->r_type;
if (tmpl->ce_mask & RULE_ATTR_SRC_LEN)
rtm.rtm_src_len = tmpl->r_src_len;
if (tmpl->ce_mask & RULE_ATTR_DST_LEN)
rtm.rtm_dst_len = tmpl->r_dst_len;
msg = nlmsg_alloc_simple(cmd, flags);
if (!msg)
goto nla_put_failure;
if (nlmsg_append(msg, &rtm, sizeof(rtm), NLMSG_ALIGNTO) < 0)
goto nla_put_failure;
if (tmpl->ce_mask & RULE_ATTR_SRC)
NLA_PUT_ADDR(msg, RTA_SRC, tmpl->r_src);
if (tmpl->ce_mask & RULE_ATTR_DST)
NLA_PUT_ADDR(msg, RTA_DST, tmpl->r_dst);
if (tmpl->ce_mask & RULE_ATTR_PRIO)
NLA_PUT_U32(msg, RTA_PRIORITY, tmpl->r_prio);
if (tmpl->ce_mask & RULE_ATTR_MARK)
NLA_PUT_U32(msg, RTA_PROTOINFO, tmpl->r_mark);
if (tmpl->ce_mask & RULE_ATTR_REALMS)
NLA_PUT_U32(msg, RTA_FLOW, tmpl->r_realms);
if (tmpl->ce_mask & RULE_ATTR_IIF)
NLA_PUT_STRING(msg, RTA_IIF, tmpl->r_iif);
return msg;
nla_put_failure:
nlmsg_free(msg);
return NULL;
}
示例15: 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;
}