/**************************************************************************/
/* miscellaneous ip routines */
/**************************************************************************/
#include "../h/protosw.h"
#include "../h/socketvar.h"
#include "../net/route.h"
#include "../net/netisr.h"
#include "../bbnnet/in.h"
#include "../bbnnet/in_var.h"
#include "../bbnnet/net.h"
#include "../bbnnet/in_pcb.h"
#include "../bbnnet/fsm.h"
#include "../bbnnet/ip.h"
#include "../bbnnet/icmp.h"
ip_ioctl (inp
, command
, data
)
return in_ioctl (command
, data
);
ip_ctloutput(req
, so
, level
, optname
, optval
)
* O.K., with the berkeley method of using the protocol number for the level,
* what magic cookie should we use to distinguish between IP and the interfaces?
return(ip_getopt(inp
,optname
,optval
));
return(ip_setopt(inp
,optname
,optval
));
ip_setopt (inpcb
, command
, data
)
register struct mbuf
*m
= *data
;
/* this probably breaks!! */
/* turns off use of options */
if ((m
->m_len
< (2 * sizeof(struct in_addr
))) ||
(m
->m_len
> (MAX_IPOPTLEN
- sizeof(struct in_addr
))) ||
(m
->m_len
% sizeof(struct in_addr
)))
* O.K., user process specifies it as:
* D must be our final destination (but we can't
* check that since we haven't connected yet).
* Convert this into a form for ip_output.
inpcb
->inp_optlen
= m
->m_len
;
bcopy (mtod(m
, caddr_t
), inpcb
->inp_options
, (unsigned)m
->m_len
);
* Following could be moved to ip_send(), but let's
* do it once for efficiency even though user may
* retrieve different from what stored.
ipa
= (struct in_addr
*) p
;
ipa
[m
->m_len
/ sizeof(struct in_addr
)] = ipa
[0];
p
[3] = 4; /* offset: counting one based */
* Now we have a correct IP source route recorded,
* and the first hop comes after the source route.
/* they can futz with m */
ip_getopt (inpcb
, command
, data
)
register struct mbuf
*m
= NULL
;
*data
= NULL
; /* o.k. (no data sent on getsockopt) */
m
= m_get(M_WAIT
, MT_SOOPTS
);
m
->m_len
= inpcb
->inp_optlen
;
bcopy (inpcb
->inp_options
, mtod(m
, caddr_t
), (unsigned)m
->m_len
);
u_char inetctlerrmap
[PRC_NCMDS
] =
ENETUNREACH
, /* PRC_IFDOWN: connection oriented protocols use
* interface with their local address. Can't re-route.
0, 0, EHOSTDOWN
, EHOSTUNREACH
,
ENETUNREACH
, EHOSTUNREACH
, ECONNREFUSED
, ECONNREFUSED
,