Lines Matching refs:ifp
104 if_link(struct interface *ifp)
108 ifp->int_prev = &ifnet;
109 ifp->int_next = ifnet;
111 ifnet->int_prev = &ifp->int_next;
112 ifnet = ifp;
114 hifp = AHASH(ifp->int_addr);
115 ifp->int_ahash_prev = hifp;
116 if ((ifp->int_ahash = *hifp) != 0)
117 (*hifp)->int_ahash_prev = &ifp->int_ahash;
118 *hifp = ifp;
120 if (ifp->int_if_flags & IFF_BROADCAST) {
121 hifp = BHASH(ifp->int_brdaddr);
122 ifp->int_bhash_prev = hifp;
123 if ((ifp->int_bhash = *hifp) != 0)
124 (*hifp)->int_bhash_prev = &ifp->int_bhash;
125 *hifp = ifp;
128 if (ifp->int_state & IS_REMOTE) {
129 ifp->int_rlink_prev = &remote_if;
130 ifp->int_rlink = remote_if;
132 remote_if->int_rlink_prev = &ifp->int_rlink;
133 remote_if = ifp;
136 hifp = nhash(ifp->int_name);
137 if (ifp->int_state & IS_ALIAS) {
142 ifp->int_nhash_prev = hifp;
143 if ((ifp->int_nhash = *hifp) != 0)
144 (*hifp)->int_nhash_prev = &ifp->int_nhash;
145 *hifp = ifp;
156 struct interface *ifp, *possible = 0;
160 for (ifp = *AHASH(addr); ifp; ifp = ifp->int_ahash) {
161 if (ifp->int_addr != addr)
163 if ((ifp->int_state & remote) != 0)
165 if ((ifp->int_state & (IS_BROKE | IS_PASSIVE)) == 0)
166 return ifp;
167 possible = ifp;
173 for (ifp = *BHASH(addr); ifp; ifp = ifp->int_bhash) {
174 if (ifp->int_brdaddr != addr)
176 if ((ifp->int_state & remote) != 0)
178 if ((ifp->int_state & (IS_BROKE | IS_PASSIVE)) == 0)
179 return ifp;
180 possible = ifp;
193 struct interface *ifp;
196 for (ifp = *nhash(name); ifp != 0; ifp = ifp->int_nhash) {
201 if (!strcmp(ifp->int_name, name)
202 && ((addr == 0 && !(ifp->int_state & IS_ALIAS))
203 || (ifp->int_addr == addr)))
204 return ifp;
221 struct interface *ifp;
224 for (ifp = ifnet; 0 != ifp; ifp = ifp->int_next) {
225 if (ifp->int_index == ifindex)
226 return ifp;
247 struct interface *ifp, *maybe;
252 for (ifp = ifnet; ifp; ifp = ifp->int_next) {
253 if (ifp->int_if_flags & IFF_POINTOPOINT) {
255 if (ifp->int_dstaddr == addr)
256 return ifp;
260 if (ifp->int_addr == addr)
261 return ifp;
265 if (on_net(addr, ifp->int_net, ifp->int_mask)
267 || ifp->int_mask > maybe->int_mask))
268 maybe = ifp;
307 struct interface *ifp) /* as seen on this interface */
315 if (ifp != 0 && ifp->int_ripv1_mask != HOST_MASK) {
319 if (on_net(addr, ifp->int_net, ifp->int_std_mask))
320 mask = ifp->int_ripv1_mask;
329 for (ifp = ifnet; ifp != 0; ifp = ifp->int_next) {
330 if (on_net(addr, ifp->int_std_net, ifp->int_std_mask)
331 && ifp->int_ripv1_mask > mask
332 && ifp->int_ripv1_mask != HOST_MASK)
333 mask = ifp->int_ripv1_mask;
358 struct interface *ifp) /* as seen on this interface */
360 naddr mask = ripv1_mask_net(addr, ifp);
399 struct interface *ifp;
401 for (ifp = ifnet; 0 != ifp; ifp = ifp->int_next) {
402 if (ifp->int_mask != mask)
405 if (!iff_up(ifp->int_if_flags))
411 if ((!(ifp->int_state & IS_REMOTE) || !(if_flags & IS_REMOTE))
412 && ifp->int_addr == addr
413 && (((if_flags|ifp->int_if_flags) & IFF_POINTOPOINT) == 0))
414 return ifp;
416 if (on_net(ifp->int_dstaddr, ntohl(dstaddr),mask))
417 return ifp;
427 check_remote(struct interface *ifp)
432 if (!(ifp->int_state & IS_REMOTE))
435 rt = rtfind(ifp->int_addr);
438 &&on_net(ifp->int_addr,
445 if (!(ifp->int_state & IS_BROKE)) {
447 naddr_ntoa(ifp->int_addr));
448 if_bad(ifp);
457 ifdel(struct interface *ifp)
463 trace_if("Del", ifp);
465 ifp->int_state |= IS_BROKE;
469 *ifp->int_prev = ifp->int_next;
470 if (ifp->int_next != 0)
471 ifp->int_next->int_prev = ifp->int_prev;
472 *ifp->int_ahash_prev = ifp->int_ahash;
473 if (ifp->int_ahash != 0)
474 ifp->int_ahash->int_ahash_prev = ifp->int_ahash_prev;
475 *ifp->int_nhash_prev = ifp->int_nhash;
476 if (ifp->int_nhash != 0)
477 ifp->int_nhash->int_nhash_prev = ifp->int_nhash_prev;
478 if (ifp->int_if_flags & IFF_BROADCAST) {
479 *ifp->int_bhash_prev = ifp->int_bhash;
480 if (ifp->int_bhash != 0)
481 ifp->int_bhash->int_bhash_prev = ifp->int_bhash_prev;
483 if (ifp->int_state & IS_REMOTE) {
484 *ifp->int_rlink_prev = ifp->int_rlink;
485 if (ifp->int_rlink != 0)
486 ifp->int_rlink->int_rlink_prev = ifp->int_rlink_prev;
489 if (!(ifp->int_state & IS_ALIAS)) {
493 if (ifp1 != ifp
494 && !strcmp(ifp->int_name, ifp1->int_name))
498 if ((ifp->int_if_flags & IFF_MULTICAST)
500 && !(ifp->int_if_flags & IFF_POINTOPOINT)
505 m.imr_interface.s_addr = htonl(ifp->int_index);
507 m.imr_interface.s_addr = ((ifp->int_if_flags
509 ? ifp->int_dstaddr
510 : ifp->int_addr);
517 if (rip_sock_mcast == ifp)
520 if (ifp->int_rip_sock >= 0) {
521 (void)close(ifp->int_rip_sock);
522 ifp->int_rip_sock = -1;
527 if (!IS_RIP_OFF(ifp->int_state))
536 set_rdisc_mg(ifp, 0);
537 if_bad_rdisc(ifp);
540 free(ifp);
547 if_sick(struct interface *ifp)
549 if (0 == (ifp->int_state & (IS_SICK | IS_BROKE))) {
550 ifp->int_state |= IS_SICK;
551 ifp->int_act_time = NEVER;
552 trace_if("Chg", ifp);
562 if_bad(struct interface *ifp)
567 if (ifp->int_state & IS_BROKE)
572 ifp->int_state |= (IS_BROKE | IS_SICK);
573 ifp->int_act_time = NEVER;
574 ifp->int_query_time = NEVER;
575 ifp->int_data.ts = now.tv_sec;
577 trace_if("Chg", ifp);
579 if (!(ifp->int_state & IS_ALIAS)) {
581 if (ifp1 != ifp
582 && !strcmp(ifp->int_name, ifp1->int_name))
586 if_bad_rdisc(ifp);
594 if_ok(struct interface *ifp,
600 if (!(ifp->int_state & IS_BROKE)) {
601 if (ifp->int_state & IS_SICK) {
604 ifp->int_name, naddr_ntoa(ifp->int_dstaddr));
605 ifp->int_state &= ~IS_SICK;
611 type, ifp->int_name, naddr_ntoa(ifp->int_dstaddr));
612 ifp->int_state &= ~(IS_BROKE | IS_SICK);
613 ifp->int_data.ts = 0;
615 if (!(ifp->int_state & IS_ALIAS)) {
617 if (ifp1 != ifp
618 && !strcmp(ifp->int_name, ifp1->int_name))
621 if_ok_rdisc(ifp);
624 if (ifp->int_state & IS_REMOTE) {
625 if (!addrouteforif(ifp))
696 struct interface ifs, ifs0, *ifp, *ifp1;
716 for (ifp = ifnet; 0 != ifp; ifp = ifp->int_next)
717 ifp->int_state &= ~(IS_CHECKED | IS_DUP);
940 ifp = ifwithname(ifs.int_name, ((ifs.int_state & IS_ALIAS)
943 if (ifp != 0) {
944 ifp->int_state |= IS_CHECKED;
946 if (0 != ((ifp->int_if_flags ^ ifs.int_if_flags)
951 || 0 != ((ifp->int_state ^ ifs.int_state)
953 || ifp->int_addr != ifs.int_addr
954 || ifp->int_brdaddr != ifs.int_brdaddr
955 || ifp->int_dstaddr != ifs.int_dstaddr
956 || ifp->int_mask != ifs.int_mask
957 || ifp->int_metric != ifs.int_metric) {
962 ifp->int_name);
963 ifdel(ifp);
964 ifp = 0;
968 if (ifp != 0) {
972 if (ifp->int_state & IS_ALIAS)
978 if (iff_up(ifp->int_if_flags)) {
980 ifp->int_name,
981 naddr_ntoa(ifp->int_dstaddr));
982 if_bad(ifp);
983 ifp->int_if_flags &= ~IFF_UP;
984 } else if (now.tv_sec>(ifp->int_data.ts
988 ifp->int_name,
990 ifp->int_data.ts);
991 ifdel(ifp);
992 ifp = 0;
997 if (!iff_up(ifp->int_if_flags)) {
998 ifp->int_if_flags |= IFF_UP;
999 (void)if_ok(ifp, "");
1005 if (now.tv_sec < ifp->int_data.ts+CHECK_BAD_INTERVAL)
1008 in = ifs.int_data.ipackets - ifp->int_data.ipackets;
1009 ierr = ifs.int_data.ierrors - ifp->int_data.ierrors;
1010 out = ifs.int_data.opackets - ifp->int_data.opackets;
1011 oerr = ifs.int_data.oerrors - ifp->int_data.oerrors;
1015 if (ifp->int_data.ts == 0) {
1016 ifp->int_data = ifs.int_data;
1019 ifp->int_data = ifs.int_data;
1040 if (!(ifp->int_state & IS_SICK)) {
1044 ifp->int_name,
1045 naddr_ntoa(ifp->int_dstaddr),
1047 if_sick(ifp);
1050 if (!(ifp->int_state & IS_BROKE)) {
1053 ifp->int_name,
1054 naddr_ntoa(ifp->int_dstaddr),
1056 if_bad(ifp);
1063 ifp->int_act_time = now.tv_sec;
1064 (void)if_ok(ifp, "");
1078 ifp = check_dup(ifs.int_addr,ifs.int_dstaddr,ifs.int_mask,
1080 if (ifp != 0) {
1084 if (!strcmp(ifp->int_name, ifs.int_name))
1097 ifp->int_name,
1098 addrname(ifp->int_addr,ifp->int_mask,1),
1099 ((ifp->int_if_flags & IFF_POINTOPOINT)
1101 ((ifp->int_if_flags & IFF_POINTOPOINT)
1102 ? naddr_ntoa(ifp->int_dstaddr) : ""));
1104 ifp->int_state |= IS_DUP;
1120 ifp = (struct interface *)rtmalloc(sizeof(*ifp), "ifinit ifp");
1121 memcpy(ifp, &ifs, sizeof(*ifp));
1122 get_parms(ifp);
1123 if_link(ifp);
1124 trace_if("Add", ifp);
1129 && !(ifp->int_if_flags & IFF_POINTOPOINT)
1130 && ifp->int_addr != RIP_DEFAULT) {
1132 if (ifp1->int_mask == ifp->int_mask)
1139 if (!strcmp(ifp->int_name, ifp1->int_name))
1141 if (on_net(ifp->int_dstaddr,
1144 ifp->int_net, ifp->int_mask)) {
1147 ifp->int_name,
1148 addrname(htonl(ifp->int_net),
1149 ifp->int_mask, 1),
1158 if (!(ifp->int_state & IS_ALIAS)) {
1161 if (!(ifp->int_if_flags & IFF_LOOPBACK))
1163 if (!IS_RIP_OFF(ifp->int_state))
1167 if_ok_rdisc(ifp);
1168 rip_on(ifp);
1181 if ((advertise_mhome && ifp)
1184 && (ifp = ifwithaddr(myaddr, 0, 0)) != 0
1189 if (rt->rt_ifp != ifp
1194 loop_rts.rts_ifp = ifp;
1202 loop_rts.rts_ifp = ifp;
1208 for (ifp = ifnet; ifp != 0; ifp = ifp1) {
1209 ifp1 = ifp->int_next; /* because we may delete it */
1213 if (!(ifp->int_state & (IS_CHECKED | IS_REMOTE))) {
1215 ifp->int_name);
1216 ifdel(ifp);
1220 if ((ifp->int_state & IS_BROKE)
1221 && !(ifp->int_state & IS_PASSIVE))
1227 if (!(ifp->int_state & IS_NO_RIPV1_OUT) && supplier)
1229 if (!(ifp->int_state & IS_NO_RIPV1_IN))
1233 for (ifp = ifnet; ifp != 0; ifp = ifp->int_next) {
1238 if (!addrouteforif(ifp))
1244 if ((ifp->int_if_flags & IFF_POINTOPOINT)
1245 && !(ifp->int_state & IS_REMOTE)
1250 del_static(ifp->int_addr, HOST_MASK, 0, 0);
1251 rt = rtget(ifp->int_addr, HOST_MASK);
1258 || rt->rt_metric > ifp->int_metric) {
1259 ifp1 = ifp;
1270 loop_rts.rts_ifp = ifp;
1272 rtadd(ifp->int_addr, HOST_MASK,
1300 check_net_syn(struct interface *ifp)
1311 ifp->int_state |= IS_NEED_NET_SYN;
1312 rt = rtget(ifp->int_std_addr, ifp->int_std_mask);
1316 || rt->rt_metric > ifp->int_metric)) {
1321 new.rts_ifp = ifp;
1322 new.rts_gate = ifp->int_addr;
1323 new.rts_router = ifp->int_addr;
1324 new.rts_metric = ifp->int_metric;
1325 rtadd(ifp->int_std_addr, ifp->int_std_mask,
1330 ifp->int_state &= ~IS_NEED_NET_SYN;
1332 rt = rtget(ifp->int_std_addr,
1333 ifp->int_std_mask);
1336 && rt->rt_ifp == ifp)
1347 addrouteforif(struct interface *ifp)
1356 if (ifp->int_state & IS_BROKE)
1362 if (ifp->int_state & IS_SUBNET)
1363 check_net_syn(ifp);
1365 dst = (0 != (ifp->int_if_flags & (IFF_POINTOPOINT | IFF_LOOPBACK))
1366 ? ifp->int_dstaddr
1367 : htonl(ifp->int_net));
1369 new.rts_ifp = ifp;
1370 new.rts_router = ifp->int_addr;
1371 new.rts_gate = ifp->int_addr;
1372 new.rts_metric = ifp->int_metric;
1378 if ((ifp->int_state & IS_REMOTE)
1379 && !(ifp->int_state & IS_EXTERNAL)
1380 && !check_remote(ifp))
1387 del_static(dst, ifp->int_mask, 0, 0);
1388 rt = rtget(dst, ifp->int_mask);
1390 if ((rt->rt_ifp != ifp
1391 || rt->rt_router != ifp->int_addr)
1392 && (!(ifp->int_state & IS_DUP)
1404 if (ifp->int_transitions++ > 0)
1406 ifp->int_name);
1408 rtadd(dst, ifp->int_mask, RS_IF, &new);