Lines Matching +full:use +full:- +full:rtm

2  * Copyright (c) 2001-2003
8 * Redistribution and use in source and binary forms, with or without
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
65 return (memcmp(s1->index, s2->index, 13)); in sroute_compare()
73 oid->len = sub + 13; in sroute_index_append()
75 oid->subs[sub + i] = s->index[i]; in sroute_index_append()
84 for (i = 0; i < 13 - 1; i++)
85 printf("%u.", r->index[i]);
86 printf("%u proto=%u type=%u", r->index[i], r->proto, r->type);
94 mib_sroute_process(struct rt_msghdr *rtm, struct sockaddr *gw, in mib_sroute_process() argument
104 if (dst == NULL || gw == NULL || dst->sa_family != AF_INET || in mib_sroute_process()
105 gw->sa_family != AF_INET) in mib_sroute_process()
111 if (rtm->rtm_flags & RTF_HOST) in mib_sroute_process()
113 else if (mask == NULL || mask->sa_len == 0) in mib_sroute_process()
116 in_mask = ((struct sockaddr_in *)(void *)mask)->sin_addr; in mib_sroute_process()
119 ha = ntohl(in_dst->sin_addr.s_addr); in mib_sroute_process()
134 ha = ntohl(in_gw->sin_addr.s_addr); in mib_sroute_process()
140 if (rtm->rtm_type == RTM_DELETE) { in mib_sroute_process()
156 route_total--; in mib_sroute_process()
171 if ((ifp = mib_find_if_sys(rtm->rtm_index)) == NULL) { in mib_sroute_process()
172 if (rtm->rtm_type == RTM_ADD) { in mib_sroute_process()
174 mib_send_rtmsg(rtm, gw, dst, mask); in mib_sroute_process()
185 memcpy(r->index, key.index, sizeof(r->index)); in mib_sroute_process()
186 r->ifindex = (ifp == NULL) ? 0 : ifp->index; in mib_sroute_process()
188 r->type = (rtm->rtm_flags & RTF_REJECT) ? 2 : 4; in mib_sroute_process()
191 r->proto = (rtm->rtm_flags & RTF_LOCAL) ? 2 : in mib_sroute_process()
192 (rtm->rtm_flags & RTF_STATIC) ? 3 : in mib_sroute_process()
193 (rtm->rtm_flags & RTF_DYNAMIC) ? 4 : 10; in mib_sroute_process()
206 r1->ifindex = r->ifindex; in mib_sroute_process()
207 r1->type = r->type; in mib_sroute_process()
208 r1->proto = r->proto; in mib_sroute_process()
231 struct rt_msghdr *rtm; in mib_fetch_route() local
250 return (-1); in mib_fetch_route()
253 for (next = rtab; next < rtab + len; next += rtm->rtm_msglen) { in mib_fetch_route()
254 rtm = (struct rt_msghdr *)(void *)next; in mib_fetch_route()
255 if (rtm->rtm_type != RTM_GET || in mib_fetch_route()
256 !(rtm->rtm_flags & RTF_UP)) in mib_fetch_route()
258 mib_extract_addrs(rtm->rtm_addrs, (u_char *)(rtm + 1), addrs); in mib_fetch_route()
261 mib_sroute_process(rtm, addrs[RTAX_GATEWAY], addrs[RTAX_DST], in mib_fetch_route()
290 if (oid->len - sub != 13) in sroute_get()
293 key.index[i] = oid->subs[sub + i]; in sroute_get()
314 if (oid->len == sub) in sroute_getnext()
321 if (oid->len < sub + 13) { in sroute_getnext()
322 for (i = sub; i < oid->len; i++) in sroute_getnext()
323 if (oid->subs[i] != 0) in sroute_getnext()
325 if (i == oid->len) in sroute_getnext()
333 for (i = oid->len; i < sub + 13; i++) in sroute_getnext()
334 oid->subs[i] = 0; in sroute_getnext()
336 for (i = sub + 13 - 1; i >= sub; i--) { in sroute_getnext()
337 if (oid->subs[i] != 0) { in sroute_getnext()
338 oid->subs[i]--; in sroute_getnext()
341 oid->subs[i] = ASN_MAXID; in sroute_getnext()
343 oid->len = sub + 13; in sroute_getnext()
348 key.index[i - sub] = oid->subs[i]; in sroute_getnext()
383 if (mib_fetch_route() == -1) in op_route_table()
389 if ((r = sroute_getnext(&value->var, sub)) == NULL) in op_route_table()
391 sroute_index_append(&value->var, sub, r); in op_route_table()
395 if ((r = sroute_get(&value->var, sub)) == NULL) in op_route_table()
400 if ((r = sroute_get(&value->var, sub)) == NULL) in op_route_table()
412 switch (value->var.subs[sub - 1]) { in op_route_table()
415 value->v.ipaddress[0] = r->index[0]; in op_route_table()
416 value->v.ipaddress[1] = r->index[1]; in op_route_table()
417 value->v.ipaddress[2] = r->index[2]; in op_route_table()
418 value->v.ipaddress[3] = r->index[3]; in op_route_table()
422 value->v.ipaddress[0] = r->index[4]; in op_route_table()
423 value->v.ipaddress[1] = r->index[5]; in op_route_table()
424 value->v.ipaddress[2] = r->index[6]; in op_route_table()
425 value->v.ipaddress[3] = r->index[7]; in op_route_table()
429 value->v.integer = r->index[8]; in op_route_table()
433 value->v.ipaddress[0] = r->index[9]; in op_route_table()
434 value->v.ipaddress[1] = r->index[10]; in op_route_table()
435 value->v.ipaddress[2] = r->index[11]; in op_route_table()
436 value->v.ipaddress[3] = r->index[12]; in op_route_table()
440 value->v.integer = r->ifindex; in op_route_table()
444 value->v.integer = r->type; in op_route_table()
448 value->v.integer = r->proto; in op_route_table()
452 value->v.integer = 0; in op_route_table()
456 value->v.oid = oid_zeroDotZero; in op_route_table()
460 value->v.integer = 0; in op_route_table()
468 value->v.integer = -1; in op_route_table()
472 value->v.integer = 1; in op_route_table()
501 if (mib_fetch_route() == -1) in op_route()
504 switch (value->var.subs[sub - 1]) { in op_route()
507 value->v.uint32 = route_total; in op_route()