MCPcopy Create free account
hub / github.com/F-Stack/f-stack / rtsock_msg_buffer

Function rtsock_msg_buffer

freebsd/net/rtsock.c:1639–1763  ·  view source on GitHub ↗

* Writes information related to @rtinfo object to preallocated buffer. * Stores needed size in @plen. If @w is NULL, calculates size without * writing. * Used for sysctl dumps and rtsock answers (RTM_DEL/RTM_GET) generation. * * Returns 0 on success. * */

Source from the content-addressed store, hash-verified

1637 *
1638 */
1639static int
1640rtsock_msg_buffer(int type, struct rt_addrinfo *rtinfo, struct walkarg *w, int *plen)
1641{
1642 struct sockaddr_storage ss;
1643 int len, buflen = 0, dlen, i;
1644 caddr_t cp = NULL;
1645 struct rt_msghdr *rtm = NULL;
1646#ifdef INET6
1647 struct sockaddr_in6 *sin6;
1648#endif
1649#ifdef COMPAT_FREEBSD32
1650 bool compat32 = false;
1651#endif
1652
1653 switch (type) {
1654 case RTM_DELADDR:
1655 case RTM_NEWADDR:
1656 if (w != NULL && w->w_op == NET_RT_IFLISTL) {
1657#ifdef COMPAT_FREEBSD32
1658 if (w->w_req->flags & SCTL_MASK32) {
1659 len = sizeof(struct ifa_msghdrl32);
1660 compat32 = true;
1661 } else
1662#endif
1663 len = sizeof(struct ifa_msghdrl);
1664 } else
1665 len = sizeof(struct ifa_msghdr);
1666 break;
1667
1668 case RTM_IFINFO:
1669#ifdef COMPAT_FREEBSD32
1670 if (w != NULL && w->w_req->flags & SCTL_MASK32) {
1671 if (w->w_op == NET_RT_IFLISTL)
1672 len = sizeof(struct if_msghdrl32);
1673 else
1674 len = sizeof(struct if_msghdr32);
1675 compat32 = true;
1676 break;
1677 }
1678#endif
1679 if (w != NULL && w->w_op == NET_RT_IFLISTL)
1680 len = sizeof(struct if_msghdrl);
1681 else
1682 len = sizeof(struct if_msghdr);
1683 break;
1684
1685 case RTM_NEWMADDR:
1686 len = sizeof(struct ifma_msghdr);
1687 break;
1688
1689 default:
1690 len = sizeof(struct rt_msghdr);
1691 }
1692
1693 if (w != NULL) {
1694 rtm = (struct rt_msghdr *)w->w_tmem;
1695 buflen = w->w_tmemsize - len;
1696 cp = (caddr_t)w->w_tmem + len;

Callers 4

update_rtm_from_rcFunction · 0.70
sysctl_dumpnhopFunction · 0.70
sysctl_iflistFunction · 0.70
sysctl_ifmalistFunction · 0.70

Calls 2

bzeroFunction · 0.85
sa6_recoverscopeFunction · 0.85

Tested by

no test coverage detected