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
77 if (idx >= map->size) in nhop_get()
79 if (*map->ptr[idx].ifname == '\0') in nhop_get()
81 return &map->ptr[idx]; in nhop_get()
88 xo_emit("{T:/%-*.*s}{T:/%-*.*s}{T:/%*.*s}{T:/%*.*s}{T:/%*.*s}" in print_nhgroup_header()
116 print_nhgroup_entry_sysctl(const char *name, struct rt_msghdr *rtm, in print_nhgroup_entry_sysctl() argument
125 if (nhg_cp->nhgc_type != NHG_C_TYPE_CNHOPS || nhg_cp->nhgc_subtype != 0) in print_nhgroup_entry_sysctl()
129 nhg_dp = (struct nhgrp_container *)((char *)nhg_cp + nhg_cp->nhgc_len); in print_nhgroup_entry_sysctl()
130 if (nhg_dp->nhgc_type != NHG_C_TYPE_DNHOPS || nhg_dp->nhgc_subtype != 0) in print_nhgroup_entry_sysctl()
136 snprintf(buffer, sizeof(buffer), "{[:-%d}{:nhgrp-index/%%lu}{]:} ", wid_nhidx); in print_nhgroup_entry_sysctl()
138 xo_emit(buffer, nhge->nhg_idx); in print_nhgroup_entry_sysctl()
141 print_padding('-', wid_nhidx); in print_nhgroup_entry_sysctl()
143 print_padding('-', wid_nhidx); in print_nhgroup_entry_sysctl()
145 print_padding('-', wid_nhidx); in print_nhgroup_entry_sysctl()
146 print_padding('-', wid_gw); in print_nhgroup_entry_sysctl()
147 print_padding('-', wid_if); in print_nhgroup_entry_sysctl()
148 xo_emit("{t:nhg-refcnt/%*lu}", wid_refcnt, nhge->nhg_refcount); in print_nhgroup_entry_sysctl()
151 xo_open_list("nhop-weights"); in print_nhgroup_entry_sysctl()
152 for (uint32_t i = 0; i < nhg_cp->nhgc_count; i++) { in print_nhgroup_entry_sysctl()
155 for (uint32_t sidx = 0; sidx < nhg_dp->nhgc_count; sidx++) { in print_nhgroup_entry_sysctl()
159 xo_open_instance("nhop-weight"); in print_nhgroup_entry_sysctl()
162 xo_emit("{t:nh-index/%*lu}", wid_nhidx, ext_cp[i].nh_idx); in print_nhgroup_entry_sysctl()
163 xo_emit("{t:nh-weight/%*lu}", wid_nhidx, ext_cp[i].nh_weight); in print_nhgroup_entry_sysctl()
164 xo_emit("{t:nh-slots/%*lu}", wid_nhidx, slots); in print_nhgroup_entry_sysctl()
167 xo_emit("{t:nh-gw/%*.*s}", wid_gw, wid_gw, ne->gw); in print_nhgroup_entry_sysctl()
168 xo_emit("{t:nh-interface/%*.*s}", wid_if, wid_if, ne->ifname); in print_nhgroup_entry_sysctl()
171 xo_close_instance("nhop-weight"); in print_nhgroup_entry_sysctl()
173 xo_close_list("nhop-weights"); in print_nhgroup_entry_sysctl()
185 if (a->idx > b->idx) in cmp_nhg_idx()
187 else if (a->idx < b->idx) in cmp_nhg_idx()
188 return (-1); in cmp_nhg_idx()
198 struct rt_msghdr *rtm; in dump_nhgrp_sysctl() local
226 for (next = buf; next < lim; next += rtm->rtm_msglen) { in dump_nhgrp_sysctl()
227 rtm = (struct rt_msghdr *)next; in dump_nhgrp_sysctl()
228 if (rtm->rtm_version != RTM_VERSION) in dump_nhgrp_sysctl()
236 nhg = (struct nhgrp_external *)(rtm + 1); in dump_nhgrp_sysctl()
237 nhg_map[nhg_count].idx = nhg->nhg_idx; in dump_nhgrp_sysctl()
238 nhg_map[nhg_count].rtm = rtm; in dump_nhgrp_sysctl()
244 nd->nh_buf = buf; in dump_nhgrp_sysctl()
245 nd->nh_count = nhg_count; in dump_nhgrp_sysctl()
246 nd->nh_map = nhg_map; in dump_nhgrp_sysctl()
254 struct rt_msghdr *rtm; in print_nhgrp_sysctl() local
258 xo_open_container("nhgrp-table"); in print_nhgrp_sysctl()
259 xo_open_list("rt-family"); in print_nhgrp_sysctl()
262 xo_open_instance("rt-family"); in print_nhgrp_sysctl()
264 xo_open_list("nhgrp-entry"); in print_nhgrp_sysctl()
269 rtm = nd.nh_map[i].rtm; in print_nhgrp_sysctl()
270 nhg = (struct nhgrp_external *)(rtm + 1); in print_nhgrp_sysctl()
271 print_nhgroup_entry_sysctl("nhgrp-entry", rtm, nhg); in print_nhgrp_sysctl()
274 xo_close_list("rt-family"); in print_nhgrp_sysctl()
275 xo_close_container("nhgrp-table"); in print_nhgrp_sysctl()
287 na = (struct nhop_addrs *)((char *)nh + nh->nh_len); in update_global_map()
288 sa_gw = (struct sockaddr *)((char *)na + na->gw_sa_off); in update_global_map()
291 if (nh->ifindex < (uint32_t)ifmap_size) { in update_global_map()
292 strlcpy(iface_name, ifmap[nh->ifindex].ifname, in update_global_map()
295 strlcpy(iface_name, "---", sizeof(iface_name)); in update_global_map()
298 if (nh->nh_flags & NHF_GATEWAY) { in update_global_map()
305 nhop_map_update(&global_nhop_map, nh->nh_idx, gw_addr, iface_name); in update_global_map()
313 struct rt_msghdr *rtm; in prepare_nh_map() local
318 rtm = nd.nh_map[i].rtm; in prepare_nh_map()
319 nh = (struct nhop_external *)(rtm + 1); in prepare_nh_map()
333 if (fibnum == -1 && in nhgrp_print()
334 sysctlbyname("net.my_fibnum", &fibnum, &intsize, NULL, 0) == -1) in nhgrp_print()
336 if (sysctlbyname("net.fibs", &numfibs, &intsize, NULL, 0) == -1) in nhgrp_print()
338 if (fibnum < 0 || fibnum > numfibs - 1) in nhgrp_print()
344 xo_open_container("route-nhgrp-information"); in nhgrp_print()
350 xo_close_container("route-nhgrp-information"); in nhgrp_print()