Home | History | Annotate | Download | only in dhcpcd-6.8.2

Lines Matching defs:nlm

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