• Home
  • Raw
  • Download

Lines Matching refs:rt

192 static void get_next_params(char **argv, struct rtentry *rt, char **netmask)  in get_next_params()  argument
195 if (!strcmp(*argv, "reject")) rt->rt_flags |= RTF_REJECT; in get_next_params()
196 else if (!strcmp(*argv, "mod")) rt->rt_flags |= RTF_MODIFIED; in get_next_params()
197 else if (!strcmp(*argv, "dyn")) rt->rt_flags |= RTF_DYNAMIC; in get_next_params()
198 else if (!strcmp(*argv, "reinstate")) rt->rt_flags |= RTF_REINSTATE; in get_next_params()
204 rt->rt_metric = atolx_range(argv[1], 0, ULONG_MAX) + 1; in get_next_params()
208 unsigned int addr_mask = (((struct sockaddr_in *)&((rt)->rt_genmask))->sin_addr.s_addr); in get_next_params()
213 rt->rt_genmask = sock; in get_next_params()
216 if (!(rt->rt_flags & RTF_GATEWAY)) { in get_next_params()
217 if (!get_hostname(argv[1], (struct sockaddr_in *) &rt->rt_gateway)) in get_next_params()
218 rt->rt_flags |= RTF_GATEWAY; in get_next_params()
223 rt->rt_mtu = atolx_range(argv[1], 64, 65536); in get_next_params()
224 rt->rt_flags |= RTF_MSS; in get_next_params()
227 rt->rt_window = atolx_range(argv[1], 128, INT_MAX); //win low in get_next_params()
228 rt->rt_flags |= RTF_WINDOW; in get_next_params()
230 rt->rt_irtt = atolx_range(argv[1], 0, INT_MAX); in get_next_params()
231 rt->rt_flags |= RTF_IRTT; in get_next_params()
232 } else if (!strcmp(*argv, "dev") && !rt->rt_dev) rt->rt_dev = argv[1]; in get_next_params()
238 if (!rt->rt_dev && (rt->rt_flags & RTF_REJECT)) rt->rt_dev = (char *)"lo"; in get_next_params()
242 static void verify_netmask(struct rtentry *rt, char *netmask) in verify_netmask() argument
244 unsigned int addr_mask = (((struct sockaddr_in *)&((rt)->rt_genmask))->sin_addr.s_addr); in verify_netmask()
245 …unsigned int router_addr = ~(unsigned int)(((struct sockaddr_in *)&((rt)->rt_dst))->sin_addr.s_add… in verify_netmask()
249 if ((rt->rt_flags & RTF_HOST) && addr_mask != INVALID_ADDR) in verify_netmask()
252 addr_mask = ((struct sockaddr_in *) &rt->rt_dst)->sin_addr.s_addr; in verify_netmask()
260 struct rtentry rt; in setroute() local
270 memset(&rt, 0, sizeof(struct rtentry)); in setroute()
277 (((struct sockaddr_in *)&rt.rt_genmask)->sin_addr.s_addr) in setroute()
279 rt.rt_genmask.sa_family = AF_INET; in setroute()
283 is_net_or_host = get_hostname(targetip, (void *)&rt.rt_dst); in setroute()
286 rt.rt_flags = ((is_net_or_host) ? RTF_UP : (RTF_UP | RTF_HOST)); in setroute()
288 get_next_params(argv, &rt, (char **)&netmask); in setroute()
289 verify_netmask(&rt, (char *)netmask); in setroute()
291 if ((action == 1) && (rt.rt_flags & RTF_HOST)) in setroute()
292 (((struct sockaddr_in *)&((rt).rt_genmask))->sin_addr.s_addr) = INVALID_ADDR; in setroute()
295 if (action == 1) xioctl(sokfd, SIOCADDRT, &rt); in setroute()
296 else xioctl(sokfd, SIOCDELRT, &rt); in setroute()
304 static void is_prefix_inet6(char **tip, struct in6_rtmsg *rt) in is_prefix_inet6() argument
314 rt->rtmsg_flags = (plen == DEFAULT_PREFIXLEN) ? (RTF_UP | RTF_HOST) : RTF_UP; in is_prefix_inet6()
315 rt->rtmsg_dst_len = plen; in is_prefix_inet6()
322 static void get_next_params_inet6(char **argv, struct sockaddr_in6 *sock_in6, struct in6_rtmsg *rt,… in get_next_params_inet6() argument
325 if (!strcmp(*argv, "mod")) rt->rtmsg_flags |= RTF_MODIFIED; in get_next_params_inet6()
326 else if (!strcmp(*argv, "dyn")) rt->rtmsg_flags |= RTF_DYNAMIC; in get_next_params_inet6()
331 rt->rtmsg_metric = atolx_range(argv[1], 0, ULONG_MAX); in get_next_params_inet6()
334 if (!(rt->rtmsg_flags & RTF_GATEWAY)) { in get_next_params_inet6()
336 memcpy(&rt->rtmsg_gateway, sock_in6->sin6_addr.s6_addr, sizeof(struct in6_addr)); in get_next_params_inet6()
337 rt->rtmsg_flags |= RTF_GATEWAY; in get_next_params_inet6()
352 struct in6_rtmsg rt; in setroute_inet6() local
358 memset(&rt, 0, sizeof(struct in6_rtmsg)); in setroute_inet6()
363 rt.rtmsg_flags = RTF_UP; in setroute_inet6()
364 rt.rtmsg_dst_len = 0; in setroute_inet6()
366 is_prefix_inet6((char **)&targetip, &rt); in setroute_inet6()
370 rt.rtmsg_metric = 1; //default metric. in setroute_inet6()
371 memcpy(&rt.rtmsg_dst, sock_in6.sin6_addr.s6_addr, sizeof(struct in6_addr)); in setroute_inet6()
372 get_next_params_inet6(argv, &sock_in6, &rt, (char **)&dev_name); in setroute_inet6()
380 rt.rtmsg_ifindex = ifre->ifr_ifindex; in setroute_inet6()
382 if (action == 1) xioctl(sockfd, SIOCADDRT, &rt); in setroute_inet6()
383 else xioctl(sockfd, SIOCDELRT, &rt); in setroute_inet6()