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

Function print_rtmsg

tools/route/route.c:1706–1807  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1704 "\n%s: truncated route message, only %zu bytes left\n";
1705
1706static void
1707print_rtmsg(struct rt_msghdr *rtm, size_t msglen)
1708{
1709 struct if_msghdr *ifm;
1710 struct ifa_msghdr *ifam;
1711#ifdef RTM_NEWMADDR
1712 struct ifma_msghdr *ifmam;
1713#endif
1714 struct if_announcemsghdr *ifan;
1715 const char *state;
1716
1717 if (verbose == 0)
1718 return;
1719 if (rtm->rtm_version != RTM_VERSION) {
1720 (void)printf("routing message version %d not understood\n",
1721 rtm->rtm_version);
1722 return;
1723 }
1724 if (rtm->rtm_type < nitems(msgtypes))
1725 (void)printf("%s: ", msgtypes[rtm->rtm_type]);
1726 else
1727 (void)printf("unknown type %d: ", rtm->rtm_type);
1728 (void)printf("len %d, ", rtm->rtm_msglen);
1729
1730#define REQUIRE(x) do { \
1731 if (msglen < sizeof(x)) \
1732 goto badlen; \
1733 else \
1734 msglen -= sizeof(x); \
1735 } while (0)
1736
1737 switch (rtm->rtm_type) {
1738 case RTM_IFINFO:
1739 REQUIRE(struct if_msghdr);
1740 ifm = (struct if_msghdr *)rtm;
1741 (void)printf("if# %d, ", ifm->ifm_index);
1742 switch (ifm->ifm_data.ifi_link_state) {
1743 case LINK_STATE_DOWN:
1744 state = "down";
1745 break;
1746 case LINK_STATE_UP:
1747 state = "up";
1748 break;
1749 default:
1750 state = "unknown";
1751 break;
1752 }
1753 (void)printf("link: %s, flags:", state);
1754 printb(ifm->ifm_flags, ifnetflags);
1755 pmsg_addrs((char *)(ifm + 1), ifm->ifm_addrs, msglen);
1756 break;
1757 case RTM_NEWADDR:
1758 case RTM_DELADDR:
1759 REQUIRE(struct ifa_msghdr);
1760 ifam = (struct ifa_msghdr *)rtm;
1761 (void)printf("metric %d, flags:", ifam->ifam_metric);
1762 printb(ifam->ifam_flags, routeflags);
1763 pmsg_addrs((char *)(ifam + 1), ifam->ifam_addrs, msglen);

Callers 4

flushroutes_fibFunction · 0.85
interfacesFunction · 0.85
monitorFunction · 0.85
route.cFile · 0.85

Calls 4

pmsg_addrsFunction · 0.85
pmsg_commonFunction · 0.85
printbFunction · 0.70
printfFunction · 0.50

Tested by

no test coverage detected