Lines Matching +full:use +full:- +full:rtm
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
6 * Redistribution and use in source and binary forms, with or without
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
81 if (hdr->nlmsg_len < sizeof(struct nlmsghdr) + sizeof(struct ndmsg)) in rtnl_neigh_from_linux()
83 if ((f = linux_to_bsd_domain(ndm->ndm_family)) == AF_UNKNOWN) in rtnl_neigh_from_linux()
86 ndm->ndm_family = f; in rtnl_neigh_from_linux()
97 if (hdr->nlmsg_len < sizeof(struct nlmsghdr) + in rtnl_ifaddr_from_linux()
98 offsetof(struct ifaddrmsg, ifa_family) + sizeof(ifam->ifa_family)) in rtnl_ifaddr_from_linux()
100 if ((f = linux_to_bsd_domain(ifam->ifa_family)) == AF_UNKNOWN) in rtnl_ifaddr_from_linux()
103 ifam->ifa_family = f; in rtnl_ifaddr_from_linux()
115 struct rtmsg *rtm = (struct rtmsg *)(hdr + 1); in rtnl_route_from_linux() local
120 if (hdr->nlmsg_len < sizeof(struct nlmsghdr) + sizeof(struct rtmsg)) in rtnl_route_from_linux()
122 if ((f = linux_to_bsd_domain(rtm->rtm_family)) == AF_UNKNOWN) in rtnl_route_from_linux()
124 rtm->rtm_family = f; in rtnl_route_from_linux()
126 if (rtm->rtm_table == 254) in rtnl_route_from_linux()
127 rtm->rtm_table = 0; in rtnl_route_from_linux()
129 attrs_len = hdr->nlmsg_len - sizeof(struct nlmsghdr); in rtnl_route_from_linux()
130 attrs_len -= NETLINK_ALIGN(sizeof(struct rtmsg)); in rtnl_route_from_linux()
131 nla_head = (struct nlattr *)((char *)rtm + NETLINK_ALIGN(sizeof(struct rtmsg))); in rtnl_route_from_linux()
135 nla->nla_type, nla->nla_len, attrs_len); in rtnl_route_from_linux()
137 if (rta->rta_len < sizeof(struct rtattr)) { in rtnl_route_from_linux()
140 switch (rta->rta_type) { in rtnl_route_from_linux()
144 rtm->rtm_table = 0; in rtnl_route_from_linux()
161 switch (hdr->nlmsg_type) { in rtnl_from_linux()
177 hdr->nlmsg_type); in rtnl_from_linux()
198 * Kernel -> Linux
205 out_hdr = nlmsg_reserve_data(nw, NLMSG_ALIGN(hdr->nlmsg_len), char); in handle_default_out()
208 memcpy(out_hdr, hdr, hdr->nlmsg_len); in handle_default_out()
209 nw->num_messages++; in handle_default_out()
218 return (nlmsg_add(nw, hdr->nlmsg_pid, hdr->nlmsg_seq, hdr->nlmsg_type, in nlmsg_copy_header()
219 hdr->nlmsg_flags, 0)); in nlmsg_copy_header()
236 struct nlattr *nla = nlmsg_reserve_data(nw, nla_orig->nla_len, struct nlattr); in nlmsg_copy_nla()
238 memcpy(nla, nla_orig, nla_orig->nla_len); in nlmsg_copy_nla()
258 #define LINUX_NLA_UNHANDLED -1
269 switch (hdr->nlmsg_type) { in nlmsg_translate_all_nla()
273 switch (nla->nla_type) { in nlmsg_translate_all_nla()
292 int attrs_len = hdr->nlmsg_len - sizeof(struct nlmsghdr) - hdrlen; in nlmsg_copy_all_nla()
296 RT_LOG(LOG_DEBUG3, "reading attr %d len %d", nla->nla_type, nla->nla_len); in nlmsg_copy_all_nla()
297 if (nla->nla_len < sizeof(struct nlattr)) { in nlmsg_copy_all_nla()
363 ifinfo->ifi_family = bsd_to_linux_domain(ifinfo->ifi_family); in rtnl_newlink_to_linux()
365 switch (ifinfo->ifi_type) { in rtnl_newlink_to_linux()
367 ifinfo->ifi_type = LINUX_ARPHRD_ETHER; in rtnl_newlink_to_linux()
370 ifinfo->ifi_flags = rtnl_if_flags_to_linux(ifinfo->ifi_flags); in rtnl_newlink_to_linux()
398 ifamsg->ifa_family = bsd_to_linux_domain(ifamsg->ifa_family); in rtnl_newaddr_to_linux()
420 ndm->ndm_family = bsd_to_linux_domain(ndm->ndm_family); in rtnl_newneigh_to_linux()
438 struct rtmsg *rtm; in rtnl_newroute_to_linux() local
439 rtm = nlmsg_copy_next_header(hdr, nw, struct rtmsg); in rtnl_newroute_to_linux()
440 rtm->rtm_family = bsd_to_linux_domain(rtm->rtm_family); in rtnl_newroute_to_linux()
445 int attrs_len = hdr->nlmsg_len - sizeof(struct nlmsghdr) - hdrlen; in rtnl_newroute_to_linux()
450 //RT_LOG(LOG_DEBUG, "READING attr %d len %d", nla->nla_type, nla->nla_len); in rtnl_newroute_to_linux()
451 if (rta->rta_len < sizeof(struct rtattr)) { in rtnl_newroute_to_linux()
455 switch (rta->rta_type) { in rtnl_newroute_to_linux()
482 RT_LOG(LOG_DEBUG2, "Got message type %d", hdr->nlmsg_type); in rtnl_to_linux()
484 switch (hdr->nlmsg_type) { in rtnl_to_linux()
501 hdr->nlmsg_type); in rtnl_to_linux()
514 nlerr->error = bsd_to_linux_errno(nlerr->error); in nlmsg_error_to_linux()
517 if (hdr->nlmsg_len == copied_len) { in nlmsg_error_to_linux()
527 nlerr->msg.nlmsg_type); in nlmsg_error_to_linux()
529 int copy_len = hdr->nlmsg_len - copied_len; in nlmsg_error_to_linux()
543 if (hdr->nlmsg_type < NLMSG_MIN_TYPE) { in nlmsg_to_linux()
544 switch (hdr->nlmsg_type) { in nlmsg_to_linux()
553 hdr->nlmsg_type); in nlmsg_to_linux()
558 switch (nlp->nl_proto) { in nlmsg_to_linux()
573 orig->datalen + SCRATCH_BUFFER_SIZE, nlp, false))) in nlmsgs_to_linux()
578 offset + sizeof(struct nlmsghdr) <= orig->datalen; in nlmsgs_to_linux()
580 struct nlmsghdr *hdr = (struct nlmsghdr *)&orig->data[offset]; in nlmsgs_to_linux()
582 msglen = NLMSG_ALIGN(hdr->nlmsg_len); in nlmsgs_to_linux()
585 hdr->nlmsg_type); in nlmsgs_to_linux()
592 nw.buf->datalen, nw.num_messages); in nlmsgs_to_linux()