#include "../h/protosw.h"
int ifqmaxlen
= IFQ_MAXLEN
;
* Network interface utility routines.
* Routines with if_ifwith* names take sockaddr *'s as
* parameters. Other routines take value parameters,
* e.g. if_ifwithnet takes the network number.
register struct ifnet
*ifp
;
for (ifp
= ifnet
; ifp
; ifp
= ifp
->if_next
)
(*ifp
->if_init
)(ifp
->if_unit
);
if (ifp
->if_snd
.ifq_maxlen
== 0)
ifp
->if_snd
.ifq_maxlen
= ifqmaxlen
;
* Call each interface on a Unibus reset.
register struct ifnet
*ifp
;
for (ifp
= ifnet
; ifp
; ifp
= ifp
->if_next
)
* Attach an interface to the
* list of "active" interfaces.
register struct ifnet
**p
= &ifnet
;
* Locate an interface based on a complete address.
register struct ifnet
*ifp
;
(bcmp((caddr_t)((a1)->sa_data), (caddr_t)((a2)->sa_data), 14) == 0)
for (ifp
= ifnet
; ifp
; ifp
= ifp
->if_next
) {
if (ifp
->if_addr
.sa_family
!= addr
->sa_family
)
if (equal(&ifp
->if_addr
, addr
))
if ((ifp
->if_flags
& IFF_BROADCAST
) &&
equal(&ifp
->if_broadaddr
, addr
))
* Find an interface on a specific network. If many, choice
register struct sockaddr
*addr
;
register struct ifnet
*ifp
;
register u_int af
= addr
->sa_family
;
register int (*netmatch
)();
netmatch
= afswitch
[af
].af_netmatch
;
for (ifp
= ifnet
; ifp
; ifp
= ifp
->if_next
) {
if (af
!= ifp
->if_addr
.sa_family
)
if ((*netmatch
)(addr
, &ifp
->if_addr
))
* As above, but parameter is network number.
register struct ifnet
*ifp
;
for (ifp
= ifnet
; ifp
; ifp
= ifp
->if_next
)
* Find an interface using a specific address family
register struct ifnet
*ifp
;
for (ifp
= ifnet
; ifp
; ifp
= ifp
->if_next
)
if (ifp
->if_addr
.sa_family
== af
)
* Mark an interface down and notify protocols of
* NOTE: must be called at splnet or eqivalent.
register struct ifnet
*ifp
;
ifp
->if_flags
&= ~IFF_UP
;
pfctlinput(PRC_IFDOWN
, (caddr_t
)&ifp
->if_addr
);
* Handle interface watchdog timer routines. Called
* from softclock, we decrement timers (if set) and
* call the appropriate interface routine on expiration.
register struct ifnet
*ifp
;
for (ifp
= ifnet
; ifp
; ifp
= ifp
->if_next
) {
if (ifp
->if_timer
== 0 || --ifp
->if_timer
)
(*ifp
->if_watchdog
)(ifp
->if_unit
);
timeout(if_slowtimo
, (caddr_t
)0, hz
/ IFNET_SLOWHZ
);