Lines Matching refs:nlm
301 err_netlink(struct nlmsghdr *nlm) in err_netlink() argument
306 if (nlm->nlmsg_type != NLMSG_ERROR) in err_netlink()
308 len = nlm->nlmsg_len - sizeof(*nlm); in err_netlink()
313 err = (struct nlmsgerr *)NLMSG_DATA(nlm); in err_netlink()
327 struct nlmsghdr *nlm; in get_netlink() local
371 for (nlm = (struct nlmsghdr *)(void *)buf; in get_netlink()
372 nlm && NLMSG_OK(nlm, (size_t)bytes); in get_netlink()
373 nlm = NLMSG_NEXT(nlm, bytes)) in get_netlink()
375 r = err_netlink(nlm); in get_netlink()
381 r = callback(ctx, ifp, nlm); in get_netlink()
395 if_copyrt(struct dhcpcd_ctx *ctx, struct rt *rt, struct nlmsghdr *nlm) in if_copyrt() argument
402 len = nlm->nlmsg_len - sizeof(*nlm); in if_copyrt()
407 rtm = (struct rtmsg *)NLMSG_DATA(nlm); in if_copyrt()
419 len = RTM_PAYLOAD(nlm); in if_copyrt()
461 if_copyrt6(struct dhcpcd_ctx *ctx, struct rt6 *rt, struct nlmsghdr *nlm) in if_copyrt6() argument
467 len = nlm->nlmsg_len - sizeof(*nlm); in if_copyrt6()
472 rtm = (struct rtmsg *)NLMSG_DATA(nlm); in if_copyrt6()
484 len = RTM_PAYLOAD(nlm); in if_copyrt6()
524 struct nlmsghdr *nlm) in link_route() argument
535 switch (nlm->nlmsg_type) { in link_route()
546 len = nlm->nlmsg_len - sizeof(*nlm); in link_route()
556 if (nlm->nlmsg_pid > get_max_pid_t()) in link_route()
559 rtm = NLMSG_DATA(nlm); in link_route()
563 if (if_copyrt(ctx, &rt, nlm) == 0) in link_route()
569 if (if_copyrt6(ctx, &rt6, nlm) == 0) in link_route()
579 link_addr(struct dhcpcd_ctx *ctx, struct interface *ifp, struct nlmsghdr *nlm) in link_addr() argument
591 if (nlm->nlmsg_type != RTM_DELADDR && nlm->nlmsg_type != RTM_NEWADDR) in link_addr()
594 len = nlm->nlmsg_len - sizeof(*nlm); in link_addr()
599 ifa = NLMSG_DATA(nlm); in link_addr()
606 len = NLMSG_PAYLOAD(nlm, sizeof(*ifa)); in link_addr()
628 ipv4_handleifa(ctx, nlm->nlmsg_type, NULL, ifp->name, in link_addr()
644 ipv6_handleifa(ctx, nlm->nlmsg_type, NULL, ifp->name, in link_addr()
691 struct nlmsghdr *nlm) in link_neigh() argument
699 if (nlm->nlmsg_type != RTM_NEWNEIGH && nlm->nlmsg_type != RTM_DELNEIGH) in link_neigh()
701 if (nlm->nlmsg_len < sizeof(*r)) in link_neigh()
704 r = NLMSG_DATA(nlm); in link_neigh()
706 len = RTM_PAYLOAD(nlm); in link_neigh()
711 if (nlm->nlmsg_type == RTM_NEWNEIGH && in link_neigh()
735 struct nlmsghdr *nlm) in link_netlink() argument
743 r = link_route(ctx, ifp, nlm); in link_netlink()
746 r = link_addr(ctx, ifp, nlm); in link_netlink()
750 r = link_neigh(ctx, ifp, nlm); in link_netlink()
755 if (nlm->nlmsg_type != RTM_NEWLINK && nlm->nlmsg_type != RTM_DELLINK) in link_netlink()
757 len = nlm->nlmsg_len - sizeof(*nlm); in link_netlink()
762 ifi = NLMSG_DATA(nlm); in link_netlink()
766 len = NLMSG_PAYLOAD(nlm, sizeof(*ifi)); in link_netlink()
774 if (nlm->nlmsg_type == RTM_NEWLINK && in link_netlink()
788 if (nlm->nlmsg_type == RTM_DELLINK) { in link_netlink()
989 gnl_parse(struct nlmsghdr *nlm, struct nlattr *tb[], int maxtype) in gnl_parse() argument
997 ghdr = NLMSG_DATA(nlm); in gnl_parse()
999 len = nlm->nlmsg_len - GENL_HDRLEN - NLMSG_HDRLEN; in gnl_parse()
1011 struct nlmsghdr *nlm) in _gnl_getfamily() argument
1016 if (gnl_parse(nlm, tb, CTRL_ATTR_FAMILY_ID) == -1) in _gnl_getfamily()
1029 struct nlmg nlm; in gnl_getfamily() local
1031 memset(&nlm, 0, sizeof(nlm)); in gnl_getfamily()
1032 nlm.hdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct genlmsghdr)); in gnl_getfamily()
1033 nlm.hdr.nlmsg_type = GENL_ID_CTRL; in gnl_getfamily()
1034 nlm.hdr.nlmsg_flags = NLM_F_REQUEST; in gnl_getfamily()
1035 nlm.ghdr.cmd = CTRL_CMD_GETFAMILY; in gnl_getfamily()
1036 nlm.ghdr.version = 1; in gnl_getfamily()
1037 if (nla_put_string(&nlm.hdr, sizeof(nlm), in gnl_getfamily()
1040 return send_netlink(ctx, NULL, NETLINK_GENERIC, &nlm.hdr, in gnl_getfamily()
1046 struct nlmsghdr *nlm) in _if_getssid() argument
1050 if (gnl_parse(nlm, tb, NL80211_ATTR_SSID) == -1) in _if_getssid()
1077 struct nlmg nlm; in if_getssid_nl80211() local
1083 memset(&nlm, 0, sizeof(nlm)); in if_getssid_nl80211()
1084 nlm.hdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct genlmsghdr)); in if_getssid_nl80211()
1085 nlm.hdr.nlmsg_type = (unsigned short)family; in if_getssid_nl80211()
1086 nlm.hdr.nlmsg_flags = NLM_F_REQUEST; in if_getssid_nl80211()
1087 nlm.ghdr.cmd = NL80211_CMD_GET_INTERFACE; in if_getssid_nl80211()
1088 nla_put_32(&nlm.hdr, sizeof(nlm), NL80211_ATTR_IFINDEX, ifp->index); in if_getssid_nl80211()
1091 NETLINK_GENERIC, &nlm.hdr, &_if_getssid); in if_getssid_nl80211()
1290 struct nlma nlm; in if_address() local
1293 memset(&nlm, 0, sizeof(nlm)); in if_address()
1294 nlm.hdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg)); in if_address()
1295 nlm.hdr.nlmsg_flags = NLM_F_REQUEST; in if_address()
1297 nlm.hdr.nlmsg_flags |= NLM_F_CREATE | NLM_F_REPLACE; in if_address()
1298 nlm.hdr.nlmsg_type = RTM_NEWADDR; in if_address()
1300 nlm.hdr.nlmsg_type = RTM_DELADDR; in if_address()
1301 nlm.ifa.ifa_index = iface->index; in if_address()
1302 nlm.ifa.ifa_family = AF_INET; in if_address()
1303 nlm.ifa.ifa_prefixlen = inet_ntocidr(*netmask); in if_address()
1305 add_attr_l(&nlm.hdr, sizeof(nlm), IFA_LABEL, in if_address()
1307 add_attr_l(&nlm.hdr, sizeof(nlm), IFA_LOCAL, in if_address()
1310 add_attr_l(&nlm.hdr, sizeof(nlm), IFA_BROADCAST, in if_address()
1313 if (send_netlink(iface->ctx, NULL, NETLINK_ROUTE, &nlm.hdr, NULL) == -1) in if_address()
1321 struct nlmr nlm; in if_route() local
1325 memset(&nlm, 0, sizeof(nlm)); in if_route()
1326 nlm.hdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg)); in if_route()
1329 nlm.hdr.nlmsg_type = RTM_NEWROUTE; in if_route()
1330 nlm.hdr.nlmsg_flags = NLM_F_CREATE | NLM_F_REPLACE; in if_route()
1333 nlm.hdr.nlmsg_type = RTM_NEWROUTE; in if_route()
1334 nlm.hdr.nlmsg_flags = NLM_F_CREATE | NLM_F_EXCL; in if_route()
1337 nlm.hdr.nlmsg_type = RTM_DELROUTE; in if_route()
1340 nlm.hdr.nlmsg_flags |= NLM_F_REQUEST; in if_route()
1341 nlm.rt.rtm_family = AF_INET; in if_route()
1342 nlm.rt.rtm_table = RT_TABLE_MAIN; in if_route()
1346 nlm.rt.rtm_scope = RT_SCOPE_NOWHERE; in if_route()
1352 nlm.rt.rtm_protocol = RTPROT_KERNEL; in if_route()
1354 nlm.rt.rtm_protocol = RTPROT_BOOT; in if_route()
1356 nlm.rt.rtm_scope = RT_SCOPE_HOST; in if_route()
1360 nlm.rt.rtm_scope = RT_SCOPE_LINK; in if_route()
1362 nlm.rt.rtm_scope = RT_SCOPE_UNIVERSE; in if_route()
1363 nlm.rt.rtm_type = RTN_UNICAST; in if_route()
1366 nlm.rt.rtm_dst_len = inet_ntocidr(rt->net); in if_route()
1367 add_attr_l(&nlm.hdr, sizeof(nlm), RTA_DST, in if_route()
1369 if (nlm.rt.rtm_protocol == RTPROT_KERNEL) { in if_route()
1370 add_attr_l(&nlm.hdr, sizeof(nlm), RTA_PREFSRC, in if_route()
1376 add_attr_l(&nlm.hdr, sizeof(nlm), RTA_GATEWAY, in if_route()
1380 add_attr_32(&nlm.hdr, sizeof(nlm), RTA_OIF, rt->iface->index); in if_route()
1382 add_attr_32(&nlm.hdr, sizeof(nlm), RTA_PRIORITY, rt->metric); in if_route()
1385 NETLINK_ROUTE, &nlm.hdr, NULL) == -1) in if_route()
1392 struct nlmsghdr *nlm) in _if_initrt() argument
1396 if (if_copyrt(ctx, &rt, nlm) == 0) in _if_initrt()
1404 struct nlmr nlm; in if_initrt() local
1408 memset(&nlm, 0, sizeof(nlm)); in if_initrt()
1409 nlm.hdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg)); in if_initrt()
1410 nlm.hdr.nlmsg_type = RTM_GETROUTE; in if_initrt()
1411 nlm.hdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_MATCH; in if_initrt()
1412 nlm.hdr.nlmsg_flags |= NLM_F_REQUEST; in if_initrt()
1413 nlm.rt.rtm_family = AF_INET; in if_initrt()
1414 nlm.rt.rtm_table = RT_TABLE_MAIN; in if_initrt()
1415 add_attr_32(&nlm.hdr, sizeof(nlm), RTA_OIF, ifp->index); in if_initrt()
1418 NETLINK_ROUTE, &nlm.hdr, &_if_initrt); in if_initrt()
1435 struct nlma nlm; in if_address6() local
1444 memset(&nlm, 0, sizeof(nlm)); in if_address6()
1445 nlm.hdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg)); in if_address6()
1446 nlm.hdr.nlmsg_flags = NLM_F_REQUEST; in if_address6()
1448 nlm.hdr.nlmsg_flags |= NLM_F_CREATE | NLM_F_REPLACE; in if_address6()
1449 nlm.hdr.nlmsg_type = RTM_NEWADDR; in if_address6()
1451 nlm.hdr.nlmsg_type = RTM_DELADDR; in if_address6()
1452 nlm.ifa.ifa_index = ap->iface->index; in if_address6()
1453 nlm.ifa.ifa_family = AF_INET6; in if_address6()
1458 nlm.ifa.ifa_flags |= IFA_F_TEMPORARY; in if_address6()
1468 nlm.ifa.ifa_prefixlen = ap->prefix_len; in if_address6()
1470 add_attr_l(&nlm.hdr, sizeof(nlm), IFA_LABEL, in if_address6()
1472 add_attr_l(&nlm.hdr, sizeof(nlm), IFA_LOCAL, in if_address6()
1479 add_attr_l(&nlm.hdr, sizeof(nlm), IFA_CACHEINFO, in if_address6()
1489 add_attr_32(&nlm.hdr, sizeof(nlm), IFA_FLAGS, flags); in if_address6()
1492 if (send_netlink(ap->iface->ctx, NULL, NETLINK_ROUTE, &nlm.hdr, in if_address6()
1522 struct nlmr nlm; in if_route6() local
1525 memset(&nlm, 0, sizeof(nlm)); in if_route6()
1526 nlm.hdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg)); in if_route6()
1529 nlm.hdr.nlmsg_type = RTM_NEWROUTE; in if_route6()
1530 nlm.hdr.nlmsg_flags = NLM_F_CREATE | NLM_F_REPLACE; in if_route6()
1533 nlm.hdr.nlmsg_type = RTM_NEWROUTE; in if_route6()
1534 nlm.hdr.nlmsg_flags = NLM_F_CREATE | NLM_F_EXCL; in if_route6()
1537 nlm.hdr.nlmsg_type = RTM_DELROUTE; in if_route6()
1540 nlm.hdr.nlmsg_flags |= NLM_F_REQUEST; in if_route6()
1541 nlm.rt.rtm_family = AF_INET6; in if_route6()
1542 nlm.rt.rtm_table = RT_TABLE_MAIN; in if_route6()
1545 nlm.rt.rtm_scope = RT_SCOPE_NOWHERE; in if_route6()
1549 nlm.rt.rtm_scope = RT_SCOPE_HOST; in if_route6()
1551 nlm.rt.rtm_protocol = RTPROT_KERNEL; in if_route6()
1552 nlm.rt.rtm_scope = RT_SCOPE_LINK; in if_route6()
1554 nlm.rt.rtm_protocol = RTPROT_BOOT; in if_route6()
1556 nlm.rt.rtm_type = RTN_UNREACHABLE; in if_route6()
1558 nlm.rt.rtm_type = RTN_UNICAST; in if_route6()
1561 nlm.rt.rtm_dst_len = ipv6_prefixlen(&rt->net); in if_route6()
1562 add_attr_l(&nlm.hdr, sizeof(nlm), RTA_DST, in if_route6()
1566 add_attr_l(&nlm.hdr, sizeof(nlm), RTA_GATEWAY, in if_route6()
1570 add_attr_32(&nlm.hdr, sizeof(nlm), RTA_OIF, rt->iface->index); in if_route6()
1572 add_attr_32(&nlm.hdr, sizeof(nlm), in if_route6()
1582 add_attr_l(&nlm.hdr, sizeof(nlm), RTA_METRICS, in if_route6()
1587 NETLINK_ROUTE, &nlm.hdr, NULL) == -1) in if_route6()
1594 struct nlmsghdr *nlm) in _if_initrt6() argument
1598 if (if_copyrt6(ctx, &rt, nlm) == 0) in _if_initrt6()
1606 struct nlmr nlm; in if_initrt6() local
1610 memset(&nlm, 0, sizeof(nlm)); in if_initrt6()
1611 nlm.hdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg)); in if_initrt6()
1612 nlm.hdr.nlmsg_type = RTM_GETROUTE; in if_initrt6()
1613 nlm.hdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_MATCH; in if_initrt6()
1614 nlm.hdr.nlmsg_flags |= NLM_F_REQUEST; in if_initrt6()
1615 nlm.rt.rtm_family = AF_INET6; in if_initrt6()
1616 nlm.rt.rtm_table = RT_TABLE_MAIN; in if_initrt6()
1617 add_attr_32(&nlm.hdr, sizeof(nlm), RTA_OIF, ifp->index); in if_initrt6()
1620 NETLINK_ROUTE, &nlm.hdr, &_if_initrt6); in if_initrt6()
1706 struct nlml nlm; in if_disable_autolinklocal() local
1709 memset(&nlm, 0, sizeof(nlm)); in if_disable_autolinklocal()
1710 nlm.hdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)); in if_disable_autolinklocal()
1711 nlm.hdr.nlmsg_type = RTM_NEWLINK; in if_disable_autolinklocal()
1712 nlm.hdr.nlmsg_flags = NLM_F_REQUEST; in if_disable_autolinklocal()
1713 nlm.i.ifi_family = AF_INET6; in if_disable_autolinklocal()
1714 nlm.i.ifi_index = ifindex; in if_disable_autolinklocal()
1715 afs = add_attr_nest(&nlm.hdr, sizeof(nlm), IFLA_AF_SPEC); in if_disable_autolinklocal()
1716 afs6 = add_attr_nest(&nlm.hdr, sizeof(nlm), AF_INET6); in if_disable_autolinklocal()
1717 add_attr_8(&nlm.hdr, sizeof(nlm), IFLA_INET6_ADDR_GEN_MODE, in if_disable_autolinklocal()
1719 add_attr_nest_end(&nlm.hdr, afs6); in if_disable_autolinklocal()
1720 add_attr_nest_end(&nlm.hdr, afs); in if_disable_autolinklocal()
1722 return send_netlink(ctx, NULL, NETLINK_ROUTE, &nlm.hdr, NULL); in if_disable_autolinklocal()