Merge of branches/team/network/new_stack - not yet complete as SVN does only support

replacing files when merging when you don't have deleted them manually (for some reason,
it only works as part of the merge operation, and we didn't copy the whole tree to
have "a fresh start" - next time we know better, at least if SVN still suffers from
that same limitation).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18456 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2006-08-08 12:33:33 +00:00
parent 70418bc5bf
commit 5adca30a18
406 changed files with 17948 additions and 26566 deletions
-59
View File
@@ -1,59 +0,0 @@
/* Parts of this file are covered under the following copyright */
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)icmp_var.h 8.1 (Berkeley) 6/10/93
*/
#ifndef NETINET_ICMP_VAR_H
#define NETINET_ICMP_VAR_H
#include "netinet/ip_icmp.h"
struct icmpstat {
int32 icps_oldicmp;
int32 icps_oldshort;
int32 icps_badcode;
int32 icps_badlen;
int32 icps_checksum;
int32 icps_tooshort;
int32 icps_error;
int32 icps_reflect;
int32 icps_outhist[ICMP_MAXTYPE + 1];
int32 icps_inhist[ICMP_MAXTYPE + 1];
};
//#ifdef _KERNEL_MODE
//struct icmpstat icmpstat;
//#endif
#endif /* NETINET_ICMP_VAR_H */
-198
View File
@@ -1,198 +0,0 @@
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)if_ether.h 8.1 (Berkeley) 6/10/93
*/
#ifndef NETINET_IF_ETHER_H
#define NETINET_IF_ETHER_H
#include "net/if_arp.h"
/*
* Ethernet address - 6 octets
* this is only used by the ethers(3) functions.
*/
struct ether_addr {
uint8 ether_addr_octet[6];
};
/*
* Some Ethernet constants.
*/
#define ETHER_ADDR_LEN 6 /* Ethernet address length */
#define ETHER_TYPE_LEN 2 /* Ethernet type field length */
#define ETHER_CRC_LEN 4 /* Ethernet CRC lenght */
#define ETHER_HDR_LEN ((ETHER_ADDR_LEN * 2) + ETHER_TYPE_LEN)
#define ETHER_MIN_LEN 64 /* Minimum frame length, CRC included */
#define ETHER_MAX_LEN 1518 /* Maximum frame length, CRC included */
struct ether_header {
uint8 ether_dhost[ETHER_ADDR_LEN];
uint8 ether_shost[ETHER_ADDR_LEN];
uint16 ether_type;
};
#define ETHERTYPE_PUP 0x0200 /* PUP protocol */
#define ETHERTYPE_IP 0x0800 /* IP protocol */
#define ETHERTYPE_ARP 0x0806 /* address resolution protocol */
#define ETHERTYPE_REVARP 0x8035 /* reverse addr resolution protocol */
#define ETHERTYPE_8021Q 0x8100 /* IEEE 802.1Q VLAN tagging */
#define ETHERTYPE_IPV6 0x86DD /* IPv6 protocol */
#define ETHERTYPE_PPPOEDISC 0x8863 /* PPP Over Ethernet Discovery Stage */
#define ETHERTYPE_PPPOE 0x8864 /* PPP Over Ethernet Session Stage */
#define ETHERTYPE_LOOPBACK 0x9000 /* used to test interfaces */
#define ETHER_IS_MULTICAST(addr) (*(addr) & 0x01) /* is address mcast/bcast? */
#define ETHERMTU (ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN)
#define ETHERMIN (ETHER_MIN_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN)
//#ifdef _NETWORK_STACK
/*
* Macro to map an IP multicast address to an Ethernet multicast address.
* The high-order 25 bits of the Ethernet address are statically assigned,
* and the low-order 23 bits are taken from the low end of the IP address.
*/
#define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \
/* struct in_addr *ipaddr; */ \
/* u_int8_t enaddr[ETHER_ADDR_LEN]; */ \
{ \
(enaddr)[0] = 0x01; \
(enaddr)[1] = 0x00; \
(enaddr)[2] = 0x5e; \
(enaddr)[3] = ((uint8 *)ipaddr)[1] & 0x7f; \
(enaddr)[4] = ((uint8 *)ipaddr)[2]; \
(enaddr)[5] = ((uint8 *)ipaddr)[3]; \
}
/*
* Macro to map an IPv6 multicast address to an Ethernet multicast address.
* The high-order 16 bits of the Ethernet address are statically assigned,
* and the low-order 32 bits are taken from the low end of the IPv6 address.
*/
#define ETHER_MAP_IPV6_MULTICAST(ip6addr, enaddr) \
/* struct in6_addr *ip6addr; */ \
/* u_int8_t enaddr[ETHER_ADDR_LEN]; */ \
{ \
(enaddr)[0] = 0x33; \
(enaddr)[1] = 0x33; \
(enaddr)[2] = ((u_int8_t *)ip6addr)[12]; \
(enaddr)[3] = ((u_int8_t *)ip6addr)[13]; \
(enaddr)[4] = ((u_int8_t *)ip6addr)[14]; \
(enaddr)[5] = ((u_int8_t *)ip6addr)[15]; \
}
//#endif
/*
* Structure shared between the ethernet driver modules and
* the address resolution code. For example, each ec_softc or il_softc
* begins with this structure.
*/
struct arpcom {
struct ifnet ac_if; /* network-visible interface */
uint8 ac_enaddr[ETHER_ADDR_LEN]; /* ethernet hardware address */
struct in_addr ac_ipaddr;
char ac__pad[2]; /* pad for some machines */
// struct ether_multi *ac_multiaddrs; /* list of ether multicast addrs */
int ac_multicnt; /* length of ac_multiaddrs list */
};
struct ether_device {
struct arpcom sc_ac;
struct ether_device *next; /* next ether_device */
};
#define sc_if sc_ac.ac_if
#define sc_addr sc_ac.ac_enaddr
struct ether_arp {
struct arphdr ea_hdr;
u_char arp_sha[6];
u_char arp_spa[4];
u_char arp_tha[6];
u_char arp_tpa[4];
};
#define arp_hrd ea_hdr.ar_hrd
#define arp_pro ea_hdr.ar_pro
#define arp_hln ea_hdr.ar_hln
#define arp_pln ea_hdr.ar_pln
#define arp_op ea_hdr.ar_op
struct llinfo_arp {
struct llinfo_arp *la_next;
struct llinfo_arp *la_prev;
struct rtentry *la_rt;
struct mbuf *la_hold;
int32 la_asked;
};
#define la_timer la_rt->rt_rmx.rmx_expire
struct sockaddr_inarp {
uint8 sin_len;
uint8 sin_family;
uint16 sin_port;
struct in_addr sin_addr;
struct in_addr sin_srcaddr;
uint16 sin_tos;
uint16 sin_other;
};
#define SIN_PROXY 1
/*
* IP and ethernet specific routing flags
*/
#define RTF_USETRAILERS RTF_PROTO1 /* use trailers */
#define RTF_ANNOUNCE RTF_PROTO2 /* announce new arp entry */
#define RTF_PERMANENT_ARP RTF_PROTO3 /* only manual overwrite of entry */
//#ifdef _NETWORK_STACK
int arpresolve(struct arpcom *ac, struct rtentry *rt, struct mbuf *m,
struct sockaddr *dst, uint8 *desten);
//void arpwhohas(struct arpcom *ac, struct in_addr *ia);
//#else
char *ether_ntoa (struct ether_addr *);
struct ether_addr *ether_aton (char *);
int ether_ntohost (char *, struct ether_addr *);
int ether_hostton (char *, struct ether_addr *);
int ether_line(char *line, struct ether_addr *e, char *hostname);
//#endif
#endif /* NETINET_IF_ETHER_H */
+17 -16
View File
@@ -6,20 +6,21 @@
#include <sys/types.h>
#include <net/if.h>
#include <endian.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef unsigned short in_port_t;
typedef unsigned long in_addr_t;
typedef uint16_t in_port_t;
typedef uint32_t in_addr_t;
/* We can't include <ByteOrder.h> since we are a posix file,
* and we are not allowed to import all the BeOS types here.
*/
#ifndef htonl
extern unsigned long __swap_int32(unsigned long); /* private */
extern unsigned short __swap_int16(unsigned short); /* private */
extern uint32_t __swap_int32(uint32_t); /* private */
extern uint16_t __swap_int16(uint16_t); /* private */
#if BYTE_ORDER == LITTLE_ENDIAN
#define htonl(x) __swap_int32(x)
#define ntohl(x) __swap_int32(x)
@@ -73,11 +74,11 @@ struct in_addr {
* IP Version 4 socket address.
*/
struct sockaddr_in {
uint8 sin_len;
uint8 sin_family;
uint16 sin_port;
uint8_t sin_len;
uint8_t sin_family;
uint16_t sin_port;
struct in_addr sin_addr;
int8 sin_zero[24];
int8_t sin_zero[24];
};
/* the address is therefore at sin_addr.s_addr */
@@ -99,7 +100,7 @@ struct sockaddr_in {
#define IP_ADD_MEMBERSHIP 12 /* ip_mreq; add an IP group membership */
#define IP_DROP_MEMBERSHIP 13 /* ip_mreq; drop an IP group membership */
#define __IPADDR(x) ((uint32) htonl((uint32)(x)))
#define __IPADDR(x) ((uint32_t)htonl((uint32_t)(x)))
#define INADDR_ANY __IPADDR(0x00000000)
#define INADDR_LOOPBACK __IPADDR(0x7f000001)
@@ -114,27 +115,27 @@ struct sockaddr_in {
#define INADDR_NONE __IPADDR(0xffffffff)
#define IN_CLASSA(i) (((uint32)(i) & __IPADDR(0x80000000)) == \
#define IN_CLASSA(i) (((uint32_t)(i) & __IPADDR(0x80000000)) == \
__IPADDR(0x00000000))
#define IN_CLASSA_NET __IPADDR(0xff000000)
#define IN_CLASSA_NSHIFT 24
#define IN_CLASSA_HOST __IPADDR(0x00ffffff)
#define IN_CLASSA_MAX 128
#define IN_CLASSB(i) (((uint32)(i) & __IPADDR(0xc0000000)) == \
#define IN_CLASSB(i) (((uint32_t)(i) & __IPADDR(0xc0000000)) == \
__IPADDR(0x80000000))
#define IN_CLASSB_NET __IPADDR(0xffff0000)
#define IN_CLASSB_NSHIFT 16
#define IN_CLASSB_HOST __IPADDR(0x0000ffff)
#define IN_CLASSB_MAX 65536
#define IN_CLASSC(i) (((uint32)(i) & __IPADDR(0xe0000000)) == \
#define IN_CLASSC(i) (((uint32_t)(i) & __IPADDR(0xe0000000)) == \
__IPADDR(0xc0000000))
#define IN_CLASSC_NET __IPADDR(0xffffff00)
#define IN_CLASSC_NSHIFT 8
#define IN_CLASSC_HOST __IPADDR(0x000000ff)
#define IN_CLASSD(i) (((uint32)(i) & __IPADDR(0xf0000000)) == \
#define IN_CLASSD(i) (((uint32_t)(i) & __IPADDR(0xf0000000)) == \
__IPADDR(0xe0000000))
/* These ones aren't really net and host fields, but routing needn't know. */
#define IN_CLASSD_NET __IPADDR(0xf0000000)
@@ -143,8 +144,8 @@ struct sockaddr_in {
#define IN_MULTICAST(i) IN_CLASSD(i)
#define IN_EXPERIMENTAL(i) (((uint32)(i) & 0xf0000000) == 0xf0000000)
#define IN_BADCLASS(i) (((uint32)(i) & 0xf0000000) == 0xf0000000)
#define IN_EXPERIMENTAL(i) (((uint32_t)(i) & 0xf0000000) == 0xf0000000)
#define IN_BADCLASS(i) (((uint32_t)(i) & 0xf0000000) == 0xf0000000)
#define IP_MAX_MEMBERSHIPS 20
@@ -163,7 +164,7 @@ int in_localaddr (struct in_addr);
void in_socktrim (struct sockaddr_in*);
/* uint16 in_cksum (struct mbuf *, int); */
struct mbuf;
uint16 in_cksum(struct mbuf *m, int len, int off);
uint16_t in_cksum(struct mbuf *m, int len, int off);
#ifdef __cplusplus
}
-71
View File
@@ -1,71 +0,0 @@
/* in_pcb.h
* internet protcol control blocks
*/
//#include <sys/socketvar.h>
#include <sys/socket.h>
#include <pools.h>
#include <netinet/ip.h>
#include <netinet/in.h>
#include <net/route.h>
#ifndef _NETINET_INPCB_H
#define _NETINET_INPCB_H
enum {
INP_HDRINCL = 0x01,
INP_RECVOPTS = 0x02,
INP_RECVRETOPTS = 0x04,
INP_RECVDSTADDR = 0x08 /* receive IP destination as control inf. */
};
#define INP_CONTROLOPT (INP_RECVOPTS | INP_RECVRETOPTS | INP_RECVDSTADDR)
/* Constants for in_pcblookup */
enum {
INPLOOKUP_WILDCARD = 1,
INPLOOKUP_SETLOCAL = 2,
INPLOOKUP_IPV6 = 4
};
struct inpcb {
struct inpcb *inp_next;
struct inpcb *inp_prev;
struct inpcb *inp_head;
struct in_addr faddr; /* foreign address */
uint16 fport; /* foreign port # */
struct in_addr laddr; /* local address */
uint16 lport; /* local port # */
struct socket *inp_socket;
char *inp_ppcb; /* pointer to a per protocol pcb*/
struct ip inp_ip; /* header prototype */
int inp_flags; /* flags */
struct mbuf *inp_options; /* IP options */
/* more will be required */
struct route inp_route; /* the route to host */
};
int in_pcbinit (void);
int in_pcballoc (struct socket *, struct inpcb *);
int in_pcbbind (struct inpcb *, struct mbuf *);
int in_pcbconnect (struct inpcb *, struct mbuf *);
void in_pcbdetach (struct inpcb *);
int in_pcbdisconnect (struct inpcb *);
void in_losing (struct inpcb *);
void in_setpeeraddr (struct inpcb *, struct mbuf *);
void in_setsockaddr (struct inpcb *, struct mbuf *);
struct inpcb *in_pcblookup(struct inpcb *head, struct in_addr faddr,
uint16 fport_a, struct in_addr laddr,
uint16 lport_a, int flags);
struct rtentry *in_pcbrtentry (struct inpcb *);
void in_pcbnotify (struct inpcb *, struct sockaddr *,
uint16, struct in_addr, uint16,
int, void (*)(struct inpcb *, int));
/* helpful macro's */
#define sotoinpcb(so) ((struct inpcb *)(so)->so_pcb)
#endif /* _NETINET_INPCB_H */
-62
View File
@@ -1,62 +0,0 @@
/*
* Copyright (c) 1982, 1986, 1993
*The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
*This product includes software developed by the University of
*California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*@(#)in_systm.h 8.1 (Berkeley) 6/10/93
*/
#ifndef NETINET_IN_SYSTM_H
#define NETINET_IN_SYSTM_H
#include <stdint.h>
/*
* Miscellaneous internetwork
* definitions for kernel.
*/
/*
* Network types.
*
* Internally the system keeps counters in the headers with the bytes
* swapped so that VAX instructions will work on them. It reverses
* the bytes before transmission at each protocol level. The n_ types
* represent the types with the bytes in ``high-ender'' order.
*/
typedef uint16_t n_short; /* short as received from the net */
typedef uint32_t n_long; /* long as received from the net */
typedef uint32_t n_time; /* ms since 00:00 GMT, byte rev */
#define iptime() (htonl((uint32_t)real_time_clock_usecs()))
#endif /* NETINET_IN_SYSTM_H */
-66
View File
@@ -1,66 +0,0 @@
/* in_var.h */
#ifndef NETINET_IN_VAR_H
#define NETINET_IN_VAR_H
#include <netinet/in.h>
#include <net/if.h>
struct in_ifaddr {
struct ifaddr ia_ifa;
struct in_ifaddr *ia_next;
uint32 ia_net;
uint32 ia_netmask;
uint32 ia_subnet;
uint32 ia_subnetmask;
struct in_addr ia_netbroadcast;
struct sockaddr_in ia_addr;
struct sockaddr_in ia_dstaddr; /* broadcast address */
struct sockaddr_in ia_sockmask;
/*XXX - milticast address list */
};
#define ia_ifp ia_ifa.ifa_ifp
#define ia_flags ia_ifa.ifa_flags
#define ia_broadaddr ia_dstaddr
#define ifatoia(ifa) ((struct in_ifaddr *)(ifa))
#define sintosa(sin) ((struct sockaddr *)(sin))
/* used to pass in additional information, such as aliases */
struct in_aliasreq {
char ifa_name[IFNAMSIZ];
struct sockaddr_in ifra_addr;
struct sockaddr_in ifra_broadaddr;
#define ifra_dstaddr ifra_broadaddr
struct sockaddr_in ifra_mask;
};
struct in_multi {
struct in_addr inm_addr;
struct ifnet *inm_ifp;
struct in_ifaddr *inm_ia;
uint inm_refcount;
uint inm_timer;
struct in_multi *next;
struct in_multi **prev;
uint inm_state;
};
/*
* Given a pointer to an in_ifaddr (ifaddr),
* return a pointer to the addr as a sockaddr_in.
*/
#define IA_SIN(ia) (&(((struct in_ifaddr *)(ia))->ia_addr))
// extern struct in_ifaddr *in_ifaddr;
int in_control(struct socket *so, int cmd, char *data, struct ifnet *ifp);
int in_ifinit(struct ifnet *dev, struct in_ifaddr *ia, struct sockaddr_in *sin,
int scrub);
int inetctlerr(int cmd);
struct in_ifaddr *get_primary_addr(void);
#endif /* NETINET_IN_VAR_H */
+2 -3
View File
@@ -5,7 +5,6 @@
#ifndef _NETINET_IP_H
#define _NETINET_IP_H
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <stdint.h>
@@ -81,10 +80,10 @@ struct ip_timestamp {
ipt_oflw:4;
#endif
union ipt_timestamp {
n_time ipt_time[1];
uint32_t ipt_time[1];
struct ipt_ta {
struct in_addr ipt_addr;
n_time ipt_time;
uint32_t ipt_time;
} ipt_ta;
} ipt_timestamp;
};
+8 -8
View File
@@ -50,27 +50,27 @@ struct icmp {
uint8_t ih_pptr;
struct in_addr ih_gwaddr;
struct ih_idseq {
n_short icd_id;
n_short icd_seq;
uint16_t icd_id;
uint16_t icd_seq;
} ih_idseq;
int32_t ih_void;
/* ICMP_UNREACH_NEEDFRAG (RFC 1191) */
struct ih_pmtu {
n_short ipm_void;
n_short ipm_nextmtu;
uint16_t ipm_void;
uint16_t ipm_nextmtu;
} ih_pmtu;
} icmp_hun;
union {
struct id_ts {
n_time its_otime;
n_time its_rtime;
n_time its_ttime;
uint32_t its_otime;
uint32_t its_rtime;
uint32_t its_ttime;
} id_ts;
struct id_ip {
struct ip idi_ip;
} id_ip;
uint32 id_mask;
uint32_t id_mask;
char id_data[1];
} icmp_dun;
};
-63
View File
@@ -1,63 +0,0 @@
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)tcp_debug.h 8.1 (Berkeley) 6/10/93
*/
#ifndef NETINET_TCP_DEBUG_H_
#define NETINET_TCP_DEBUG_H_
struct tcp_debug {
n_time td_time;
short td_act;
short td_ostate;
caddr_t td_tcb;
struct tcpiphdr td_ti;
short td_req;
struct tcpcb td_cb;
};
#define TA_INPUT 0
#define TA_OUTPUT 1
#define TA_USER 2
#define TA_RESPOND 3
#define TA_DROP 4
//#ifdef TANAMES
//char *tanames[] =
// { "input", "output", "user", "respond", "drop" };
//#endif /* TANAMES */
#define TCP_NDEBUG 100
struct tcp_debug tcp_debug[TCP_NDEBUG];
int tcp_debx;
#endif /* _NETINET_TCP_DEBUG_H_ */
-86
View File
@@ -1,86 +0,0 @@
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)tcp_fsm.h 8.1 (Berkeley) 6/10/93
*/
#ifndef _NETINET_TCP_FSM_H_
#define _NETINET_TCP_FSM_H_
/*
* TCP FSM state definitions.
* Per RFC793, September, 1981.
*/
#define TCP_NSTATES 11
#define TCPS_CLOSED 0 /* closed */
#define TCPS_LISTEN 1 /* listening for connection */
#define TCPS_SYN_SENT 2 /* active, have sent syn */
#define TCPS_SYN_RECEIVED 3 /* have sent and received syn */
/* states < TCPS_ESTABLISHED are those where connections not established */
#define TCPS_ESTABLISHED 4 /* established */
#define TCPS_CLOSE_WAIT 5 /* rcvd fin, waiting for close */
/* states > TCPS_CLOSE_WAIT are those where user has closed */
#define TCPS_FIN_WAIT_1 6 /* have closed, sent fin */
#define TCPS_CLOSING 7 /* closed xchd FIN; await ACK */
#define TCPS_LAST_ACK 8 /* had fin and close; await FIN ACK */
/* states > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN */
#define TCPS_FIN_WAIT_2 9 /* have closed, fin is acked */
#define TCPS_TIME_WAIT 10 /* in 2*msl quiet wait after close */
#define TCPS_HAVERCVDSYN(s) ((s) >= TCPS_SYN_RECEIVED)
#define TCPS_HAVEESTABLISHED(s) ((s) >= TCPS_ESTABLISHED)
#define TCPS_HAVERCVDFIN(s) ((s) >= TCPS_TIME_WAIT)
#ifdef TCPOUTFLAGS
/*
* Flags used when sending segments in tcp_output.
* Basic flags (TH_RST,TH_ACK,TH_SYN,TH_FIN) are totally
* determined by state, with the proviso that TH_FIN is sent only
* if all data queued for output is included in the segment.
*/
u_char tcp_outflags[TCP_NSTATES] = {
TH_RST|TH_ACK, 0, TH_SYN, TH_SYN|TH_ACK,
TH_ACK, TH_ACK,
TH_FIN|TH_ACK, TH_ACK, TH_FIN|TH_ACK, TH_ACK, TH_ACK,
};
#endif /* TCPOUTFLAGS */
#ifdef TCPSTATES
char *tcpstates[] = {
"CLOSED", "LISTEN", "SYN_SENT", "SYN_RCVD",
"ESTABLISHED", "CLOSE_WAIT", "FIN_WAIT_1", "CLOSING",
"LAST_ACK", "FIN_WAIT_2", "TIME_WAIT",
};
#endif /* TCPSTATES */
#endif /* _NETINET_TCP_FSM_H_ */
-67
View File
@@ -1,67 +0,0 @@
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)tcp_seq.h 8.1 (Berkeley) 6/10/93
*/
#ifndef _NETINET_TCP_SEQ_H_
#define _NETINET_TCP_SEQ_H_
/*
* TCP sequence numbers are 32 bit integers operated
* on with modular arithmetic. These macros can be
* used to compare such integers.
*/
#define SEQ_LT(a,b) ((int)((a)-(b)) < 0)
#define SEQ_LEQ(a,b) ((int)((a)-(b)) <= 0)
#define SEQ_GT(a,b) ((int)((a)-(b)) > 0)
#define SEQ_GEQ(a,b) ((int)((a)-(b)) >= 0)
/*
* Macros to initialize tcp sequence numbers for
* send and receive from initial send and receive
* sequence numbers.
*/
#define tcp_rcvseqinit(tp) \
(tp)->rcv_adv = (tp)->rcv_nxt = (tp)->irs + 1
#define tcp_sendseqinit(tp) \
(tp)->snd_una = (tp)->snd_nxt = (tp)->snd_max = (tp)->snd_up = \
(tp)->iss
#define TCP_ISSINCR (125*1024) /* increment for tcp_iss each second */
//#ifdef _NETWORK_STACK
extern tcp_seq tcp_iss; /* tcp initial send seq # */
//#endif /* _NETWORK_STACK */
#endif /* _NETINET_TCP_SEQ_H_ */
-137
View File
@@ -1,137 +0,0 @@
/*
* Copyright (c) 1982, 1986, 1993
*The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
*
* This product includes software developed by the University of
* California, Berkeley and its contributors.
*
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#ifndef NETINET_TCP_TIMERS_H
#define NETINET_TCP_TIMERS_H
/*
* Definitions of the TCP timers. These timers are counted
* down PR_SLOWHZ times a second.
*/
#define TCPT_NTIMERS 4
#define TCPT_REXMT 0 /* retransmission timer */
#define TCPT_PERSIST 1 /* presist timer */
#define TCPT_KEEP 2 /* keeplaive timer or conn est timer */
#define TCPT_2MSL 3 /* 2MSL timer or FIN_WAIT_2 timer */
/*
* The TCPT_REXMT timer is used to force retransmissions.
* The TCP has the TCPT_REXMT timer set whenever segments
* have been sent for which ACKs are expected but not yet
* received. If an ACK is received which advances tp->snd_una,
* then the retransmit timer is cleared (if there are no more
* outstanding segments) or reset to the base value (if there
* are more ACKs expected). Whenever the retransmit timer goes off,
* we retransmit one unacknowledged segment, and do a backoff
* on the retransmit timer.
*
* The TCPT_PERSIST timer is used to keep window size information
* flowing even if the window goes shut. If all previous transmissions
* have been acknowledged (so that there are no retransmissions in progress),
* and the window is too small to bother sending anything, then we start
* the TCPT_PERSIST timer. When it expires, if the window is nonzero,
* we go to transmit state. Otherwise, at intervals send a single byte
* into the peer's window to force him to update our window information.
* We do this at most as often as TCPT_PERSMIN time intervals,
* but no more frequently than the current estimate of round-trip
* packet time. The TCPT_PERSIST timer is cleared whenever we receive
* a window update from the peer.
*
* The TCPT_KEEP timer is used to keep connections alive. If an
* connection is idle (no segments received) for TCPTV_KEEP_INIT amount of time,
* but not yet established, then we drop the connection. Once the connection
* is established, if the connection is idle for TCPTV_KEEP_IDLE time
* (and keepalives have been enabled on the socket), we begin to probe
* the connection. We force the peer to send us a segment by sending:
* <SEQ=SND.UNA-1><ACK=RCV.NXT><CTL=ACK>
* This segment is (deliberately) outside the window, and should elicit
* an ack segment in response from the peer. If, despite the TCPT_KEEP
* initiated segments we cannot elicit a response from a peer in TCPT_MAXIDLE
* amount of time probing, then we drop the connection.
*/
/*
* Time constants.
*/
#define TCPTV_MSL ( 30*PR_SLOWHZ ) /* max seg lifetime (hah!) */
#define TCPTV_SRTTBASE 0 /* base roundtrip time;
* if 0, no idea yet */
#define TCPTV_SRTTDFLT ( 3*PR_SLOWHZ ) /* assumed RTT if no info */
#define TCPTV_PERSMIN ( 5*PR_SLOWHZ ) /* retransmit persistance */
#define TCPTV_PERSMAX ( 60*PR_SLOWHZ ) /* maximum persist interval */
#define TCPTV_KEEP_INIT ( 75*PR_SLOWHZ ) /* initial connect keep alive */
#define TCPTV_KEEP_IDLE (120*60*PR_SLOWHZ) /* dflt time before probing */
#define TCPTV_KEEPINTVL ( 75*PR_SLOWHZ ) /* default probe interval */
#define TCPTV_KEEPCNT 8 /* max probes before drop */
#define TCPTV_MIN ( 1*PR_SLOWHZ ) /* minimum allowable value */
#define TCPTV_REXMTMAX ( 64*PR_SLOWHZ ) /* max allowable REXMT value */
#define TCP_LINGERTIME 120 /* at most 2 minutes... */
#define TCP_MAXRXTSHIFT 12 /* maximum retransmits */
//#ifdef TCPTIMERS
//char *tcptimers[] =
// { "REXMT", "PERSIST", "KEEP", "2MSL" };
//#endif /* TCPTIMERS */
extern char *tcptimers[];
/*
* Force a time value to be in a certain range.
*/
#define TCPT_RANGESET(tv, value, tvmin, tvmax) { \
(tv) = (value); \
if ((tv) < (tvmin)) \
(tv) = (tvmin); \
else if ((tv) > (tvmax)) \
(tv) = (tvmax); \
}
//#ifdef _NETWORK_STACK
extern int tcptv_keep_init;
extern int tcp_keepidle; /* time before keepalive probes begin */
extern int tcp_keepintvl; /* time between keepalive probes */
extern int tcp_maxidle; /* time to drop after starting probes */
extern int tcp_ttl; /* time to live for TCP segs */
extern int tcp_backoff[];
//#endif /* _NETWORK_STACK */
#endif /* NETINET_TCP_TIMERS_H */
-282
View File
@@ -1,282 +0,0 @@
/*
* Copyright (c) 1982, 1986, 1993
*The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
*
* This product includes software developed by the University of
* California, Berkeley and its contributors.
*
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#ifndef NETINET_TCP_VAR_H
#define NETINET_TCP_VAR_H
/*
* Tcp control block, one per tcp connection
*/
struct tcpcb {
struct tcpiphdr *seg_next;
struct tcpiphdr *seg_prev;
int16 t_state; /* state of this connection */
int16 t_timer[TCPT_NTIMERS]; /* tcp timers */
int16 t_rxtshift; /* log(2) of rexmt exp. backoff */
int16 t_rxtcur; /* current retransmit value */
int16 t_dupacks; /* consecutive dup acks recd */
uint16 t_maxseg; /* maximum segment size */
int8 t_force; /* 1 if forcing out a byte */
uint16 t_flags;
struct tcpiphdr *t_template; /* skeletal packet for transmit */
struct inpcb *t_inpcb; /* back pointer to internet pcb */
/*
* The following fields are used as in the protocol specification.
* See RFC783, Dec. 1981, page 21.
*/
/* send sequence variables */
tcp_seq snd_una; /* send unacknowledged */
tcp_seq snd_nxt; /* send next */
tcp_seq snd_up; /* send urgent pointer */
tcp_seq snd_wl1; /* window update seg seq number */
tcp_seq snd_wl2; /* window update seg ack number */
tcp_seq iss; /* initial send sequence number */
unsigned long snd_wnd; /* send window */
/* receive sequence variables */
unsigned long rcv_wnd; /* receive window */
tcp_seq rcv_nxt; /* receive next */
tcp_seq rcv_up; /* receive urgent pointer */
tcp_seq irs; /* initial receive sequence number */
/*
* Additional variables for this implementation.
*/
/* receive variables */
tcp_seq rcv_adv; /* advertised window */
/* retransmit variables */
tcp_seq snd_max; /* highest sequence number sent;
* used to recognize retransmits
*/
/* congestion control (for slow start, source quench, retransmit after loss) */
unsigned long snd_cwnd; /* congestion-controlled window */
unsigned long snd_ssthresh; /* snd_cwnd size threshhold for
* for slow start exponential to
* linear switch
*/
uint16 t_maxopd; /* mss plus options */
uint16 t_peermss; /* peer's maximum segment size */
/*
* transmit timing stuff. See below for scale of srtt and rttvar.
* "Variance" is actually smoothed difference.
*/
int16 t_idle; /* inactivity time */
int16 t_rtt; /* round trip time */
tcp_seq t_rtseq; /* sequence number being timed */
uint16 t_srtt; /* smoothed round-trip time */
uint16 t_rttvar; /* variance in round-trip time */
uint16 t_rttmin; /* minimum rtt allowed */
uint32 max_sndwnd; /* largest window peer has offered */
/* out-of-band data */
int8 t_oobflags; /* have some */
int8 t_iobc; /* input character */
int16 t_softerror; /* possible error, not yet reported... */
/* RFC 1323 variables */
uint8 snd_scale; /* window scaling for send window */
uint8 rcv_scale; /* window scaling for recv window */
uint8 request_r_scale; /* pending window scaling */
uint8 requested_s_scale;
uint32 ts_recent; /* timestamp echo data */
uint32 ts_recent_age; /* when last updated */
tcp_seq last_ack_sent;
};
#define intotcpcb(ip) ((struct tcpcb*)(ip)->inp_ppcb)
#define sototcpcb(so) (intotcpcb(sotoinpcb(so)))
#define TF_ACKNOW 0x0001 /* send ACK immeadiately */
#define TF_DELACK 0x0002 /* send ACK, but try to delay it */
#define TF_NODELAY 0x0004 /* don't delay packets to coalesce */
#define TF_NOOPT 0x0008 /* don't use tcp options */
#define TF_SENTFIN 0x0010 /* have sent FIN */
#define TF_REQ_SCALE 0x0020 /* have/will request window scaling */
#define TF_RCVD_SCALE 0x0040 /* other side has requested scaling */
#define TF_REQ_TSTMP 0x0080 /* have/will request timestamps */
#define TF_RCVD_TSTMP 0x0100 /* a timestamp was received in SYN */
#define TF_SACK_PERMIT 0x0200 /* other side said I could SACK */
#define TF_SIGNATURE 0x0400 /* require TCP MD5 signature */
#define TCPOOB_HAVEDATA 0x01 /* we have TCP OOB data */
#define TCPOOB_HADDATA 0x02 /* we've had some TCP OOB data */
/*
* The smoothed round-trip time and estimated variance
* are stored as fixed point numbers scaled by the values below.
* For convenience, these scales are also used in smoothing the average
* (smoothed = (1/scale)sample + ((scale-1)/scale)smoothed).
* With these scales, srtt has 3 bits to the right of the binary point,
* and thus an "ALPHA" of 0.875. rttvar has 2 bits to the right of the
* binary point, and is smoothed with an ALPHA of 0.75.
*/
#define TCP_RTT_SCALE 8 /* multiplier for srtt; 3 bits frac. */
#define TCP_RTT_SHIFT 3 /* shift for srtt; 3 bits frac. */
#define TCP_RTTVAR_SCALE 4 /* multiplier for rttvar; 2 bits */
#define TCP_RTTVAR_SHIFT 2 /* multiplier for rttvar; 2 bits */
#define TCP_REXMTVAL(tp) \
((((tp)->t_srtt >> TCP_RTT_SHIFT) + (tp)->t_rttvar) >> 2)
/*
* TCP statistics.
* Many of these should be kept per connection,
* but that's inconvenient at the moment.
*/
struct tcpstat {
uint32 tcps_connattempt; /* connections initiated */
uint32 tcps_accepts; /* connections accepted */
uint32 tcps_connects; /* connections established */
uint32 tcps_drops; /* connections dropped */
uint32 tcps_conndrops; /* embryonic connections dropped */
uint32 tcps_closed; /* conn. closed (includes drops) */
uint32 tcps_segstimed; /* segs where we tried to get rtt */
uint32 tcps_rttupdated; /* times we succeeded */
uint32 tcps_delack; /* delayed acks sent */
uint32 tcps_timeoutdrop; /* conn. dropped in rxmt timeout */
uint32 tcps_rexmttimeo; /* retransmit timeouts */
uint32 tcps_persisttimeo; /* persist timeouts */
uint32 tcps_persistdrop; /* connections dropped in persist */
uint32 tcps_keeptimeo; /* keepalive timeouts */
uint32 tcps_keepprobe; /* keepalive probes sent */
uint32 tcps_keepdrops; /* connections dropped in keepalive */
uint32 tcps_sndtotal; /* total packets sent */
uint32 tcps_sndpack; /* data packets sent */
uint64 tcps_sndbyte; /* data bytes sent */
uint32 tcps_sndrexmitpack; /* data packets retransmitted */
uint64 tcps_sndrexmitbyte; /* data bytes retransmitted */
uint64 tcps_sndrexmitfast; /* Fast retransmits */
uint32 tcps_sndacks; /* ack-only packets sent */
uint32 tcps_sndprobe; /* window probes sent */
uint32 tcps_sndurg; /* packets sent with URG only */
uint32 tcps_sndwinup; /* window update-only packets sent */
uint32 tcps_sndctrl; /* control (SYN|FIN|RST) packets sent */
uint32 tcps_rcvtotal; /* total packets received */
uint32 tcps_rcvpack; /* packets received in sequence */
uint64 tcps_rcvbyte; /* bytes received in sequence */
uint32 tcps_rcvbadsum; /* packets received with ccksum errs */
uint32 tcps_rcvbadoff; /* packets received with bad offset */
uint32 tcps_rcvmemdrop; /* packets dropped for lack of memory */
uint32 tcps_rcvnosec; /* packets dropped for lack of ipsec */
uint32 tcps_rcvshort; /* packets received too short */
uint32 tcps_rcvduppack; /* duplicate-only packets received */
uint64 tcps_rcvdupbyte; /* duplicate-only bytes received */
uint32 tcps_rcvpartduppack; /* packets with some duplicate data */
uint64 tcps_rcvpartdupbyte; /* dup. bytes in part-dup. packets */
uint32 tcps_rcvoopack; /* out-of-order packets received */
uint64 tcps_rcvoobyte; /* out-of-order bytes received */
uint32 tcps_rcvpackafterwin; /* packets with data after window */
uint64 tcps_rcvbyteafterwin; /* bytes rcvd after window */
uint32 tcps_rcvafterclose; /* packets rcvd after "close" */
uint32 tcps_rcvwinprobe; /* rcvd window probe packets */
uint32 tcps_rcvdupack; /* rcvd duplicate acks */
uint32 tcps_rcvacktoomuch; /* rcvd acks for unsent data */
uint32 tcps_rcvackpack; /* rcvd ack packets */
uint64 tcps_rcvackbyte; /* bytes acked by rcvd acks */
uint32 tcps_rcvwinupd; /* rcvd window update packets */
uint32 tcps_pawsdrop; /* segments dropped due to PAWS */
uint32 tcps_predack; /* times hdr predict ok for acks */
uint32 tcps_preddat; /* times hdr predict ok for data pkts */
uint32 tcps_pcbhashmiss; /* input packets missing pcb hash */
uint32 tcps_noport; /* no socket on port */
uint32 tcps_badsyn; /* SYN packet with src==dst rcv'ed */
uint32 tcps_rcvbadsig; /* rcvd bad/missing TCP signatures */
uint64 tcps_rcvgoodsig; /* rcvd good TCP signatures */
uint32 tcps_inhwcsum; /* input hardware-checksummed packets */
uint32 tcps_outhwcsum; /* output hardware-checksummed packets */
};
/*
* Names for TCP sysctl objects.
*/
#define TCPCTL_RFC1323 1 /* enable/disable RFC1323 timestamps/scaling */
#define TCPCTL_KEEPINITTIME 2 /* TCPT_KEEP value */
#define TCPCTL_KEEPIDLE 3 /* allow tcp_keepidle to be changed */
#define TCPCTL_KEEPINTVL 4 /* allow tcp_keepintvl to be changed */
#define TCPCTL_SLOWHZ 5 /* return kernel idea of PR_SLOWHZ */
#define TCPCTL_BADDYNAMIC 6 /* return bad dynamic port bitmap */
#define TCPCTL_RECVSPACE 7 /* receive buffer space */
#define TCPCTL_SENDSPACE 8 /* send buffer space */
#define TCPCTL_IDENT 9 /* get connection owner */
#define TCPCTL_SACK 10 /* selective acknowledgement, rfc 2018 */
#define TCPCTL_MSSDFLT 11 /* Default maximum segment size */
#define TCPCTL_RSTPPSLIMIT 12 /* RST pps limit */
#define TCPCTL_MAXID 13
//#ifdef _NETWORK_STACK
extern struct inpcb tcb;
extern struct tcpstat tcpstat;
extern int tcp_mssdflt;
extern int tcp_do_rfc1323;
extern unsigned long tcp_now;
void tcp_input(struct mbuf *, int);
int tcp_output(struct tcpcb*);
int tcp_mss(struct tcpcb *, uint);
void tcp_mss_update(struct tcpcb *);
void tcp_quench(struct inpcb *, int);
int tcp_userreq(struct socket *, int, struct mbuf *, struct mbuf *,
struct mbuf *);
struct tcpcb * tcp_timers(struct tcpcb *, int);
struct tcpcb *tcp_close(struct tcpcb *);
void tcp_setpersist(struct tcpcb *);
struct tcpcb *tcp_drop(struct tcpcb *, int);
void tcp_respond(struct tcpcb *, struct tcpiphdr *, struct mbuf *,
tcp_seq, tcp_seq, int);
void tcp_xmit_timer(struct tcpcb *, int16);
void tcp_dooptions(struct tcpcb *, u_char *, int, struct tcpiphdr *,
int *, uint32 *, uint32 *);
struct tcpiphdr *tcp_template(struct tcpcb *);
void tcp_pulloutofband(struct socket *, struct tcpiphdr *, struct mbuf *);
void tcp_canceltimers(struct tcpcb *);
void tcp_trace(int16, int16, struct tcpcb *, void *, int, int);
void tcp_slowtimer(void *data);
void tcp_fasttimer(void *data);
//#endif
#endif /* NETINET_TCP_VAR_H */
-66
View File
@@ -1,66 +0,0 @@
/*
* Copyright (c) 1982, 1986, 1993
*The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
*
* This product includes software developed by the University of
* California, Berkeley and its contributors.
*
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#ifndef NETINET_TCPIP_H
#define NETINET_TCPIP_H
/* The TCP + IPv4 header (NB no options) */
struct tcpiphdr {
struct ipovly ti_i;
struct tcphdr ti_t;
};
#define ti_next ti_i.ih_next
#define ti_prev ti_i.ih_prev
#define ti_x1 ti_i.ih_x1
#define ti_pr ti_i.ih_pr
#define ti_len ti_i.ih_len
#define ti_src ti_i.ih_src
#define ti_dst ti_i.ih_dst
#define ti_sport ti_t.th_sport
#define ti_dport ti_t.th_dport
#define ti_seq ti_t.th_seq
#define ti_ack ti_t.th_ack
#define ti_x2 ti_t.th_x2
#define ti_off ti_t.th_off
#define ti_flags ti_t.th_flags
#define ti_win ti_t.th_win
#define ti_sum ti_t.th_sum
#define ti_urp ti_t.th_urp
#define REASS_MBUF(ti) (*(struct mbuf **)&((ti)->ti_t))
#endif /* NETINET_TCPIP_H */
-51
View File
@@ -1,51 +0,0 @@
/* udp_var.h */
#ifndef UDP_VAR_H
#define UDP_VAR_H
#include "netinet/ip_var.h"
struct udpiphdr {
struct ipovly ui_i;
struct udphdr ui_u;
};
#define ui_next ui_i.ih_next
#define ui_prev ui_i.ih_prev
#define ui_x1 ui_i.ih_x1 /* NB _x1 (one) */
#define ui_pr ui_i.ih_pr
#define ui_len ui_i.ih_len
#define ui_src ui_i.ih_src
#define ui_dst ui_i.ih_dst
#define ui_sport ui_u.uh_sport
#define ui_dport ui_u.uh_dport
#define ui_ulen ui_u.uh_ulen
#define ui_sum ui_u.uh_sum
struct udpstat {
/* input statistics: */
uint32 udps_ipackets; /* total input packets */
uint32 udps_hdrops; /* packet shorter than header */
uint32 udps_badsum; /* checksum error */
uint32 udps_nosum; /* no checksum */
uint32 udps_badlen; /* data length larger than packet */
uint32 udps_noport; /* no socket on port */
uint32 udps_noportbcast; /* of above, arrived as broadcast */
uint32 udps_nosec; /* dropped for lack of ipsec */
uint32 udps_fullsock; /* not delivered, input socket full */
uint32 udps_pcbhashmiss; /* input packets missing pcb hash */
uint32 udps_inhwcsum; /* input hardware-csummed packets */
/* output statistics: */
uint32 udps_opackets; /* total output packets */
uint32 udps_outhwcsum; /* output hardware-csummed packets */
};
/*
* Names for UDP sysctl objects
*/
#define UDPCTL_CHECKSUM 1 /* checksum UDP packets */
#define UDPCTL_BADDYNAMIC 2 /* return bad dynamic port bitmap */
#define UDPCTL_RECVSPACE 3 /* receive buffer space */
#define UDPCTL_SENDSPACE 4 /* send buffer space */
#define UDPCTL_MAXID 5
#endif