Lines Matching refs:rt
177 static void is_prefix(char **tip, char **netmask, struct rtentry *rt) in is_prefix() argument
184 (((struct sockaddr_in *)&((rt)->rt_genmask))->sin_addr.s_addr) in is_prefix()
187 rt->rt_genmask.sa_family = AF_INET; in is_prefix()
195 static void get_next_params(char **argv, struct rtentry *rt, char **netmask) in get_next_params() argument
202 rt->rt_metric = atolx_range(*argv, 0, ULONG_MAX) + 1; in get_next_params()
207 unsigned int addr_mask = (((struct sockaddr_in *)&((rt)->rt_genmask))->sin_addr.s_addr); in get_next_params()
214 rt->rt_genmask = sock; in get_next_params()
218 if (!(rt->rt_flags & RTF_GATEWAY)) { in get_next_params()
222 if ((ishost = get_hostname(*argv, (struct sockaddr_in *) &rt->rt_gateway)) == 0) { in get_next_params()
223 rt->rt_flags |= RTF_GATEWAY; in get_next_params()
232 rt->rt_mss = atolx_range(*argv, 64, 32768); //MSS low and max in get_next_params()
233 rt->rt_flags |= RTF_MSS; in get_next_params()
239 rt->rt_window = atolx_range(*argv, 128, INT_MAX); //win low in get_next_params()
240 rt->rt_flags |= RTF_WINDOW; in get_next_params()
247 rt->rt_irtt = strtoul(*argv, NULL, 10); in get_next_params()
248 if (nclock_ticks > 0) rt->rt_irtt *= nclock_ticks; in get_next_params()
249 rt->rt_flags |= 0x0100; //RTF_IRTT in get_next_params()
254 if ((!rt->rt_dev)) rt->rt_dev = *argv; in get_next_params()
257 rt->rt_flags |= RTF_REJECT; in get_next_params()
260 rt->rt_flags |= RTF_MODIFIED; in get_next_params()
263 rt->rt_flags |= RTF_DYNAMIC; in get_next_params()
266 rt->rt_flags |= RTF_REINSTATE; in get_next_params()
271 if (!rt->rt_dev && (rt->rt_flags & RTF_REJECT)) rt->rt_dev = (char *)"lo"; in get_next_params()
275 static void verify_netmask(struct rtentry *rt, char *netmask) in verify_netmask() argument
277 unsigned int addr_mask = (((struct sockaddr_in *)&((rt)->rt_genmask))->sin_addr.s_addr); in verify_netmask()
278 …unsigned int router_addr = ~(unsigned int)(((struct sockaddr_in *)&((rt)->rt_dst))->sin_addr.s_add… in verify_netmask()
282 if ((rt->rt_flags & RTF_HOST) && addr_mask != INVALID_ADDR) in verify_netmask()
285 addr_mask = ((struct sockaddr_in *) &rt->rt_dst)->sin_addr.s_addr; in verify_netmask()
293 struct rtentry rt; in setroute() local
303 memset(&rt, 0, sizeof(struct rtentry)); in setroute()
306 is_prefix((char **)&targetip, (char **)&netmask, &rt); in setroute()
308 (struct sockaddr_in *) &rt.rt_dst)) < 0) in setroute()
312 rt.rt_flags = ((is_net_or_host) ? RTF_UP : (RTF_UP | RTF_HOST)); in setroute()
314 get_next_params(argv, &rt, (char **)&netmask); in setroute()
315 verify_netmask(&rt, (char *)netmask); in setroute()
317 if ((action == 1) && (rt.rt_flags & RTF_HOST)) in setroute()
318 (((struct sockaddr_in *)&((rt).rt_genmask))->sin_addr.s_addr) = INVALID_ADDR; in setroute()
321 if (action == 1) xioctl(sokfd, SIOCADDRT, &rt); in setroute()
322 else xioctl(sokfd, SIOCDELRT, &rt); in setroute()
330 static void is_prefix_inet6(char **tip, struct in6_rtmsg *rt) in is_prefix_inet6() argument
340 rt->rtmsg_flags = (plen == DEFAULT_PREFIXLEN) ? (RTF_UP | RTF_HOST) : RTF_UP; in is_prefix_inet6()
341 rt->rtmsg_dst_len = plen; in is_prefix_inet6()
348 static void get_next_params_inet6(char **argv, struct sockaddr_in6 *sock_in6, struct in6_rtmsg *rt,… in get_next_params_inet6() argument
355 rt->rtmsg_metric = atolx_range(*argv, 0, ULONG_MAX); in get_next_params_inet6()
359 if (!(rt->rtmsg_flags & RTF_GATEWAY)) { in get_next_params_inet6()
363 memcpy(&rt->rtmsg_gateway, sock_in6->sin6_addr.s6_addr, sizeof(struct in6_addr)); in get_next_params_inet6()
364 rt->rtmsg_flags |= RTF_GATEWAY; in get_next_params_inet6()
374 rt->rtmsg_flags |= RTF_MODIFIED; in get_next_params_inet6()
377 rt->rtmsg_flags |= RTF_DYNAMIC; in get_next_params_inet6()
387 struct in6_rtmsg rt; in setroute_inet6() local
393 memset(&rt, 0, sizeof(struct in6_rtmsg)); in setroute_inet6()
399 rt.rtmsg_flags = RTF_UP; in setroute_inet6()
400 rt.rtmsg_dst_len = plen; in setroute_inet6()
402 is_prefix_inet6((char **)&targetip, &rt); in setroute_inet6()
406 rt.rtmsg_metric = 1; //default metric. in setroute_inet6()
407 memcpy(&rt.rtmsg_dst, sock_in6.sin6_addr.s6_addr, sizeof(struct in6_addr)); in setroute_inet6()
408 get_next_params_inet6(argv, &sock_in6, &rt, (char **)&dev_name); in setroute_inet6()
416 rt.rtmsg_ifindex = ifre->ifr_ifindex; in setroute_inet6()
418 if (action == 1) xioctl(sockfd, SIOCADDRT, &rt); in setroute_inet6()
419 else xioctl(sockfd, SIOCDELRT, &rt); in setroute_inet6()