|
void | rtnl_link_set_qdisc (struct rtnl_link *link, const char *qdisc) |
|
char * | rtnl_link_get_qdisc (struct rtnl_link *link) |
|
void | rtnl_link_set_name (struct rtnl_link *link, const char *name) |
|
char * | rtnl_link_get_name (struct rtnl_link *link) |
|
void | rtnl_link_set_addr (struct rtnl_link *link, struct nl_addr *addr) |
|
struct nl_addr * | rtnl_link_get_addr (struct rtnl_link *link) |
|
void | rtnl_link_set_broadcast (struct rtnl_link *link, struct nl_addr *brd) |
|
struct nl_addr * | rtnl_link_get_broadcast (struct rtnl_link *link) |
|
void | rtnl_link_set_flags (struct rtnl_link *link, unsigned int flags) |
|
void | rtnl_link_unset_flags (struct rtnl_link *link, unsigned int flags) |
|
unsigned int | rtnl_link_get_flags (struct rtnl_link *link) |
|
void | rtnl_link_set_family (struct rtnl_link *link, int family) |
|
int | rtnl_link_get_family (struct rtnl_link *link) |
|
void | rtnl_link_set_arptype (struct rtnl_link *link, unsigned int arptype) |
|
unsigned int | rtnl_link_get_arptype (struct rtnl_link *link) |
|
void | rtnl_link_set_ifindex (struct rtnl_link *link, int ifindex) |
|
int | rtnl_link_get_ifindex (struct rtnl_link *link) |
|
void | rtnl_link_set_mtu (struct rtnl_link *link, unsigned int mtu) |
|
unsigned int | rtnl_link_get_mtu (struct rtnl_link *link) |
|
void | rtnl_link_set_txqlen (struct rtnl_link *link, unsigned int txqlen) |
|
unsigned int | rtnl_link_get_txqlen (struct rtnl_link *link) |
|
void | rtnl_link_set_weight (struct rtnl_link *link, unsigned int weight) |
|
unsigned int | rtnl_link_get_weight (struct rtnl_link *link) |
|
void | rtnl_link_set_link (struct rtnl_link *link, int ifindex) |
|
int | rtnl_link_get_link (struct rtnl_link *link) |
|
void | rtnl_link_set_master (struct rtnl_link *link, int ifindex) |
|
int | rtnl_link_get_master (struct rtnl_link *link) |
|
void | rtnl_link_set_operstate (struct rtnl_link *link, uint8_t operstate) |
|
uint8_t | rtnl_link_get_operstate (struct rtnl_link *link) |
|
void | rtnl_link_set_linkmode (struct rtnl_link *link, uint8_t linkmode) |
|
uint8_t | rtnl_link_get_linkmode (struct rtnl_link *link) |
|
uint64_t | rtnl_link_get_stat (struct rtnl_link *link, int id) |
|
int | rtnl_link_set_info_type (struct rtnl_link *link, const char *type) |
| Specify the info type of a link. More...
|
|
char * | rtnl_link_get_info_type (struct rtnl_link *link) |
| Return info type of a link. More...
|
|
struct nl_msg* rtnl_link_build_change_request |
( |
struct rtnl_link * |
old, |
|
|
struct rtnl_link * |
tmpl, |
|
|
int |
flags |
|
) |
| |
|
read |
- Parameters
-
old | link to be changed |
tmpl | template with requested changes |
flags | additional netlink message flags |
Builds a new netlink message requesting a change of link attributes. The netlink message header isn't fully equipped with all relevant fields and must be sent out via nl_send_auto_complete() or supplemented as needed. old must point to a link currently configured in the kernel and tmpl must contain the attributes to be changed set via rtnl_link_set_*
functions.
- Returns
- New netlink message
- Note
- Not all attributes can be changed, see Changeable Attributes for more details.
Definition at line 965 of file link.c.
References nla_nest_end(), nla_nest_start(), NLA_PUT_ADDR, NLA_PUT_STRING, NLA_PUT_U32, NLA_PUT_U8, nlmsg_alloc_simple(), nlmsg_append(), and nlmsg_free().
Referenced by rtnl_link_change().
970 struct ifinfomsg ifi = {
971 .ifi_family = old->l_family,
972 .ifi_index = old->l_index,
975 if (tmpl->ce_mask & LINK_ATTR_FLAGS) {
976 ifi.ifi_flags = old->l_flags & ~tmpl->l_flag_mask;
977 ifi.ifi_flags |= tmpl->l_flags;
982 goto nla_put_failure;
984 if (
nlmsg_append(msg, &ifi,
sizeof(ifi), NLMSG_ALIGNTO) < 0)
985 goto nla_put_failure;
987 if (tmpl->ce_mask & LINK_ATTR_ADDR)
990 if (tmpl->ce_mask & LINK_ATTR_BRD)
993 if (tmpl->ce_mask & LINK_ATTR_MTU)
996 if (tmpl->ce_mask & LINK_ATTR_TXQLEN)
999 if (tmpl->ce_mask & LINK_ATTR_WEIGHT)
1002 if (tmpl->ce_mask & LINK_ATTR_IFNAME)
1005 if (tmpl->ce_mask & LINK_ATTR_OPERSTATE)
1006 NLA_PUT_U8(msg, IFLA_OPERSTATE, tmpl->l_operstate);
1008 if (tmpl->ce_mask & LINK_ATTR_LINKMODE)
1009 NLA_PUT_U8(msg, IFLA_LINKMODE, tmpl->l_linkmode);
1011 if ((tmpl->ce_mask & LINK_ATTR_LINKINFO) && tmpl->l_info_ops &&
1012 tmpl->l_info_ops->io_put_attrs) {
1013 struct nlattr *info;
1016 goto nla_put_failure;
1020 if (tmpl->l_info_ops->io_put_attrs(msg, tmpl) < 0)
1021 goto nla_put_failure;