#include "../h/protosw.h"
#include "../net/in_systm.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
)
(*ifp
->if_ubareset
)(uban
);
* 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 int af
= addr
->sa_family
;
register int (*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
register struct ifnet
*ifp
;
ifp
->if_flags
&= ~IFF_UP
;
pfctlinput(PRC_IFDOWN
, (caddr_t
)&ifp
->if_addr
);
* Formulate an Internet address from network + host. Used in
* building addresses stored in the ifnet structure.
addr
= (net
<< 24) | host
;
addr
= (net
<< 16) | host
;
addr
= (net
<< 8) | host
;
return (*(struct in_addr
*)&addr
);
* Initialize an interface's routing
* table entry according to the network.
register struct ifnet
*ifp
;
if (ifp
->if_flags
& IFF_ROUTE
)
bzero((caddr_t
)&sin
, sizeof (sin
));
sin
.sin_family
= AF_INET
;
sin
.sin_addr
= if_makeaddr(ifp
->if_net
, 0);
rtinit(&sin
, &ifp
->if_addr
, flags
);