/* raw_cb.c 4.8 82/04/11 */
#include "../h/socketvar.h"
#include "../net/in_systm.h"
#include "../net/raw_cb.h"
* Routines to manage the raw protocol control blocks.
* hash lookups by protocol family/protocol + address family
* take care of unique address problems per AF?
* redo address binding to allow wildcards
* Allocate a control block and a nominal amount
* of buffer space for the socket.
register struct socket
*so
;
register struct rawcb
*rp
;
* Should we verify address not already in use?
* Some say yes, others no.
if (addr
) switch (addr
->sa_family
) {
if (((struct sockaddr_in
*)addr
)->sin_addr
.s_addr
&&
if_ifwithaddr(addr
) == 0)
* Curious, we convert PUP address format to internet
* to allow us to verify we're asking for an Ethernet
* interface. This is wrong, but things are heavily
* oriented towards the internet addressing scheme, and
* converting internet to PUP would be very expensive.
struct sockaddr_pup
*spup
= (struct sockaddr_pup
*)addr
;
struct sockaddr_in inpup
;
bzero((caddr_t
)&inpup
, sizeof(inpup
));
inpup
.sin_family
= AF_INET
;
inpup
.sin_addr
.s_net
= spup
->sp_net
;
inpup
.sin_addr
.s_impno
= spup
->sp_host
;
if (inpup
.sin_addr
.s_addr
&&
if_ifwithaddr((struct sockaddr
*)&inpup
) == 0)
m
= m_getclr(M_DONTWAIT
);
if (sbreserve(&so
->so_snd
, RAWSNDQ
) == 0)
if (sbreserve(&so
->so_rcv
, RAWRCVQ
) == 0)
rp
= mtod(m
, struct rawcb
*);
so
->so_pcb
= (caddr_t
)rp
;
bcopy((caddr_t
)addr
, (caddr_t
)&rp
->rcb_laddr
, sizeof(*addr
));
rp
->rcb_flags
|= RAW_LADDR
;
* Detach the raw connection block and discard
register struct rawcb
*rp
;
struct socket
*so
= rp
->rcb_socket
;
(void) m_freem(dtom(rp
));
* Disconnect and possibly release resources.
rp
->rcb_flags
&= ~RAW_FADDR
;
if (rp
->rcb_socket
->so_state
& SS_USERGONE
)
* Associate a peer's address with a
bcopy((caddr_t
)addr
, (caddr_t
)&rp
->rcb_faddr
, sizeof(*addr
));
rp
->rcb_flags
|= RAW_FADDR
;