* Copyright (c) 1982, 1986 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
* @(#)raw_imp.c 7.1 (Berkeley) 6/4/86
#include "../net/route.h"
#include "../net/raw_cb.h"
#include "../netinet/in.h"
#include "../netinet/in_systm.h"
#include "../netinet/in_var.h"
* Generate IMP leader and pass packet to impoutput.
* The user must create a skeletal leader in order to
* communicate message type, message subtype, etc.
* We fill in holes where needed and verify parameters
register struct imp_leader
*ip
;
register struct sockaddr_in
*sin
;
register struct rawcb
*rp
= sotorawcb(so
);
struct control_leader
*cp
;
* Verify user has supplied necessary space
* for the leader and check parameters in it.
if ((m
->m_off
> MMAXOFF
|| m
->m_len
< sizeof(struct control_leader
)) &&
(m
= m_pullup(m
, sizeof(struct control_leader
))) == 0) {
error
= EMSGSIZE
; /* XXX */
cp
= mtod(m
, struct control_leader
*);
if (cp
->dl_mtype
== IMPTYPE_DATA
)
if (m
->m_len
< sizeof(struct imp_leader
) &&
(m
= m_pullup(m
, sizeof(struct imp_leader
))) == 0) {
error
= EMSGSIZE
; /* XXX */
ip
= mtod(m
, struct imp_leader
*);
if (ip
->il_format
!= IMP_NFF
) {
error
= EMSGSIZE
; /* XXX */
if (ip
->il_link
!= IMPLINK_IP
&&
(ip
->il_link
<IMPLINK_LOWEXPER
|| ip
->il_link
>IMPLINK_HIGHEXPER
)) {
* Fill in IMP leader -- impoutput refrains from rebuilding
* the leader when it sees the protocol family PF_IMPLINK.
* (message size calculated by walking through mbuf's)
for (len
= 0, n
= m
; n
; n
= n
->m_next
)
ip
->il_length
= htons((u_short
)(len
<< 3));
sin
= (struct sockaddr_in
*)&rp
->rcb_faddr
;
imp_addr_to_leader(ip
, sin
->sin_addr
.s_addr
); /* BRL */
ia
= in_iaonnetof(in_netof(sin
->sin_addr
));
return (impoutput(ia
->ia_ifp
, m
, (struct sockaddr
*)sin
));