00001 struct nl_msg *build_msg(int ifindex, struct nl_addr *lladdr, int mtu)
00002 {
00003 struct nl_msg *msg;
00004 struct nlattr *info, *vlan;
00005 struct ifinfomsg ifi = {
00006 .ifi_family = AF_INET,
00007 .ifi_index = ifindex,
00008 };
00009
00010
00011 if (!(msg = nlmsg_alloc_simple(RTM_SETLINK, 0)))
00012 return NULL;
00013
00014
00015 if (nlmsg_append(msg, &ifi, sizeof(ifi), NLMSG_ALIGNTO) < 0)
00016 goto nla_put_failure
00017
00018
00019 NLA_PUT_U32(msg, IFLA_MTU, mtu);
00020
00021
00022 NLA_PUT_ADDR(msg, IFLA_ADDRESS, lladdr);
00023
00024
00025 if (!(info = nla_nest_start(msg, IFLA_LINKINFO)))
00026 goto nla_put_failure;
00027
00028
00029 NLA_PUT_STRING(msg, IFLA_INFO_KIND, "vlan");
00030
00031
00032
00033
00034
00035 if (!(vlan = nla_nest_start(msg, IFLA_INFO_DATA)))
00036 goto nla_put_failure;
00037
00038
00039
00040
00041 nla_nest_end(msg, vlan);
00042
00043
00044 nla_nest_end(msg, info);
00045
00046 return msg;
00047
00048 nla_put_failure:
00049 nlmsg_free(msg);
00050 return NULL;
00051 }