diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1997-01-07 02:33:00 +0000 |
---|---|---|
committer | <ralf@linux-mips.org> | 1997-01-07 02:33:00 +0000 |
commit | beb116954b9b7f3bb56412b2494b562f02b864b1 (patch) | |
tree | 120e997879884e1b9d93b265221b939d2ef1ade1 /include/net | |
parent | 908d4681a1dc3792ecafbe64265783a86c4cccb6 (diff) |
Import of Linux/MIPS 2.1.14
Diffstat (limited to 'include/net')
49 files changed, 3747 insertions, 1052 deletions
diff --git a/include/net/addrconf.h b/include/net/addrconf.h new file mode 100644 index 000000000..03f9982bd --- /dev/null +++ b/include/net/addrconf.h @@ -0,0 +1,136 @@ +#ifndef _ADDRCONF_H +#define _ADDRCONF_H + +#define RETRANS_TIMER HZ + +#define MAX_RTR_SOLICITATIONS 3 +#define RTR_SOLICITATION_INTERVAL (4*HZ) + +#define ADDR_CHECK_FREQUENCY (120*HZ) + +struct prefix_info { + __u8 type; + __u8 length; + __u8 prefix_len; + +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 onlink : 1, + autoconf : 1, + reserved : 6; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 reserved : 6, + autoconf : 1, + onlink : 1; +#else +#error "Please fix <asm/byteorder.h>" +#endif + __u32 valid; + __u32 prefered; + __u32 reserved2; + + struct in6_addr prefix; +}; + + +#ifdef __KERNEL__ + +#include <linux/in6.h> +#include <linux/netdevice.h> +#include <net/if_inet6.h> + +extern struct inet6_ifaddr *inet6_addr_lst[16]; +extern struct ipv6_mc_list *inet6_mcast_lst[16]; +extern struct inet6_dev *inet6_dev_lst; + +extern void addrconf_init(void); +extern void addrconf_cleanup(void); + +extern int addrconf_notify(struct notifier_block *this, + unsigned long event, + void * data); + +extern int addrconf_add_ifaddr(void *arg); +extern int addrconf_set_dstaddr(void *arg); +extern int addrconf_get_ifindex(void *arg); + +extern struct inet6_ifaddr * ipv6_chk_addr(struct in6_addr *addr); +extern struct inet6_ifaddr * ipv6_get_saddr(struct rt6_info *rt, + struct in6_addr *daddr); +extern struct inet6_ifaddr * ipv6_get_lladdr(struct device *dev); + +/* + * multicast prototypes (mcast.c) + */ +extern int ipv6_sock_mc_join(struct sock *sk, + struct device *dev, + struct in6_addr *addr); +extern int ipv6_sock_mc_drop(struct sock *sk, + struct device *dev, + struct in6_addr *addr); +extern void ipv6_sock_mc_close(struct sock *sk); + +extern int ipv6_dev_mc_inc(struct device *dev, + struct in6_addr *addr); +extern int ipv6_dev_mc_dec(struct device *dev, + struct in6_addr *addr); + +extern int ipv6_chk_mcast_addr(struct device *dev, + struct in6_addr *addr); + +extern void addrconf_prefix_rcv(struct device *dev, + u8 *opt, int len); + +extern struct inet6_dev * ipv6_dev_by_index(int index); +extern struct inet6_dev * ipv6_get_idev(struct device *dev); + +extern void addrconf_forwarding_on(void); +/* + * Hash function taken from net_alias.c + */ + +static __inline__ u8 ipv6_addr_hash(struct in6_addr *addr) +{ + __u32 word; + unsigned tmp; + + /* + * We perform the hash function over the last 64 bits of the address + * This will include the IEEE address token on links that support it. + */ + + word = addr->s6_addr[2] ^ addr->s6_addr32[3]; + tmp = word ^ (word>>16); + tmp ^= (tmp >> 8); + + return ((tmp ^ (tmp >> 4)) & 0x0f); +} + +/* + * compute link-local solicited-node multicast address + */ + +static __inline__ void addrconf_addr_solict_mult(struct in6_addr *addr, + struct in6_addr *solicited) +{ + ipv6_addr_set(solicited, + __constant_htonl(0xFF020000), 0, + __constant_htonl(0x1), addr->s6_addr32[3]); +} + +static __inline__ void ipv6_addr_all_nodes(struct in6_addr *addr) +{ + ipv6_addr_set(addr, + __constant_htonl(0xFF020000), 0, 0, + __constant_htonl(0x1)); +} + +static __inline__ void ipv6_addr_all_routers(struct in6_addr *addr) +{ + ipv6_addr_set(addr, + __constant_htonl(0xFF020000), 0, 0, + __constant_htonl(0x2)); +} + + +#endif +#endif diff --git a/include/net/af_unix.h b/include/net/af_unix.h new file mode 100644 index 000000000..86b0e1ea1 --- /dev/null +++ b/include/net/af_unix.h @@ -0,0 +1,14 @@ +#ifndef __LINUX_NET_AFUNIX_H +#define __LINUX_NET_AFUNIX_H +extern void unix_proto_init(struct net_proto *pro); +extern struct proto_ops unix_proto_ops; +extern void unix_inflight(struct file *fp); +extern void unix_notinflight(struct file *fp); +typedef struct sock unix_socket; +extern void unix_gc(void); + +extern unix_socket *unix_socket_list; + +#define UNIX_MAX_FD 8 + +#endif diff --git a/include/net/arp.h b/include/net/arp.h index e8fa572ea..db7a29c36 100644 --- a/include/net/arp.h +++ b/include/net/arp.h @@ -3,18 +3,15 @@ #define _ARP_H extern void arp_init(void); -extern void arp_destroy(unsigned long paddr, int force); -extern void arp_device_down(struct device *dev); extern int arp_rcv(struct sk_buff *skb, struct device *dev, struct packet_type *pt); -extern int arp_find(unsigned char *haddr, unsigned long paddr, - struct device *dev, unsigned long saddr, struct sk_buff *skb); -extern int arp_get_info(char *buffer, char **start, off_t origin, int length); +extern int arp_query(unsigned char *haddr, u32 paddr, struct device *dev); +extern int arp_find(unsigned char *haddr, u32 paddr, + struct device *dev, u32 saddr, struct sk_buff *skb); extern int arp_ioctl(unsigned int cmd, void *arg); -extern void arp_send(int type, int ptype, unsigned long dest_ip, - struct device *dev, unsigned long src_ip, - unsigned char *dest_hw, unsigned char *src_hw); -extern int arp_find_cache(unsigned char *dp, unsigned long daddr, struct device *dev); - -extern unsigned long arp_cache_stamp; +extern void arp_send(int type, int ptype, u32 dest_ip, + struct device *dev, u32 src_ip, + unsigned char *dest_hw, unsigned char *src_hw, unsigned char *th); +extern int arp_bind_cache(struct hh_cache ** hhp, struct device *dev, unsigned short type, __u32 daddr); +extern int arp_update_cache(struct hh_cache * hh); #endif /* _ARP_H */ diff --git a/include/net/atalk.h b/include/net/atalk.h deleted file mode 100644 index 08760cdac..000000000 --- a/include/net/atalk.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Appletalk networking structures - * - * The following are directly referenced from the University Of Michigan - * netatalk for compatibility reasons. - */ - -#ifndef __LINUX_ATALK_H__ -#define __LINUX_ATALK_H__ - -#define ATPORT_FIRST 1 -#define ATPORT_RESERVED 128 -#define ATPORT_LAST 255 -#define ATADDR_ANYNET (__u16)0 -#define ATADDR_ANYNODE (__u8)0 -#define ATADDR_ANYPORT (__u8)0 -#define ATADDR_BCAST (__u8)255 -#define DDP_MAXSZ 587 - -struct at_addr -{ - __u16 s_net; - __u8 s_node; -}; - -struct sockaddr_at -{ - short sat_family; - __u8 sat_port; - struct at_addr sat_addr; - char sat_zero[ 8 ]; -}; - -struct netrange -{ - __u8 nr_phase; - __u16 nr_firstnet; - __u16 nr_lastnet; -}; - -struct atalk_route -{ - struct device *dev; - struct at_addr target; - struct at_addr gateway; - int flags; - struct atalk_route *next; -}; - -struct atalk_iface -{ - struct device *dev; - struct at_addr address; /* Our address */ - int status; /* What are we doing ?? */ -#define ATIF_PROBE 1 /* Probing for an address */ -#define ATIF_PROBE_FAIL 2 /* Probe collided */ - struct netrange nets; /* Associated direct netrange */ - struct atalk_iface *next; -}; - -struct atalk_sock -{ - unsigned short dest_net; - unsigned short src_net; - unsigned char dest_node; - unsigned char src_node; - unsigned char dest_port; - unsigned char src_port; -}; - -#define DDP_MAXHOPS 15 /* 4 bits of hop counter */ - -#ifdef __KERNEL__ - -struct ddpehdr -{ - /* FIXME for bigendians */ - /*__u16 deh_pad:2,deh_hops:4,deh_len:10;*/ - __u16 deh_len:10,deh_hops:4,deh_pad:2; - __u16 deh_sum; - __u16 deh_dnet; - __u16 deh_snet; - __u8 deh_dnode; - __u8 deh_snode; - __u8 deh_dport; - __u8 deh_sport; - /* And netatalk apps expect to stick the type in themselves */ -}; - -/* - * Unused (and currently unsupported) - */ - -struct ddpshdr -{ - /* FIXME for bigendians */ - __u8 dsh_sport; - __u8 dsh_dport; - __u16 dsh_len:10, dsh_pad:6; - /* And netatalk apps expect to stick the type in themselves */ -}; - -/* Appletalk AARP headers */ - -struct elapaarp -{ - __u16 hw_type; -#define AARP_HW_TYPE_ETHERNET 1 -#define AARP_HW_TYPE_TOKENRING 2 - __u16 pa_type; - __u8 hw_len; - __u8 pa_len; -#define AARP_PA_ALEN 4 - __u16 function; -#define AARP_REQUEST 1 -#define AARP_REPLY 2 -#define AARP_PROBE 3 - __u8 hw_src[ETH_ALEN] __attribute__ ((packed)); - __u8 pa_src_zero __attribute__ ((packed)); - __u16 pa_src_net __attribute__ ((packed)); - __u8 pa_src_node __attribute__ ((packed)); - __u8 hw_dst[ETH_ALEN] __attribute__ ((packed)); - __u8 pa_dst_zero __attribute__ ((packed)); - __u16 pa_dst_net __attribute__ ((packed)); - __u8 pa_dst_node __attribute__ ((packed)); -}; - -typedef struct sock atalk_socket; - -#define AARP_EXPIRY_TIME (5*60*HZ) /* Not specified - how long till we drop a resolved entry */ -#define AARP_HASH_SIZE 16 /* Size of hash table */ -#define AARP_TICK_TIME (HZ/5) /* Fast retransmission timer when resolving */ -#define AARP_RETRANSMIT_LIMIT 10 /* Send 10 requests then give up (2 seconds) */ -#define AARP_RESOLVE_TIME (10*HZ) /* Some value bigger than total retransmit time + a bit for last reply to appear and to stop continual requests */ - -extern struct datalink_proto *ddp_dl, *aarp_dl; -extern void aarp_proto_init(void); -/* Inter module exports */ -extern struct atalk_iface *atalk_find_dev(struct device *dev); -extern struct at_addr *atalk_find_dev_addr(struct device *dev); -extern int aarp_send_ddp(struct device *dev,struct sk_buff *skb, struct at_addr *sa, void *hwaddr); -extern void aarp_send_probe(struct device *dev, struct at_addr *addr); -#endif -#endif diff --git a/include/net/ax25.h b/include/net/ax25.h index 4195c1246..43cedaafb 100644 --- a/include/net/ax25.h +++ b/include/net/ax25.h @@ -7,17 +7,39 @@ #ifndef _AX25_H #define _AX25_H #include <linux/ax25.h> + +#define PR_SLOWHZ 10 /* Run timing at 1/10 second - gives us better resolution for 56kbit links */ + +#define AX25_T1CLAMPLO (1 * PR_SLOWHZ) /* If defined, clamp at 1 second **/ +#define AX25_T1CLAMPHI (30 * PR_SLOWHZ) /* If defined, clamp at 30 seconds **/ + +#define AX25_BROKEN_NETMAC + +#define AX25_BPQ_HEADER_LEN 16 +#define AX25_KISS_HEADER_LEN 1 + +#define AX25_HEADER_LEN 17 +#define AX25_ADDR_LEN 7 +#define AX25_DIGI_HEADER_LEN (AX25_MAX_DIGIS * AX25_ADDR_LEN) +#define AX25_MAX_HEADER_LEN (AX25_HEADER_LEN + AX25_DIGI_HEADER_LEN) +#define AX25_P_ROSE 0x01 #define AX25_P_IP 0xCC #define AX25_P_ARP 0xCD #define AX25_P_TEXT 0xF0 #define AX25_P_NETROM 0xCF +#define AX25_P_SEGMENT 0x08 + +#define SEG_REM 0x7F +#define SEG_FIRST 0x80 -#define LAPB_UI 0x03 -#define LAPB_C 0x80 -#define LAPB_E 0x01 +#define LAPB_UI 0x03 +#define LAPB_C 0x80 +#define LAPB_E 0x01 -#define SSID_SPARE 0x60 /* Unused bits (DAMA bit and spare must be 1) */ +#define SSSID_SPARE 0x60 /* Unused bits in SSID for standard AX.25 */ +#define ESSID_SPARE 0x20 /* Unused bits in SSID for extended AX.25 */ +#define DAMA_FLAG 0x20 /* Well, it is *NOT* unused! (dl1bke 951121 */ #define AX25_REPEATED 0x80 @@ -67,11 +89,13 @@ #define UA 0x63 /* Unnumbered acknowledge */ #define FRMR 0x87 /* Frame reject */ #define UI 0x03 /* Unnumbered information */ -#define PF 0x10 /* Poll/final bit */ +#define PF 0x10 /* Poll/final bit for standard AX.25 */ +#define EPF 0x01 /* Poll/final bit for extended AX.25 */ #define ILLEGAL 0x100 /* Impossible to be a real frame type */ -#define MMASK 7 /* Mask for modulo-8 sequence numbers */ +#define POLLOFF 0 +#define POLLON 1 /* AX25 L2 C-bit */ @@ -86,14 +110,46 @@ #define AX25_STATE_3 3 #define AX25_STATE_4 4 -#define PR_SLOWHZ 10 /* Run timing at 1/10 second - gives us better resolution for 56kbit links */ -#define DEFAULT_T1 (10 * PR_SLOWHZ) /* Outstanding frames - 10 seconds */ -#define DEFAULT_T2 (3 * PR_SLOWHZ) /* Response delay - 3 seconds */ -#define DEFAULT_T3 (300 * PR_SLOWHZ) /* Idle supervision - 300 seconds */ -#define DEFAULT_N2 10 /* Number of retries */ -#define DEFAULT_WINDOW 2 /* Default window size */ -#define MODULUS 8 -#define MAX_WINDOW_SIZE 7 /* Maximum window allowable */ +#define AX25_MAX_DEVICES 20 /* Max No of AX.25 devices */ + +#define MODULUS 8 /* Standard AX.25 modulus */ +#define EMODULUS 128 /* Extended AX.25 modulus */ + +#define AX25_DIGI_INBAND 0x01 /* Allow digipeating within port **/ +#define AX25_DIGI_XBAND 0x02 /* Allow digipeating across ports **/ + +#define AX25_VALUES_IPDEFMODE 0 /* 0=DG 1=VC */ +#define AX25_VALUES_AXDEFMODE 1 /* 0=Normal 1=Extended Seq Nos */ +#define AX25_VALUES_TEXT 2 /* Allow PID=Text - 0=No 1=Yes */ +#define AX25_VALUES_BACKOFF 3 /* 0=Linear 1=Exponential */ +#define AX25_VALUES_CONMODE 4 /* Allow connected modes - 0=No 1=Yes */ +#define AX25_VALUES_WINDOW 5 /* Default window size for standard AX.25 */ +#define AX25_VALUES_EWINDOW 6 /* Default window size for extended AX.25 */ +#define AX25_VALUES_T1 7 /* Default T1 timeout value */ +#define AX25_VALUES_T2 8 /* Default T2 timeout value */ +#define AX25_VALUES_T3 9 /* Default T3 timeout value */ +#define AX25_VALUES_IDLE 10 /* mode vc idle timer */ +#define AX25_VALUES_N2 11 /* Default N2 value */ +#define AX25_VALUES_PACLEN 12 /* AX.25 MTU */ +#define AX25_VALUES_MAXQUEUE 13 /* Maximum number of buffers enqueued */ +#define AX25_VALUES_DIGI 14 /* Digipeat mode */ +#define AX25_MAX_VALUES 15 + +#define AX25_DEF_IPDEFMODE 0 /* Datagram */ +#define AX25_DEF_AXDEFMODE 0 /* Normal */ +#define AX25_DEF_TEXT 1 /* PID=Text allowed */ +#define AX25_DEF_BACKOFF 1 /* Exponential backoff */ +#define AX25_DEF_CONMODE 1 /* Connected mode allowed */ +#define AX25_DEF_WINDOW 2 /* Window=2 */ +#define AX25_DEF_EWINDOW 32 /* Module-128 Window=32 */ +#define AX25_DEF_T1 (10 * PR_SLOWHZ) /* T1=10s */ +#define AX25_DEF_T2 (3 * PR_SLOWHZ) /* T2=3s */ +#define AX25_DEF_T3 (300 * PR_SLOWHZ) /* T3=300s */ +#define AX25_DEF_N2 10 /* N2=10 */ +#define AX25_DEF_IDLE (20 * 60 * PR_SLOWHZ) /* Idle=20 mins */ +#define AX25_DEF_PACLEN 256 /* Paclen=256 */ +#define AX25_DEF_MAXQUEUE 2 /* 1 * ax25->window */ +#define AX25_DEF_DIGI 0x03 /* All digis alowed */ typedef struct ax25_uid_assoc { struct ax25_uid_assoc *next; @@ -102,8 +158,8 @@ typedef struct ax25_uid_assoc { } ax25_uid_assoc; typedef struct { - ax25_address calls[6]; - unsigned char repeated[6]; + ax25_address calls[AX25_MAX_DIGIS]; + unsigned char repeated[AX25_MAX_DIGIS]; unsigned char ndigi; char lastrepeat; } ax25_digi; @@ -112,77 +168,126 @@ typedef struct ax25_cb { struct ax25_cb *next; ax25_address source_addr, dest_addr; struct device *device; - unsigned char state; + unsigned char dama_slave; /* dl1bke 951121 */ + unsigned char state, modulus, hdrincl; unsigned short vs, vr, va; - unsigned char condition; + unsigned char condition, backoff; unsigned char n2, n2count; - unsigned short t1, t2, t3, rtt; - unsigned short t1timer, t2timer, t3timer; + unsigned short t1, t2, t3, idle, rtt; + unsigned short t1timer, t2timer, t3timer, idletimer; + unsigned short paclen; + unsigned short maxqueue; + unsigned short fragno, fraglen; ax25_digi *digipeat; struct sk_buff_head write_queue; + struct sk_buff_head reseq_queue; struct sk_buff_head ack_queue; + struct sk_buff_head frag_queue; unsigned char window; struct timer_list timer; struct sock *sk; /* Backlink to socket */ } ax25_cb; -/* ax25.c */ +struct ax25_dev { + char name[20]; + struct device *dev; + int values[AX25_MAX_VALUES]; +}; + +/* af_ax25.c */ +extern ax25_address null_ax25_address; extern char *ax2asc(ax25_address *); +extern ax25_address *asc2ax(char *); extern int ax25cmp(ax25_address *, ax25_address *); -extern int ax25_send_frame(struct sk_buff *, ax25_address *, ax25_address *, struct device *); -extern int ax25_rcv(struct sk_buff *,struct device *,struct packet_type *); +extern int ax25_send_frame(struct sk_buff *, ax25_address *, ax25_address *, ax25_digi *, struct device *); +extern int ax25_link_up(ax25_address *, ax25_address *, struct device *); extern void ax25_destroy_socket(ax25_cb *); extern struct device *ax25rtr_get_dev(ax25_address *); -extern int ax25_encapsulate(unsigned char *, struct device *, unsigned short, - void *, void *, unsigned int, struct sk_buff *); +extern int ax25_encapsulate(struct sk_buff *, struct device *, unsigned short, + void *, void *, unsigned int); extern int ax25_rebuild_header(unsigned char *, struct device *, unsigned long, struct sk_buff *); -extern int ax25_get_info(char *, char **, off_t, int); extern ax25_uid_assoc *ax25_uid_list; extern int ax25_uid_policy; extern ax25_address *ax25_findbyuid(uid_t); +extern void ax25_queue_xmit(struct sk_buff *, struct device *, int); +extern int ax25_dev_is_dama_slave(struct device *); /* dl1bke 951121 */ -#include "ax25call.h" +#include <net/ax25call.h> /* ax25_in.c */ -extern int ax25_process_rx_frame(ax25_cb *, struct sk_buff *, int); +extern int ax25_process_rx_frame(ax25_cb *, struct sk_buff *, int, int); /* ax25_out.c */ -extern int ax25_output(ax25_cb *, struct sk_buff *); +extern void ax25_output(ax25_cb *, struct sk_buff *); extern void ax25_kick(ax25_cb *); extern void ax25_transmit_buffer(ax25_cb *, struct sk_buff *, int); extern void ax25_nr_error_recovery(ax25_cb *); extern void ax25_establish_data_link(ax25_cb *); extern void ax25_transmit_enquiry(ax25_cb *); extern void ax25_enquiry_response(ax25_cb *); +extern void ax25_timeout_response(ax25_cb *); extern void ax25_check_iframes_acked(ax25_cb *, unsigned short); extern void ax25_check_need_response(ax25_cb *, int, int); +extern void dama_enquiry_response(ax25_cb *); /* dl1bke 960114 */ +extern void dama_check_need_response(ax25_cb *, int, int); /* dl1bke 960114 */ +extern void dama_establish_data_link(ax25_cb *); /* ax25_route.c */ -extern void ax25_rt_rx_frame(ax25_address *, struct device *); -extern int ax25_rt_get_info(char *, char **, off_t, int); -extern int ax25_cs_get_info(char *, char **, off_t, int); +extern struct ax25_dev ax25_device[]; +extern int ax25_rt_get_info(char *, char **, off_t, int, int); +extern int ax25_cs_get_info(char *, char **, off_t, int, int); extern int ax25_rt_autobind(ax25_cb *, ax25_address *); +extern void ax25_rt_build_path(ax25_cb *, ax25_address *, struct device *); +extern void ax25_dg_build_path(struct sk_buff *, ax25_address *, struct device *); extern void ax25_rt_device_down(struct device *); -extern void ax25_ip_mode_set(ax25_address *, struct device *, char); +extern int ax25_rt_ioctl(unsigned int, void *); extern char ax25_ip_mode_get(ax25_address *, struct device *); +extern int ax25_dev_get_value(struct device *, int); +extern void ax25_dev_device_up(struct device *); +extern void ax25_dev_device_down(struct device *); +extern void ax25_rt_free(void); /* ax25_subr.c */ -extern void ax25_clear_tx_queue(ax25_cb *); +extern void ax25_clear_queues(ax25_cb *); extern void ax25_frames_acked(ax25_cb *, unsigned short); +extern void ax25_requeue_frames(ax25_cb *); extern int ax25_validate_nr(ax25_cb *, unsigned short); -extern int ax25_decode(unsigned char *); -extern void ax25_send_control(ax25_cb *, int, int); +extern int ax25_decode(ax25_cb *, struct sk_buff *, int *, int *, int *); +extern void ax25_send_control(ax25_cb *, int, int, int); extern unsigned short ax25_calculate_t1(ax25_cb *); extern void ax25_calculate_rtt(ax25_cb *); extern unsigned char *ax25_parse_addr(unsigned char *, int, ax25_address *, - ax25_address *, ax25_digi *, int *); + ax25_address *, ax25_digi *, int *, int *); /* dl1bke 951121 */ extern int build_ax25_addr(unsigned char *, ax25_address *, ax25_address *, - ax25_digi *, int); + ax25_digi *, int, int); extern int size_ax25_addr(ax25_digi *); extern void ax25_digi_invert(ax25_digi *, ax25_digi *); extern void ax25_return_dm(struct device *, ax25_address *, ax25_address *, ax25_digi *); +extern int ax25_queue_length(ax25_cb *, struct sk_buff *); /* dl1bke 960327 */ +extern void ax25_dama_on(ax25_cb *); /* dl1bke 951121 */ +extern void ax25_dama_off(ax25_cb *); /* dl1bke 951121 */ -/* ax25_timer */ +/* ax25_timer.c */ extern void ax25_set_timer(ax25_cb *); +extern void ax25_t1_timeout(ax25_cb *); +extern void ax25_link_failed(ax25_address *, struct device *); +extern int (*ax25_protocol_function(unsigned int))(struct sk_buff *, ax25_cb *); +extern int ax25_listen_mine(ax25_address *, struct device *); + +/* sysctl_net_ax25.c */ +extern void ax25_register_sysctl(void); +extern void ax25_unregister_sysctl(void); + +/* ... */ + +extern ax25_cb *volatile ax25_list; + +/* support routines for modules that use AX.25, in ax25_timer.c */ +extern int ax25_protocol_register(unsigned int, int (*)(struct sk_buff *, ax25_cb *)); +extern void ax25_protocol_release(unsigned int); +extern int ax25_linkfail_register(void (*)(ax25_address *, struct device *)); +extern void ax25_linkfail_release(void (*)(ax25_address *, struct device *)); +extern int ax25_listen_register(ax25_address *, struct device *); +extern void ax25_listen_release(ax25_address *, struct device *); #endif diff --git a/include/net/ax25call.h b/include/net/ax25call.h index 89569656b..68b8a70c0 100644 --- a/include/net/ax25call.h +++ b/include/net/ax25call.h @@ -1,2 +1,2 @@ -/* Seperate to keep compilation of protocols.c simpler */ +/* Separate to keep compilation of protocols.c simpler */ extern void ax25_proto_init(struct net_proto *pro); diff --git a/include/net/br.h b/include/net/br.h new file mode 100644 index 000000000..a1d3fa309 --- /dev/null +++ b/include/net/br.h @@ -0,0 +1,291 @@ +/* + * Constants and structure definitions for the bridging code + */ + +#if !defined(One) +#define Zero 0 +#define One 1 +#endif /* !defined(One) */ + +#if !defined(TRUE) +#define FALSE 0 +#define TRUE 1 +#endif /* !defined(TRUE) */ + +/** port states. **/ +#define Disabled 0 /* (4.4 5) */ +#define Listening 1 /* (4.4.2) */ +#define Learning 2 /* (4.4.3) */ +#define Forwarding 3 /* (4 4 4) */ +#define Blocking 4 /* (4.4.1) */ + +#define No_of_ports 8 +/* arbitrary choice, to allow the code below to compile */ + +#define All_ports (No_of_ports + 1) + +/* + * We time out our entries in the FDB after this many seconds. + */ +#define FDB_TIMEOUT 300 + +/* + * the following defines are the initial values used when the + * bridge is booted. These may be overridden when this bridge is + * not the root bridge. These are the recommended default values + * from the 802.1d specification. + */ +#define BRIDGE_MAX_AGE 20 +#define BRIDGE_HELLO_TIME 2 +#define BRIDGE_FORWARD_DELAY 15 +#define HOLD_TIME 1 + +#define Default_path_cost 10 + +/* + * minimum increment possible to avoid underestimating age, allows for BPDU + * transmission time + */ +#define Message_age_increment 1 + +#define No_port 0 +/* + * reserved value for Bridge's root port parameter indicating no root port, + * used when Bridge is the root - also used to indicate the source when + * a frame is being generated by a higher layer protocol on this host + */ + +/** Configuration BPDU Parameters (4.5.1) **/ + +typedef struct { + union { + struct { + unsigned short priority; + unsigned char ula[6]; + } p_u; + unsigned int id[2]; + } bi; +} bridge_id_t; + +#define BRIDGE_PRIORITY bi.p_u.priority +#define BRIDGE_ID_ULA bi.p_u.ula +#define BRIDGE_ID bi.id + +typedef struct { + unsigned short protocol_id; + unsigned char protocol_version_id; + unsigned char type; + unsigned char flags; +#define TOPOLOGY_CHANGE 0x01 +#define TOPOLOGY_CHANGE_ACK 0x80 + bridge_id_t root_id; /* (4.5.1.1) */ + unsigned int root_path_cost; /* (4.5.1.2) */ + bridge_id_t bridge_id; /* (4.5.1.3) */ + unsigned short port_id; /* (4.5.1.4) */ + unsigned short message_age; /* (4.5.1.5) */ + unsigned short max_age; /* (4.5.1.6) */ + unsigned short hello_time; /* (4.5.1.7) */ + unsigned short forward_delay; /* (4.5.1.8) */ +} Config_bpdu; + + +/** Topology Change Notification BPDU Parameters (4.5.2) **/ + +typedef struct { + unsigned short protocol_id; + unsigned char protocol_version_id; + unsigned char type; +} Tcn_bpdu; + +#define BPDU_TYPE_CONFIG 0 +#define BPDU_TYPE_TOPO_CHANGE 128 + +/** Bridge Parameters (4.5.3) **/ +typedef struct { + bridge_id_t designated_root; /* (4.5.3.1) */ + unsigned int root_path_cost; /* (4.5.3.2) */ + unsigned int root_port; /* (4.5.3.3) */ + unsigned short max_age; /* (4.5.3.4) */ + unsigned short hello_time; /* (4.5.3.5) */ + unsigned short forward_delay; /* (4.5.3.6) */ + bridge_id_t bridge_id; /* (4.5.3.7) */ + unsigned short bridge_max_age; /* (4.5.3.8) */ + unsigned short bridge_hello_time; /* (4.5.3.9) */ + unsigned short bridge_forward_delay; /* (4.5.3.10) */ + unsigned int topology_change_detected; /* (4.5.3.11) */ + unsigned int topology_change; /* (4.5.3.12) */ + unsigned short topology_change_time; /* (4.5.3.13) */ + unsigned short hold_time; /* (4.5.3.14) */ + unsigned int top_change; + unsigned int top_change_detected; +} Bridge_data; + +/** Port Parameters (4.5.5) **/ +typedef struct { + unsigned short port_id; /* (4.5.5.1) */ + unsigned int state; /* (4.5.5.2) */ + unsigned int path_cost; /* (4.5.5.3) */ + bridge_id_t designated_root; /* (4.5.5.4) */ + unsigned int designated_cost; /* (4.5.5.5) */ + bridge_id_t designated_bridge; /* (4.5.5.6) */ + unsigned short designated_port; /* (4.5.5.7) */ + unsigned int top_change_ack; /* (4.5.5.8) */ + unsigned int config_pending; /* (4.5.5.9) */ + struct device *dev; + struct fdb *fdb; /* head of per port fdb chain */ +} Port_data; + + + +/** types to support timers for this pseudo-implementation. **/ +typedef struct { + unsigned int active; /* timer in use. */ + unsigned int value; /* current value of timer, + * counting up. */ +} Timer; + +struct fdb { + unsigned char ula[6]; + unsigned char pad[2]; + unsigned short port; + unsigned int timer; + unsigned int flags; +#define FDB_ENT_VALID 0x01 +/* AVL tree of all addresses, sorted by address */ + short fdb_avl_height; + struct fdb *fdb_avl_left; + struct fdb *fdb_avl_right; +/* linked list of addresses for each port */ + struct fdb *fdb_next; +}; + +#define IS_BRIDGED 0x2e + + +#define BR_MAX_PROTOCOLS 32 +#define BR_MAX_PROT_STATS BR_MAX_PROTOCOLS + +/* policy values for policy field */ +#define BR_ACCEPT 1 +#define BR_REJECT 0 + +struct br_stat { + unsigned int flags; + Bridge_data bridge_data; + Port_data port_data[No_of_ports]; + unsigned int policy; + unsigned int exempt_protocols; + unsigned short protocols[BR_MAX_PROTOCOLS]; + unsigned short prot_id[BR_MAX_PROT_STATS]; /* Protocol encountered */ + unsigned int prot_counter[BR_MAX_PROT_STATS]; /* How many packets ? */ +}; + +/* defined flags for br_stat.flags */ +#define BR_UP 0x0001 /* bridging enabled */ +#define BR_DEBUG 0x0002 /* debugging enabled */ +#define BR_PROT_STATS 0x0004 /* protocol statistics enabled */ + +struct br_cf { + unsigned int cmd; + unsigned int arg1; + unsigned int arg2; +}; + +/* defined cmds */ +#define BRCMD_BRIDGE_ENABLE 1 +#define BRCMD_BRIDGE_DISABLE 2 +#define BRCMD_PORT_ENABLE 3 /* arg1 = port */ +#define BRCMD_PORT_DISABLE 4 /* arg1 = port */ +#define BRCMD_SET_BRIDGE_PRIORITY 5 /* arg1 = priority */ +#define BRCMD_SET_PORT_PRIORITY 6 /* arg1 = port, arg2 = priority */ +#define BRCMD_SET_PATH_COST 7 /* arg1 = port, arg2 = cost */ +#define BRCMD_DISPLAY_FDB 8 /* arg1 = port */ +#define BRCMD_ENABLE_DEBUG 9 +#define BRCMD_DISABLE_DEBUG 10 +#define BRCMD_SET_POLICY 11 /* arg1 = default policy (1==bridge all) */ +#define BRCMD_EXEMPT_PROTOCOL 12 /* arg1 = protocol (see net/if_ether.h) */ +#define BRCMD_ENABLE_PROT_STATS 13 +#define BRCMD_DISABLE_PROT_STATS 14 +#define BRCMD_ZERO_PROT_STATS 15 + +/* prototypes of all bridging functions... */ + +void transmit_config(int port_no); +int root_bridge(void); +int supersedes_port_info(int port_no, Config_bpdu *config); +void record_config_information(int port_no, Config_bpdu *config); +void record_config_timeout_values(Config_bpdu *config); +void config_bpdu_generation(void); +int designated_port(int port_no); +void reply(int port_no); +void transmit_tcn(void); +void configuration_update(void); +void root_selection(void); +void designated_port_selection(void); +void become_designated_port(int port_no); +void port_state_selection(void); +void make_forwarding(int port_no); +void topology_change_detection(void); +void topology_change_acknowledged(void); +void acknowledge_topology_change(int port_no); +void make_blocking(int port_no); +void set_port_state(int port_no, int state); +void received_config_bpdu(int port_no, Config_bpdu *config); +void received_tcn_bpdu(int port_no, Tcn_bpdu *tcn); +void hello_timer_expiry(void); +void message_age_timer_expiry(int port_no); +void forward_delay_timer_expiry(int port_no); +int designated_for_some_port(void); +void tcn_timer_expiry(void); +void topology_change_timer_expiry(void); +void hold_timer_expiry(int port_no); +void br_init(void); +void br_init_port(int port_no); +void enable_port(int port_no); +void disable_port(int port_no); +void set_bridge_priority(bridge_id_t *new_bridge_id); +void set_port_priority(int port_no, unsigned short new_port_id); +void set_path_cost(int port_no, unsigned short path_cost); +void start_hello_timer(void); +void stop_hello_timer(void); +int hello_timer_expired(void); +void start_tcn_timer(void); +void stop_tcn_timer(void); +int tcn_timer_expired(void); +void start_topology_change_timer(void); +void stop_topology_change_timer(void); +int topology_change_timer_expired(void); +void start_message_age_timer(int port_no, unsigned short message_age); +void stop_message_age_timer(int port_no); +int message_age_timer_expired(int port_no); +void start_forward_delay_timer(int port_no); +void stop_forward_delay_timer(int port_no); +int forward_delay_timer_expired(int port_no); +void start_hold_timer(int port_no); +void stop_hold_timer(int port_no); +int hold_timer_expired(int port_no); + +struct fdb *br_avl_find_addr(unsigned char addr[6]); +int br_avl_insert (struct fdb * new_node); +int br_avl_remove (struct fdb * node_to_delete); + +int send_tcn_bpdu(int port_no, Tcn_bpdu *bpdu); +int send_config_bpdu(int port_no, Config_bpdu *config_bpdu); +int find_port(struct device *dev); +int br_flood(struct sk_buff *skb, int port); +int br_drop(struct sk_buff *skb); +int br_learn(struct sk_buff *skb, int port); /* 3.8 */ + +int br_receive_frame(struct sk_buff *skb); /* 3.5 */ +int br_tx_frame(struct sk_buff *skb); +int br_ioctl(unsigned int cmd, void *arg); + +int br_protocol_ok(unsigned short protocol); + +void free_fdb(struct fdb *); +struct fdb *get_fdb(void); + +/* externs */ + +extern struct br_stat br_stats; + diff --git a/include/net/checksum.h b/include/net/checksum.h index 7f9492328..2fb596b13 100644 --- a/include/net/checksum.h +++ b/include/net/checksum.h @@ -15,223 +15,78 @@ * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ -#ifndef _CHECKSUM_H -#define _CHECKSUM_H - -#include <asm/byteorder.h> -#include "ip.h" /* - * This is a version of ip_compute_csum() optimized for IP headers, - * which always checksum on 4 octet boundaries. + * Fixes: * - * By Jorge Cwik <jorge@laser.satlink.net>, adapted for linux by - * Arnt Gulbrandsen. + * Ralf Baechle : generic ipv6 checksum + * <ralf@waldorf-gmbh.de> */ -static inline unsigned short ip_fast_csum(unsigned char * iph, - unsigned int ihl) { - unsigned short int sum; - -#ifdef __i386__ - __asm__(" - movl (%%esi), %%eax - andl $15, %%ecx - subl $4, %%ecx - jbe 2f - addl 4(%%esi), %%eax - adcl 8(%%esi), %%eax - adcl 12(%%esi), %%eax -1: adcl 16(%%esi), %%eax - lea 4(%%esi), %%esi - decl %%ecx - jne 1b - adcl $0, %%eax - movl %%eax, %%ecx - shrl $16, %%eax - addw %%ecx, %%eax - adcl $0, %%eax - notl %%eax - andl $65535, %%eax -2: - " - : "=a" (sum) - : "S" (iph), "c"(ihl) - : "ax", "cx", "si"); -#elif defined (__mips__) - unsigned long dummy1, dummy2; - /* - * This is optimized for 32-bit MIPS processors. - * I tried it in plain C but the generated code looks to bad to - * use with old first generation MIPS CPUs. - * Using 64-bit code could even further improve these routines. - */ - __asm__(" - .set noreorder - .set noat - lw %0,(%3) - subu %1,4 - blez %1,2f - sll %1,%4,2 # delay slot - lw %2,4(%3) - addu %1,%3 # delay slot - addu %0,%2 - sltu $1,%0,%2 - lw %2,8(%3) - addu %0,$1 - addu %0,%2 - sltu $1,%0,%2 - lw %2,12(%3) - addu %0,$1 - addu %0,%2 - sltu $1,%0,%2 - addu %0,$1 -1: lw %2,16(%3) - addu %1,4 - addu %0,%2 - sltu $1,%0,%2 - bne %1,%3,1b - addu %0,$1 # delay slot - srl $1,%0,16 - addu %0,$1 - sltu $1,%0,$1 - addu %0,$1 - nor %0,$0,%0 - andi %0,0xffff -2: .set at - .set reorder" - : "=r" (sum), "=r" (dummy1), "=r" (dummy2) - : "r" (iph), "r"(ihl) - : "$1"); -#else -#error Not implemented for this CPU -#endif - return(sum); -} - - +#ifndef _CHECKSUM_H +#define _CHECKSUM_H -/* - * computes the checksum of the TCP/UDP pseudo-header - * returns a 16-bit checksum, already complemented - */ - -static inline unsigned short int csum_tcpudp_magic(unsigned long saddr, - unsigned long daddr, - unsigned short len, - unsigned short proto, - unsigned int sum) { -#ifdef __i386__ - __asm__(" - addl %2, %0 - adcl %3, %0 - adcl %4, %0 - adcl $0, %0 - movl %0, %2 - shrl $16, %2 - addw %2, %0 - adcl $0, %0 - notl %0 - andl $65535, %0 - " - : "=r" (sum) - : "0" (daddr), "S"(saddr), "r"((ntohs(len)<<16)+proto*256), "r"(sum) - : "si" ); -#elif defined (__mips__) - __asm__(" - .set noat - addu %0,%2 - sltu $1,%0,%2 - addu %0,$1 - addu %0,%3 - sltu $1,%0,%3 - addu %0,$1 - addu %0,%4 - sltu $1,%0,%4 - addu %0,$1 - srl $1,%0,16 - addu %0,$1 - sltu $1,%0,$1 - addu %0,$1 - nor %0,$0,%0 - andi %0,0xffff - .set at" - : "=r" (sum) - : "0" (daddr), "r"(saddr), "r"((ntohs(len)<<16)+proto*256), "r"(sum) - : "$1"); -#else -#error Not implemented for this CPU -#endif - return((unsigned short)sum); +#include <asm/byteorder.h> +#include <net/ip.h> +#include <asm/checksum.h> + +#ifndef _HAVE_ARCH_IPV6_CSUM + +static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr, + struct in6_addr *daddr, + __u16 len, + unsigned short proto, + unsigned int csum) +{ + int carry; + __u32 ulen; + __u32 uproto; + + csum += saddr->s6_addr32[0]; + carry = (csum < saddr->s6_addr32[0]); + csum += carry; + + csum += saddr->s6_addr32[1]; + carry = (csum < saddr->s6_addr32[1]); + csum += carry; + + csum += saddr->s6_addr32[2]; + carry = (csum < saddr->s6_addr32[2]); + csum += carry; + + csum += saddr->s6_addr32[3]; + carry = (csum < saddr->s6_addr32[3]); + csum += carry; + + csum += daddr->s6_addr32[0]; + carry = (csum < daddr->s6_addr32[0]); + csum += carry; + + csum += daddr->s6_addr32[1]; + carry = (csum < daddr->s6_addr32[1]); + csum += carry; + + csum += daddr->s6_addr32[2]; + carry = (csum < daddr->s6_addr32[2]); + csum += carry; + + csum += daddr->s6_addr32[3]; + carry = (csum < daddr->s6_addr32[3]); + csum += carry; + + ulen = htonl((__u32) len); + csum += ulen; + carry = (csum < ulen); + csum += carry; + + uproto = htonl(proto); + csum += uproto; + carry = (csum < uproto); + csum += carry; + + return csum_fold(csum); } - - -/* - * computes the checksum of a memory block at buff, length len, - * and adds in "sum" (32-bit) - * - * returns a 32-bit number suitable for feeding into itself - * or csum_tcpudp_magic - * - * this function must be called with even lengths, except - * for the last fragment, which may be odd - * - * it's best to have buff aligned on a 32-bit boundary - */ -unsigned int csum_partial(unsigned char * buff, int len, unsigned int sum); - - - -/* - * the same as csum_partial, but copies from fs:src while it - * checksums - * - * here even more important to align src and dst on a 32-bit (or even - * better 64-bit) boundary - */ - -unsigned int csum_partial_copyffs( char *src, char *dst, int len, int sum); - - - - -/* - * this routine is used for miscellaneous IP-like checksums, mainly - * in icmp.c - */ - -static inline unsigned short ip_compute_csum(unsigned char * buff, int len) { - unsigned short int sum; - -#ifdef __i386__ - __asm__(" - movl %%eax, %%ecx - shrl $16, %%ecx - addw %%cx, %%ax - adcl $0, %%eax - notl %%eax - andl $65535, %%eax - " - : "=a"(sum) - : "a" (csum_partial(buff, len, 0)) - : "cx"); -#elif defined (__mips__) - __asm__(" - .set noat - srl $1,%0,16 - addu %0,$1 - sltu $1,%0,$1 - nor %0,$0,%0 - andi %0,0xffff - .set at" - : "=r"(sum) - : "r" (csum_partial(buff, len, 0)) - : "$1"); -#else -#error Not implemented for this CPU #endif - return(sum); -} #endif diff --git a/include/net/datalink.h b/include/net/datalink.h index 34ae08daa..44e56990c 100644 --- a/include/net/datalink.h +++ b/include/net/datalink.h @@ -4,7 +4,7 @@ struct datalink_proto { unsigned short type_len; unsigned char type[8]; - char *string_name; + const char *string_name; unsigned short header_length; int (*rcvfunc)(struct sk_buff *, struct device *, struct packet_type *); @@ -14,4 +14,3 @@ struct datalink_proto { }; #endif - diff --git a/include/net/eth.h b/include/net/eth.h deleted file mode 100644 index 3c11603e0..000000000 --- a/include/net/eth.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * INET An implementation of the TCP/IP protocol suite for the LINUX - * operating system. NET is implemented using the BSD Socket - * interface as the means of communication with the user level. - * - * Definitions for the Ethernet handlers. - * - * Version: @(#)eth.h 1.0.4 05/13/93 - * - * Authors: Ross Biro, <bir7@leland.Stanford.Edu> - * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - */ -#ifndef _ETH_H -#define _ETH_H - - -#include <linux/if_ether.h> - - -extern char *eth_print(unsigned char *ptr); -extern void eth_dump(struct ethhdr *eth); -extern int eth_header(unsigned char *buff, struct device *dev, - unsigned short type, unsigned long daddr, - unsigned long saddr, unsigned len); -extern int eth_rebuild_header(void *buff, struct device *dev); -extern void eth_add_arp(unsigned long addr, struct sk_buff *skb, - struct device *dev); -extern unsigned short eth_type_trans(struct sk_buff *skb, struct device *dev); -extern int eth_header_cache(struct device *dev, struct sock *sk, unsigned long saddr, unsigned long daddr); - -#endif /* _ETH_H */ diff --git a/include/net/gc.h b/include/net/gc.h new file mode 100644 index 000000000..0b28c098e --- /dev/null +++ b/include/net/gc.h @@ -0,0 +1,46 @@ +/* + * Interface routines assumed by gc() + * + * Copyright (C) Barak A. Pearlmutter. + * Released under the GPL version 2 or later. + * + */ + +typedef struct object *pobj; /* pointer to a guy of the type we gc */ + +/* + * How to mark and unmark objects + */ + +extern void gc_mark(pobj); +extern void gc_unmark(pobj); +extern int gc_marked(pobj); + +/* + * How to count and access an object's children + */ + +extern int n_children(pobj); /* how many children */ +extern pobj child_n(pobj, int); /* child i, numbered 0..n-1 */ + +/* + * How to access the root set + */ + +extern int root_size(void); /* number of things in root set */ +extern pobj root_elt(int); /* element i of root set, numbered 0..n-1 */ + +/* + * How to access the free list + */ + +extern void clear_freelist(void); +extern void add_to_free_list(pobj); + +/* + * How to iterate through all objects in memory + */ + +extern int N_OBJS; +extern pobj obj_number(int); + diff --git a/include/net/head_explode.h b/include/net/head_explode.h deleted file mode 100644 index 90276fafe..000000000 --- a/include/net/head_explode.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Header exploders. We inline those only appearing once. - * - * We assume 8 bit bytes. - * - * This is oriented to getting good code out of GCC. It may need - * tuning for other processors. - * - * Note only IGMP uses this so far. Just as an experiment. - */ - - -extern __inline__ unsigned char *exp_getu16(unsigned char *bp, unsigned short *u) -{ - *u=(*bp<<8)|bp[1]; - return bp+2; -} - -extern __inline__ unsigned char *exp_getn16(unsigned char *bp, unsigned short *u) -{ - unsigned char *tp=(unsigned char *)u; - *tp++=*bp++; - *tp++=*bp++; - return bp; -} - -extern __inline__ unsigned char *imp_putu16(unsigned char *bp, unsigned short n) -{ - *bp=(n>>8); - bp[1]=n&0xFF; - return bp+2; -} - -extern __inline__ unsigned char *imp_putn16(unsigned char *bp, unsigned short n) -{ - unsigned char *sp=(unsigned char *)&n; - *bp++=*sp++; - *bp++=*sp++; - return bp; -} - -extern __inline__ unsigned char *exp_getu32(unsigned char *bp, unsigned long *u) -{ - *u=(bp[0]<<24)|(bp[1]<<16)|(bp[2]<<8)|bp[3]; - return bp+4; -} - -extern __inline__ unsigned char *exp_getn32(unsigned char *bp, unsigned long *u) -{ - unsigned char *tp=(unsigned char *)u; - *tp++=*bp++; - *tp++=*bp++; - *tp++=*bp++; - *tp++=*bp++; - return bp; -} - -extern __inline__ unsigned char *imp_putu32(unsigned char *bp, unsigned long n) -{ - bp[0]=n>>24; - bp[1]=(n>>16)&0xFF; - bp[2]=(n>>8)&0xFF; - bp[3]=n&0xFF; - return bp+4; -} - -extern __inline__ unsigned char *imp_putn32(unsigned char *bp, unsigned long n) -{ - unsigned char *sp=(unsigned char *)&n; - *bp++=*sp++; - *bp++=*sp++; - *bp++=*sp++; - *bp++=*sp++; - return bp; -} - -#if 0 - -extern __inline__ unsigned char *ip_explode(unsigned char *iph, struct ip_header *ip) -{ - ip->version=*iph>>4; /* Avoid the shift. We do our equality checks shifted too */ - ip->ihl=(*iph++)&0xF; /* Length in long words */ - ip->tos=*iph++; /* Service type */ - iph=exp_getu16(iph,&ip->tot_len); /* Length of packet */ - iph=exp_getu16(iph,&ip->id); /* Packet identity */ - iph=exp_getu16(iph,&ip->frag_off); /* Fragment offset */ - ip->ttl=*iph++; - ip->protocol=*iph++; - iph=exp_getn16(iph,&ip->check); - iph=exp_getn32(iph,&ip->saddr); - iph=exp_getn32(iph,&ip->daddr); - return iph; -} - -extern __inline__ unsigned char *icmp_explode(unsigned char *icmph, struct icmp_header *icmp) -{ - icmp->type=*icmp++; - icmp->code=*icmp++; - icmph=exp_getn16(icmph,&icmp->checksum); - /* These two pairs are a union... expand both */ - exp_getu32(icmph,&icmp->gateway); - icmph=exp_getu16(icmph,&icmp->id); - icmph=exp_getu16(icmph,&icmp->sequence); - return icmph; -} - -#endif - -extern __inline__ unsigned char *igmp_explode(unsigned char *igmph, struct igmp_header *igmp) -{ - igmp->type=*igmph++; - igmph++; /* unused */ - igmph=exp_getn16(igmph,&igmp->csum); - igmph=exp_getn32(igmph,&igmp->group); - return igmph; -} - -#if 0 -extern __inline__ unsigned char *tcp_explode(unsigned char *tcph, struct tcp_header *tcp) -{ - tcph=exp_getu16(tcph,&tcp->source); - tcph=exp_getu16(tcph,&tcp->dest); - tcph=exp_getu32(tcph,&tcp->seq); - tcph=exp_getu32(tcph,&tcp->ack_seq); - tcph=exp_getu16(tcph,&tcp->u.bitmask); - tcph=exp_getu16(tcph,&tcp->window); - tcph=exp_getn16(tcph,&tcp->check); - tcph=exp_getu16(tcph,&tcp->urg_ptr); - return tcph; -} - -extern __inline__ unsigned char *udp_explode(unsigned char *udph, struct udp_header *udp) -{ - udph=exp_getu16(tcph,&udp->source); - udph=exp_getu16(udph,&udp->dest); - udph=exp_getu16(udph,&udp->len); - udph=exp_getn16(udph,&udp->check); - return udph; -} -#endif diff --git a/include/net/icmp.h b/include/net/icmp.h index 8f1c34983..fa770d238 100644 --- a/include/net/icmp.h +++ b/include/net/icmp.h @@ -19,20 +19,25 @@ #define _ICMP_H #include <linux/icmp.h> +#include <linux/skbuff.h> +#include <net/sock.h> +#include <net/protocol.h> extern struct icmp_err icmp_err_convert[]; extern struct icmp_mib icmp_statistics; - extern void icmp_send(struct sk_buff *skb_in, int type, int code, unsigned long info, struct device *dev); extern int icmp_rcv(struct sk_buff *skb1, struct device *dev, - struct options *opt, unsigned long daddr, - unsigned short len, unsigned long saddr, + struct options *opt, __u32 daddr, + unsigned short len, __u32 saddr, int redo, struct inet_protocol *protocol); - extern int icmp_ioctl(struct sock *sk, int cmd, unsigned long arg); +extern void icmp_init(struct proto_ops *ops); + +/* CONFIG_IP_TRANSPARENT_PROXY */ +extern int icmp_chkaddr(struct sk_buff *skb); #endif /* _ICMP_H */ diff --git a/include/net/if_inet6.h b/include/net/if_inet6.h new file mode 100644 index 000000000..048243c33 --- /dev/null +++ b/include/net/if_inet6.h @@ -0,0 +1,109 @@ +/* + * inet6 interface/address list definitions + * Linux INET6 implementation + * + * Authors: + * Pedro Roque <roque@di.fc.ul.pt> + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ + +#ifndef _NET_IF_INET6_H +#define _NET_IF_INET6_H + +#define DAD_COMPLETE 0x00 +#define DAD_INCOMPLETE 0x01 +#define DAD_STATUS 0x01 + +#define ADDR_STATUS 0x06 +#define ADDR_DEPRECATED 0x02 +#define ADDR_INVALID 0x04 + +#define ADDR_PERMANENT 0x80 + +#define IF_RA_RCVD 0x20 +#define IF_RS_SENT 0x10 + +#ifdef __KERNEL__ + +struct inet6_ifaddr +{ + struct in6_addr addr; + __u32 prefix_len; + + __u32 valid_lft; + __u32 prefered_lft; + unsigned long tstamp; + + __u8 probes; + __u8 flags; + + __u16 scope; + + struct timer_list timer; + + struct inet6_dev *idev; + + struct inet6_ifaddr *lst_next; /* next addr in addr_lst */ + struct inet6_ifaddr *if_next; /* next addr in inet6_dev */ +}; + + +struct ipv6_mc_socklist { + struct in6_addr addr; + struct device *dev; + struct ipv6_mc_socklist *next; +}; + +struct ipv6_mc_list { + struct in6_addr addr; + struct device *dev; + struct ipv6_mc_list *next; + struct ipv6_mc_list *if_next; + struct timer_list timer; + int tm_running; + atomic_t users; +}; + +#define IFA_HOST IPV6_ADDR_LOOPBACK +#define IFA_LINK IPV6_ADDR_LINKLOCAL +#define IFA_SITE IPV6_ADDR_SITELOCAL +#define IFA_GLOBAL 0x0000U + +extern int in6_ifnum; + +struct inet6_dev +{ + struct device *dev; + + struct inet6_ifaddr *addr_list; + struct ipv6_mc_list *mc_list; + + __u32 if_index; + __u32 if_flags; + __u32 router:1, + unused:31; + + struct inet6_dev *next; +}; + + +extern __inline__ void ipv6_mc_map(struct in6_addr *addr, char *buf) +{ + /* + * +-------+-------+-------+-------+-------+-------+ + * | 33 | 33 | DST13 | DST14 | DST15 | DST16 | + * +-------+-------+-------+-------+-------+-------+ + */ + + buf[0]= 0x33; + buf[1]= 0x33; + + memcpy(buf + 2, &addr->s6_addr32[3], sizeof(__u32)); +} +#endif +#endif diff --git a/include/net/inet_common.h b/include/net/inet_common.h new file mode 100644 index 000000000..c72c75333 --- /dev/null +++ b/include/net/inet_common.h @@ -0,0 +1,47 @@ +#ifndef _INET_COMMON_H +#define _INET_COMMON_H + +extern struct proto_ops inet_proto_ops; +extern struct sock * tcp_sock_array[SOCK_ARRAY_SIZE]; +extern struct sock * udp_sock_array[SOCK_ARRAY_SIZE]; + + +/* + * INET4 prototypes used by INET6 + */ + +extern void inet_remove_sock(struct sock *sk1); +extern void inet_put_sock(unsigned short num, + struct sock *sk); +extern int inet_release(struct socket *sock, + struct socket *peer); +extern int inet_connect(struct socket *sock, + struct sockaddr * uaddr, + int addr_len, int flags); +extern int inet_accept(struct socket *sock, + struct socket *newsock, int flags); +extern int inet_recvmsg(struct socket *sock, + struct msghdr *ubuf, + int size, int noblock, + int flags, int *addr_len ); +extern int inet_sendmsg(struct socket *sock, + struct msghdr *msg, + int size, int noblock, + int flags); +extern int inet_shutdown(struct socket *sock, int how); +extern int inet_select(struct socket *sock, int sel_type, + select_table *wait); +extern int inet_setsockopt(struct socket *sock, int level, + int optname, char *optval, + int optlen); +extern int inet_getsockopt(struct socket *sock, int level, + int optname, char *optval, + int *optlen); +extern int inet_fcntl(struct socket *sock, + unsigned int cmd, + unsigned long arg); +extern int inet_listen(struct socket *sock, int backlog); + +#endif + + diff --git a/include/net/ip.h b/include/net/ip.h index 6726e8a48..f7bb04c53 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -25,12 +25,13 @@ #include <linux/socket.h> #include <linux/ip.h> #include <linux/netdevice.h> +#include <net/route.h> #ifndef _SNMP_H -#include "snmp.h" +#include <net/snmp.h> #endif -#include "sock.h" /* struct sock */ +#include <net/sock.h> /* struct sock */ /* IP flags. */ #define IP_CE 0x8000 /* Flag: "Congestion" */ @@ -43,73 +44,111 @@ #ifdef CONFIG_IP_MULTICAST extern void ip_mc_dropsocket(struct sock *); extern void ip_mc_dropdevice(struct device *dev); -extern int ip_mc_procinfo(char *, char **, off_t, int); -#define MULTICAST(x) (IN_MULTICAST(htonl(x))) +extern int ip_mc_procinfo(char *, char **, off_t, int, int); #endif - + +#include <net/ip_forward.h> /* Describe an IP fragment. */ -struct ipfrag { - int offset; /* offset of fragment in IP datagram */ - int end; /* last byte of data in datagram */ - int len; /* length of this fragment */ - struct sk_buff *skb; /* complete received fragment */ - unsigned char *ptr; /* pointer into real fragment data */ - struct ipfrag *next; /* linked list pointers */ - struct ipfrag *prev; +struct ipfrag +{ + int offset; /* offset of fragment in IP datagram */ + int end; /* last byte of data in datagram */ + int len; /* length of this fragment */ + struct sk_buff *skb; /* complete received fragment */ + unsigned char *ptr; /* pointer into real fragment data */ + struct ipfrag *next; /* linked list pointers */ + struct ipfrag *prev; }; -/* Describe an entry in the "incomplete datagrams" queue. */ -struct ipq { - unsigned char *mac; /* pointer to MAC header */ - struct iphdr *iph; /* pointer to IP header */ - int len; /* total length of original datagram */ - short ihlen; /* length of the IP header */ - short maclen; /* length of the MAC header */ - struct timer_list timer; /* when will this queue expire? */ - struct ipfrag *fragments; /* linked list of received fragments */ - struct ipq *next; /* linked list pointers */ - struct ipq *prev; - struct device *dev; /* Device - for icmp replies */ +/* + * Describe an entry in the "incomplete datagrams" queue. + */ + +struct ipq +{ + unsigned char *mac; /* pointer to MAC header */ + struct iphdr *iph; /* pointer to IP header */ + int len; /* total length of original datagram */ + short ihlen; /* length of the IP header */ + short maclen; /* length of the MAC header */ + struct timer_list timer; /* when will this queue expire? */ + struct ipfrag *fragments; /* linked list of received fragments */ + struct ipq *next; /* linked list pointers */ + struct ipq *prev; + struct device *dev; /* Device - for icmp replies */ }; - -extern int backoff(int n); +/* + * Functions provided by ip.c + */ extern void ip_print(const struct iphdr *ip); -extern int ip_ioctl(struct sock *sk, int cmd, - unsigned long arg); -extern void ip_route_check(unsigned long daddr); -extern int ip_build_header(struct sk_buff *skb, - unsigned long saddr, - unsigned long daddr, +extern int ip_ioctl(struct sock *sk, int cmd, unsigned long arg); +extern void ip_route_check(__u32 daddr); +extern int ip_send(struct rtable *rt, struct sk_buff *skb, __u32 daddr, int len, struct device *dev, __u32 saddr); +extern int ip_build_header(struct sk_buff *skb, + __u32 saddr, + __u32 daddr, struct device **dev, int type, struct options *opt, int len, - int tos,int ttl); -/*extern unsigned short ip_compute_csum(unsigned char * buff, int len);*/ + int tos,int ttl,struct rtable **rp); extern int ip_rcv(struct sk_buff *skb, struct device *dev, struct packet_type *pt); -extern void ip_forward(struct sk_buff *skb, struct device *dev, int is_frag, unsigned long target_addr, int target_strict); +extern int ip_options_echo(struct options * dopt, struct options * sopt, + __u32 daddr, __u32 saddr, + struct sk_buff * skb); +extern int ip_options_compile(struct options * opt, struct sk_buff * skb); extern void ip_send_check(struct iphdr *ip); extern int ip_id_count; extern void ip_queue_xmit(struct sock *sk, struct device *dev, struct sk_buff *skb, int free); -extern int ip_setsockopt(struct sock *sk, int level, int optname, char *optval, int optlen); -extern int ip_getsockopt(struct sock *sk, int level, int optname, char *optval, int *optlen); extern void ip_init(void); extern int ip_build_xmit(struct sock *sk, - void getfrag (void *, - int, - char *, - unsigned int, - unsigned int), - void *frag, + int getfrag (const void *, + __u32, + char *, + unsigned int, + unsigned int), + const void *frag, unsigned short int length, - int daddr, + __u32 daddr, + __u32 saddr, + struct options * opt, int flags, - int type); + int type, + int noblock); extern struct ip_mib ip_statistics; +/* + * Functions provided by ip_fragment.o + */ + +struct sk_buff *ip_defrag(struct iphdr *iph, struct sk_buff *skb, struct device *dev); +void ip_fragment(struct sock *sk, struct sk_buff *skb, struct device *dev, int is_frag); + +/* + * Functions provided by ip_forward.c + */ + +extern int ip_forward(struct sk_buff *skb, struct device *dev, int is_frag, __u32 target_addr); + +/* + * Functions provided by ip_options.c + */ + +extern void ip_options_build(struct sk_buff *skb, struct options *opt, __u32 daddr, __u32 saddr, int is_frag); +extern int ip_options_echo(struct options *dopt, struct options *sopt, __u32 daddr, __u32 saddr, struct sk_buff *skb); +extern void ip_options_fragment(struct sk_buff *skb); +extern int ip_options_compile(struct options *opt, struct sk_buff *skb); + +/* + * Functions provided by ip_sockglue.c + */ + +extern int ip_setsockopt(struct sock *sk, int level, int optname, char *optval, int optlen); +extern int ip_getsockopt(struct sock *sk, int level, int optname, char *optval, int *optlen); + #endif /* _IP_H */ diff --git a/include/net/ip_alias.h b/include/net/ip_alias.h new file mode 100644 index 000000000..683a04276 --- /dev/null +++ b/include/net/ip_alias.h @@ -0,0 +1,23 @@ +/* + * IP_ALIAS (AF_INET) aliasing definitions. + * + * + * Version: @(#)ip_alias.h 0.43 12/20/95 + * + * Author: Juan Jose Ciarlante, <jjciarla@raiz.uncu.edu.ar> + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + */ + +#ifndef _IP_ALIAS_H +#define _IP_ALIAS_H + +extern int ip_alias_init(void); +extern int ip_alias_done(void); + +#endif /* _IP_ALIAS_H */ diff --git a/include/net/ip_forward.h b/include/net/ip_forward.h new file mode 100644 index 000000000..f1b532f31 --- /dev/null +++ b/include/net/ip_forward.h @@ -0,0 +1,11 @@ +#ifndef __NET_IP_FORWARD_H +#define __NET_IP_FORWARD_H + +#define IPFWD_FRAGMENT 1 +#define IPFWD_LASTFRAG 2 +#define IPFWD_MASQUERADED 4 +#define IPFWD_MULTICASTING 8 +#define IPFWD_MULTITUNNEL 0x10 +#define IPFWD_NOTTLDEC 0x20 + +#endif diff --git a/include/net/ip_masq.h b/include/net/ip_masq.h new file mode 100644 index 000000000..8b29eeb15 --- /dev/null +++ b/include/net/ip_masq.h @@ -0,0 +1,172 @@ +/* + * IP masquerading functionality definitions + */ + +#ifndef _IP_MASQ_H +#define _IP_MASQ_H + +#include <linux/types.h> +#include <linux/netdevice.h> +#include <linux/skbuff.h> + +/* + * Linux ports don't normally get allocated above 32K. + * I used an extra 4K port-space + */ + +#define PORT_MASQ_BEGIN 61000 +#define PORT_MASQ_END (PORT_MASQ_BEGIN+4096) + +#define MASQUERADE_EXPIRE_TCP 15*60*HZ +#define MASQUERADE_EXPIRE_TCP_FIN 2*60*HZ +#define MASQUERADE_EXPIRE_UDP 5*60*HZ + +#define IP_MASQ_F_OUT_SEQ 0x01 /* must do output seq adjust */ +#define IP_MASQ_F_IN_SEQ 0x02 /* must do input seq adjust */ +#define IP_MASQ_F_NO_DPORT 0x04 /* no dport set yet */ +#define IP_MASQ_F_NO_DADDR 0x08 /* no daddr yet */ +#define IP_MASQ_F_HASHED 0x10 /* hashed entry */ +#define IP_MASQ_F_SAW_RST 0x20 /* tcp rst pkt seen */ +#define IP_MASQ_F_SAW_FIN_IN 0x40 /* tcp fin pkt seen incoming */ +#define IP_MASQ_F_SAW_FIN_OUT 0x80 /* tcp fin pkt seen outgoing */ +#define IP_MASQ_F_SAW_FIN (IP_MASQ_F_SAW_FIN_IN | \ + IP_MASQ_F_SAW_FIN_OUT) + /* tcp fin pkts seen */ + +#ifdef __KERNEL__ + +/* + * Delta seq. info structure + * Each MASQ struct has 2 (output AND input seq. changes). + */ + +struct ip_masq_seq { + __u32 init_seq; /* Add delta from this seq */ + short delta; /* Delta in sequence numbers */ + short previous_delta; /* Delta in sequence numbers before last resized pkt */ +}; + +/* + * MASQ structure allocated for each masqueraded association + */ +struct ip_masq { + struct ip_masq *m_link, *s_link; /* hashed link ptrs */ + struct timer_list timer; /* Expiration timer */ + __u16 protocol; /* Which protocol are we talking? */ + __u16 sport, dport, mport; /* src, dst & masq ports */ + __u32 saddr, daddr, maddr; /* src, dst & masq addresses */ + struct ip_masq_seq out_seq, in_seq; + struct ip_masq_app *app; /* bound ip_masq_app object */ + void *app_data; /* Application private data */ + unsigned flags; /* status flags */ +}; + +/* + * timeout values + */ + +struct ip_fw_masq { + int tcp_timeout; + int tcp_fin_timeout; + int udp_timeout; +}; + +extern struct ip_fw_masq *ip_masq_expire; + +/* + * [0]: UDP free_ports + * [1]: TCP free_ports + */ + +extern int ip_masq_free_ports[2]; + +/* + * ip_masq initializer (registers symbols and /proc/net entries) + */ +extern int ip_masq_init(void); + +/* + * functions called from ip layer + */ +extern int ip_fw_masquerade(struct sk_buff **, struct device *); +extern int ip_fw_masq_icmp(struct sk_buff **, struct device *); +extern int ip_fw_demasquerade(struct sk_buff **, struct device *); + +/* + * ip_masq obj creation/deletion functions. + */ +extern struct ip_masq *ip_masq_new(struct device *dev, int proto, __u32 saddr, __u16 sport, __u32 daddr, __u16 dport, unsigned flags); +extern void ip_masq_set_expire(struct ip_masq *ms, unsigned long tout); + + +/* + * + * IP_MASQ_APP: IP application masquerading definitions + * + */ + +struct ip_masq_app +{ + struct ip_masq_app *next; + char *name; /* name of application proxy */ + unsigned type; /* type = proto<<16 | port (host byte order)*/ + int n_attach; + int (*masq_init_1) /* ip_masq initializer */ + (struct ip_masq_app *, struct ip_masq *); + int (*masq_done_1) /* ip_masq fin. */ + (struct ip_masq_app *, struct ip_masq *); + int (*pkt_out) /* output (masquerading) hook */ + (struct ip_masq_app *, struct ip_masq *, struct sk_buff **, struct device *); + int (*pkt_in) /* input (demasq) hook */ + (struct ip_masq_app *, struct ip_masq *, struct sk_buff **, struct device *); +}; + +/* + * ip_masq_app initializer + */ +extern int ip_masq_app_init(void); + +/* + * ip_masq_app object registration functions (port: host byte order) + */ +extern int register_ip_masq_app(struct ip_masq_app *mapp, unsigned short proto, __u16 port); +extern int unregister_ip_masq_app(struct ip_masq_app *mapp); + +/* + * get ip_masq_app obj by proto,port(net_byte_order) + */ +extern struct ip_masq_app * ip_masq_app_get(unsigned short proto, __u16 port); + +/* + * ip_masq TO ip_masq_app (un)binding functions. + */ +extern struct ip_masq_app * ip_masq_bind_app(struct ip_masq *ms); +extern int ip_masq_unbind_app(struct ip_masq *ms); + +/* + * output and input app. masquerading hooks. + * + */ +extern int ip_masq_app_pkt_out(struct ip_masq *, struct sk_buff **skb_p, struct device *dev); +extern int ip_masq_app_pkt_in(struct ip_masq *, struct sk_buff **skb_p, struct device *dev); + +/* + * service routine(s). + */ +extern struct ip_masq * ip_masq_out_get_2(int protocol, __u32 s_addr, __u16 s_port, __u32 d_addr, __u16 d_port); +extern struct ip_masq * ip_masq_in_get_2(int protocol, __u32 s_addr, __u16 s_port, __u32 d_addr, __u16 d_port); + +/* + * /proc/net entry + */ +extern int ip_masq_app_getinfo(char *buffer, char **start, off_t offset, int length, int dummy); + +/* + * skb_replace function used by "client" modules to replace + * a segment of skb. + */ +extern struct sk_buff * ip_masq_skb_replace(struct sk_buff *skb, int pri, char *o_buf, int o_len, char *n_buf, int n_len); + +#endif /* __KERNEL__ */ + +#endif /* _IP_MASQ_H */ diff --git a/include/net/ipip.h b/include/net/ipip.h index 398e375de..bba1492ed 100644 --- a/include/net/ipip.h +++ b/include/net/ipip.h @@ -1,4 +1,4 @@ extern int ipip_rcv(struct sk_buff *skb, struct device *dev, struct options *opt, - unsigned long daddr, unsigned short len, unsigned long saddr, + __u32 daddr, unsigned short len, __u32 saddr, int redo, struct inet_protocol *protocol); diff --git a/include/net/ipv6.h b/include/net/ipv6.h new file mode 100644 index 000000000..5b1042927 --- /dev/null +++ b/include/net/ipv6.h @@ -0,0 +1,296 @@ +/* + * Linux INET6 implementation + * + * Authors: + * Pedro Roque <roque@di.fc.ul.pt> + * + * $Id: ipv6.h,v 1.19 1996/09/24 17:04:20 roque Exp $ + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ + +#ifndef _NET_IPV6_H +#define _NET_IPV6_H + +#include <linux/ipv6.h> +#include <net/ndisc.h> + +/* + * NextHeader field of IPv6 header + */ + +#define NEXTHDR_HOP 0 /* Hop-by-hop option header. */ +#define NEXTHDR_TCP 6 /* TCP segment. */ +#define NEXTHDR_UDP 17 /* UDP message. */ +#define NEXTHDR_IPV6 41 /* IPv6 in IPv6 */ +#define NEXTHDR_ROUTING 43 /* Routing header. */ +#define NEXTHDR_FRAGMENT 44 /* Fragmentation/reassembly header. */ +#define NEXTHDR_ESP 50 /* Encapsulating security payload. */ +#define NEXTHDR_AUTH 51 /* Authentication header. */ +#define NEXTHDR_ICMP 58 /* ICMP for IPv6. */ +#define NEXTHDR_NONE 59 /* No next header */ +#define NEXTHDR_DEST 60 /* Destination options header. */ + +#define NEXTHDR_MAX 255 + + + +#define IPV6_DEFAULT_HOPLIMIT 64 +#define IPV6_DEFAULT_MCASTHOPS 1 + +/* + * Addr type + * + * type - unicast | multicast | anycast + * scope - local | site | global + * v4 - compat + * v4mapped + * any + * loopback + */ + +#define IPV6_ADDR_ANY 0x0000U + +#define IPV6_ADDR_UNICAST 0x0001U +#define IPV6_ADDR_MULTICAST 0x0002U +#define IPV6_ADDR_ANYCAST 0x0004U + +#define IPV6_ADDR_LOOPBACK 0x0010U +#define IPV6_ADDR_LINKLOCAL 0x0020U +#define IPV6_ADDR_SITELOCAL 0x0040U + +#define IPV6_ADDR_COMPATv4 0x0080U + +#define IPV6_ADDR_SCOPE_MASK 0x00f0U + +#define IPV6_ADDR_MAPPED 0x1000U +#define IPV6_ADDR_RESERVED 0x2000U /* reserved address space */ + +/* + * fragmentation header + */ + +struct frag_hdr { + unsigned char nexthdr; + unsigned char reserved; + unsigned short frag_off; + __u32 identification; +}; + +#ifdef __KERNEL__ + +#include <net/sock.h> + +extern struct ipv6_mib ipv6_statistics; + +extern int ipv6_forwarding; /* host/router switch */ +extern int ipv6_hop_limit; /* default hop limit */ + +struct ipv6_frag { + __u16 offset; + __u16 len; + struct sk_buff *skb; + + struct frag_hdr *fhdr; + + struct ipv6_frag *next; +}; + +/* + * Equivalent of ipv4 struct ipq + */ + +struct frag_queue { + + struct frag_queue *next; + struct frag_queue *prev; + + __u32 id; /* fragment id */ + struct timer_list timer; /* expire timer */ + struct ipv6_frag *fragments; + struct device *dev; + __u8 last_in; /* has last segment arrived? */ + __u8 nexthdr; + __u8 *nhptr; +}; + +extern int ipv6_routing_header(struct sk_buff **skb, + struct device *dev, + __u8 *nhptr, + struct ipv6_options *opt); + +extern int ipv6_reassembly(struct sk_buff **skb, + struct device *dev, + __u8 *nhptr, + struct ipv6_options *opt); + +#define IPV6_FRAG_TIMEOUT (60*HZ) /* 60 seconds */ + +/* + * Function prototype for build_xmit + */ + +typedef int (*inet_getfrag_t) (const void *data, + struct in6_addr *addr, + char *, + unsigned int, unsigned int); + + +extern int ipv6_addr_type(struct in6_addr *addr); + +extern __inline__ int ipv6_addr_cmp(struct in6_addr *a1, struct in6_addr *a2) +{ + return memcmp((void *) a1, (void *) a2, sizeof(struct in6_addr)); +} + +extern __inline__ void ipv6_addr_copy(struct in6_addr *a1, struct in6_addr *a2) +{ + memcpy((void *) a1, (void *) a2, sizeof(struct in6_addr)); +} + +#ifndef __HAVE_ARCH_ADDR_SET +extern __inline__ void ipv6_addr_set(struct in6_addr *addr, + __u32 w1, __u32 w2, + __u32 w3, __u32 w4) +{ + addr->s6_addr32[0] = w1; + addr->s6_addr32[1] = w2; + addr->s6_addr32[2] = w3; + addr->s6_addr32[3] = w4; +} +#endif + +extern __inline__ int ipv6_addr_any(struct in6_addr *a) +{ + return ((a->s6_addr32[0] | a->s6_addr32[1] | + a->s6_addr32[2] | a->s6_addr32[3] ) == 0); +} + +/* + * Prototypes exported by ipv6 + */ + +#if 0 +extern int ipv6_build_header(struct sk_buff *skb, + struct device *dev, + struct in6_addr *saddr_in, + struct in6_addr *daddr_in, + int proto, int len, + struct ipv6_pinfo *np); +#endif + +extern void ipv6_redo_mac_hdr(struct sk_buff *skb, + struct neighbour *neigh, + int len); + +extern int ipv6_bld_hdr_2(struct sock *sk, + struct sk_buff *skb, + struct device *dev, + struct neighbour *neigh, + struct in6_addr *saddr, + struct in6_addr *daddr, + int proto, int len); + +extern int ipv6_xmit(struct sock *sk, + struct sk_buff *skb, + struct in6_addr *saddr, + struct in6_addr *daddr, + struct ipv6_options *opt, + int proto); + +extern void ipv6_queue_xmit(struct sock *sk, + struct device *dev, + struct sk_buff *skb, + int free); + +extern int ipv6_build_xmit(struct sock *sk, + inet_getfrag_t getfrag, + const void * data, + struct in6_addr * daddr, + unsigned short int length, + struct in6_addr * saddr, + struct device *dev, + struct ipv6_options *opt, + int proto, int noblock); + +/* + * rcv function (called from netdevice level) + */ + +extern int ipv6_rcv(struct sk_buff *skb, + struct device *dev, + struct packet_type *pt); + +extern void ipv6_forward(struct sk_buff *skb, + struct device *dev, + int flags); + +#define IP6_FW_SRCRT 0x1 +#define IP6_FW_STRICT 0x2 + +/* + * Extension header (options) processing + */ +extern int ipv6opt_bld_rthdr(struct sk_buff *skb, + struct ipv6_options *opt, + struct in6_addr *addr, + int proto); + +extern int ipv6opt_srcrt_co(struct sockaddr_in6 *sin6, + int len, + struct ipv6_options *opt); + +extern int ipv6opt_srcrt_cl(struct sockaddr_in6 *sin6, + int num_addrs, + struct ipv6_options *opt); + +extern int ipv6opt_srt_tosin(struct ipv6_options *opt, + struct sockaddr_in6 *sin6, + int len); + +extern void ipv6opt_free(struct ipv6_options *opt); + + +/* + * socket lookup (af_inet6.c) + */ + +extern struct sock * inet6_get_sock(struct proto *prot, + struct in6_addr *loc_addr, + struct in6_addr *rmt_addr, + unsigned short loc_port, + unsigned short rmt_port); + +extern struct sock * inet6_get_sock_raw(struct sock *sk, + unsigned short num, + struct in6_addr *loc_addr, + struct in6_addr *rmt_addr); + +extern struct sock * inet6_get_sock_mcast(struct sock *sk, + unsigned short num, + unsigned short rmt_port, + struct in6_addr *loc_addr, + struct in6_addr *rmt_addr); + +/* + * socket options (ipv6_sockglue.c) + */ + +extern int ipv6_setsockopt(struct sock *sk, int level, + int optname, char *optval, + int optlen); +extern int ipv6_getsockopt(struct sock *sk, int level, + int optname, char *optval, + int *optlen); + + +extern void ipv6_init(void); +extern void ipv6_cleanup(void); +#endif +#endif + + + diff --git a/include/net/ipv6_route.h b/include/net/ipv6_route.h new file mode 100644 index 000000000..aaa1ba0a2 --- /dev/null +++ b/include/net/ipv6_route.h @@ -0,0 +1,200 @@ +/* + * Linux INET6 implementation + * + * Authors: + * Pedro Roque <roque@di.fc.ul.pt> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ + +#ifndef _NET_IPV6_ROUTE_H +#define _NET_IPV6_ROUTE_H + +#include <linux/ipv6_route.h> + + +#ifdef __KERNEL__ + + +struct fib6_node { + struct fib6_node *parent; + struct fib6_node *left; + struct fib6_node *right; + + struct rt6_info *leaf; + + __u16 fn_bit; /* bit key */ + __u16 fn_flags; + __u32 fn_sernum; +}; + + +struct rt6_info; + +typedef void (*rt6_output_method_t) (struct sk_buff *skb, struct rt6_info *rt); + +struct rt6_info { + struct fib6_node *fib_node; + struct rt6_info *next; + + struct in6_addr rt_dst; + + atomic_t rt_use; /* dcache references */ + atomic_t rt_ref; /* fib references */ + + struct neighbour *rt_nexthop; + struct device *rt_dev; + + rt6_output_method_t rt_output_method; + + __u16 rt_metric; + __u16 rt_prefixlen; + __u32 rt_flags; + unsigned long rt_expires; +}; + +extern struct rt6_info *default_rt_list; +extern struct rt6_info *last_resort_rt; + +struct dest_entry { + struct rt6_info rt; + + __u32 dc_irtt; + __u32 dc_window; + __u16 dc_pmtu; + + unsigned long dc_tstamp; /* for garbage collection */ + +#define dc_addr rt.rt_dst +#define dc_usecnt rt.rt_use +#define dc_nexthop rt.rt_nexthop +#define dc_flags rt.rt_flags +}; + +/* + * Structure for assync processing of operations on the routing + * table + */ + +struct rt6_req { + int operation; + struct rt6_info *ptr; + + struct rt6_req *next; + struct rt6_req *prev; + +#define RT_OPER_ADD 1 +#define RT_OPER_DEL 2 +}; + +struct rt6_statistics { + __u32 fib_nodes; + __u32 fib_route_nodes; + __u32 fib_rt_alloc; + __u32 fib_rt_entries; + __u32 fib_dc_alloc; +}; + +#define RTN_ROOT 0x0001 /* root node */ +#define RTN_BACKTRACK 0x0002 /* backtrack point */ +#define RTN_TAG 0x0010 + +/* + * Values for destination cache garbage colection + * These are wild guesses for now... + */ + +#define DC_WATER_MARK 512 +#define DC_SHORT_TIMEOUT (5*HZ) +#define DC_LONG_TIMEOUT (15*HZ) + +#define DC_TIME_RUN (5*HZ) +#define DC_TIME_RETRY HZ + +#define RT6_FILTER_NONE 0 +#define RT6_FILTER_RTNODES 1 +/* + * Prototypes + */ + +/* + * check/obtain destination cache from routing table + */ + +extern struct dest_entry * ipv6_dst_check(struct dest_entry *dc, + struct in6_addr * daddr, + __u32 sernum, int flags); + +extern struct dest_entry * ipv6_dst_route(struct in6_addr * daddr, + struct device *src_dev, + int flags); + +extern void ipv6_dst_unlock(struct dest_entry *dest); + +extern struct rt6_info * fibv6_lookup(struct in6_addr *addr, + struct device *dev, + int flags); + +/* + * user space set/del route + */ + +extern int ipv6_route_ioctl(unsigned int cmd, void *arg); + + +extern void ipv6_route_init(void); +extern void ipv6_route_cleanup(void); + +extern void rt6_ifdown(struct device *dev); + +extern int ipv6_route_add(struct in6_rtmsg *rt); + +extern int fib6_del_rt(struct rt6_info *rt); + +extern void rt6_sndmsg(__u32 type, struct in6_addr *dst, + struct in6_addr *gw, __u16 plen, + struct device *dev, + __u16 metric, __u16 flags); +/* + * ICMP interface + */ + +extern struct rt6_info * ipv6_rt_redirect(struct device *dev, + struct in6_addr *dest, + struct in6_addr *target, + int on_link); + +extern void rt6_handle_pmtu(struct in6_addr *addr, + int pmtu); +/* + * + */ + +extern struct fib6_node routing_table; +extern struct rt6_statistics rt6_stats; + +static __inline__ void rt_release(struct rt6_info *rt) +{ + atomic_dec(&rt->rt_ref); + if ((rt->rt_use | rt->rt_ref) == 0) + { + if (rt->rt_nexthop) + { + ndisc_dec_neigh(rt->rt_nexthop); + } + + if (rt->rt_flags & RTI_DCACHE) + { + rt6_stats.fib_dc_alloc--; + } + rt6_stats.fib_rt_alloc--; + kfree(rt); + } +} + +#endif + +#endif diff --git a/include/net/ipx.h b/include/net/ipx.h index 6842c8325..f23800901 100644 --- a/include/net/ipx.h +++ b/include/net/ipx.h @@ -11,8 +11,9 @@ #ifndef _NET_INET_IPX_H_ #define _NET_INET_IPX_H_ +#include <linux/netdevice.h> #include <linux/skbuff.h> -#include "datalink.h" +#include <net/datalink.h> #include <linux/ipx.h> typedef struct @@ -23,12 +24,13 @@ typedef struct } ipx_address; #define ipx_broadcast_node "\377\377\377\377\377\377" +#define ipx_this_node "\0\0\0\0\0\0" typedef struct ipx_packet { - unsigned short ipx_checksum; + unsigned short ipx_checksum __attribute__ ((packed)); #define IPX_NO_CHECKSUM 0xFFFF - unsigned short ipx_pktsize; + unsigned short ipx_pktsize __attribute__ ((packed)); unsigned char ipx_tctrl; unsigned char ipx_type; #define IPX_TYPE_UNKNOWN 0x00 @@ -44,7 +46,7 @@ typedef struct ipx_packet typedef struct sock ipx_socket; -#include "ipxcall.h" +#include <net/ipxcall.h> extern int ipx_rcv(struct sk_buff *skb, struct device *dev, struct packet_type *pt); extern void ipxrtr_device_down(struct device *dev); diff --git a/include/net/ndisc.h b/include/net/ndisc.h new file mode 100644 index 000000000..3605997e7 --- /dev/null +++ b/include/net/ndisc.h @@ -0,0 +1,184 @@ +#ifndef _NDISC_H +#define _NDISC_H + + +/* + * Neighbor Cache Entry States (7.3.2.) + */ + +/* + * The lsb is set for states that have a timer associated + */ + +#define NUD_NONE 0x00 +#define NUD_INCOMPLETE 0x11 +#define NUD_REACHABLE 0x20 +#define NUD_STALE 0x30 +#define NUD_DELAY 0x41 +#define NUD_PROBE 0x51 +#define NUD_FAILED 0x60 /* neighbour discovery failed */ + +#define NUD_IN_TIMER 0x01 + +#define NDISC_QUEUE_LEN 3 + +#define NCF_NOARP 0x01 /* no ARP needed on this device */ +#define NCF_SUBNET 0x02 /* NC entry for subnet */ +#define NCF_INVALID 0x04 +#define NCF_DELAY_EXPIRED 0x08 /* time to move to PROBE */ +#define NCF_ROUTER 0x10 /* neighbour is a router */ +#define NCF_HHVALID 0x20 /* Hardware header is valid */ + +/* + * ICMP codes for neighbour discovery messages + */ + +#define NDISC_ROUTER_SOLICITATION 133 +#define NDISC_ROUTER_ADVERTISEMENT 134 +#define NDISC_NEIGHBOUR_SOLICITATION 135 +#define NDISC_NEIGHBOUR_ADVERTISEMENT 136 +#define NDISC_REDIRECT 137 + +/* + * ndisc options + */ + +#define ND_OPT_SOURCE_LL_ADDR 1 +#define ND_OPT_TARGET_LL_ADDR 2 +#define ND_OPT_PREFIX_INFO 3 +#define ND_OPT_REDIRECT_HDR 4 +#define ND_OPT_MTU 5 + +#define MAX_RTR_SOLICITATION_DELAY HZ + +#define RECHABLE_TIME (30*HZ) +#define RETRANS_TIMER HZ + +#define MIN_RANDOM_FACTOR (1/2) +#define MAX_RANDOM_FACTOR (3/2) + +#define REACH_RANDOM_INTERVAL (60*60*HZ) /* 1 hour */ + +#ifdef __KERNEL__ + +#include <linux/skbuff.h> +#include <linux/netdevice.h> +#include <linux/icmpv6.h> +#include <asm/atomic.h> + +/* + * neighbour cache entry + * used by neighbour discovery module + * as similar functions of "struct hh_cache" used in ipv4 + */ +struct neighbour { + struct in6_addr addr; /* next hop addr */ + __u8 len; /* prefix len */ + __u8 type; /* {unicast, multicast} */ + + struct device * dev; + + __u8 flags; + + + __u8 hh_data[MAX_ADDR_LEN]; /* cached hdr */ + __u8 *h_dest; /* dest addr */ + + struct sk_buff_head arp_queue; /* packets waiting for ND to + finish */ + atomic_t refcnt; + __u8 nud_state; + __u8 probes; + __u32 tstamp; /* last reachable conf */ + + unsigned long expires; /* timer expires at */ + + struct neighbour *next; /* for hash chaining */ + struct neighbour *prev; /* for hash chaining */ +}; + +struct nd_msg { + struct icmpv6hdr icmph; + struct in6_addr target; + struct { + __u8 opt_type; + __u8 opt_len; + __u8 link_addr[MAX_ADDR_LEN]; + } opt; +}; + +struct ra_msg { + struct icmpv6hdr icmph; + __u32 reachable_time; + __u32 retrans_timer; +}; + +struct ndisc_statistics { + __u32 allocs; /* allocated entries */ + __u32 free_delayed; /* zombie entries */ + __u32 snt_probes_ucast; /* ns probes sent (ucast) */ + __u32 snt_probes_mcast; /* ns probes sent (mcast) */ + __u32 rcv_probes_ucast; /* ns probes rcv (ucast) */ + __u32 rcv_probes_mcast; /* ns probes rcv (mcast) */ + __u32 rcv_upper_conf; /* confirmations from upper layers */ + __u32 res_failed; /* address resolution failures */ +}; + +extern struct neighbour * ndisc_get_neigh(struct device *dev, + struct in6_addr *addr); + +extern void ndisc_validate(struct neighbour *neigh); + +extern void ndisc_init(struct proto_ops *ops); +extern void ndisc_cleanup(void); + +extern int ndisc_eth_resolv(unsigned char *, + struct device *, + struct sk_buff *); + +extern int ndisc_rcv(struct sk_buff *skb, + struct device *dev, + struct in6_addr *saddr, + struct in6_addr *daddr, + struct ipv6_options *opt, + unsigned short len); + +extern void ndisc_event_send(struct neighbour *neigh, + struct sk_buff *skb); + +extern void ndisc_send_ns(struct device *dev, + struct neighbour *neigh, + struct in6_addr *solicit, + struct in6_addr *daddr, + struct in6_addr *saddr); + +extern void ndisc_send_rs(struct device *dev, + struct in6_addr *saddr, + struct in6_addr *daddr); + +extern int (*ndisc_eth_hook) (unsigned char *, + struct device *, + struct sk_buff *); + +extern void ndisc_forwarding_on(void); +extern void ndisc_forwarding_off(void); + +extern void ndisc_send_redirect(struct sk_buff *skb, + struct neighbour *neigh, + struct in6_addr *target); + +struct rt6_info * dflt_rt_lookup(void); + +extern unsigned long nd_rand_seed; +extern int ipv6_random(void); + + +static __inline__ void ndisc_dec_neigh(struct neighbour *neigh) +{ + atomic_dec(&neigh->refcnt); +} + +#endif /* __KERNEL__ */ + + +#endif diff --git a/include/net/netlink.h b/include/net/netlink.h new file mode 100644 index 000000000..f0b9c9d74 --- /dev/null +++ b/include/net/netlink.h @@ -0,0 +1,35 @@ +#ifndef __NET_NETLINK_H +#define __NET_NETLINK_H + +#define NET_MAJOR 36 /* Major 18 is reserved for networking */ +#define MAX_LINKS 16 /* 18,0 for route updates, 18,1 for SKIP, 18,2 debug tap 18,3 PPP reserved */ + /* 4-7 are psi0-psi3 8 is arpd 9 is ppp */ + /* 10 is for IPSEC <John Ioannidis> */ + /* 11 IPv6 route updates */ + /* 12 is for firewall trapout */ +#define MAX_QBYTES 32768 /* Maximum bytes in the queue */ + +#include <linux/config.h> + +extern int netlink_attach(int unit, int (*function)(int,struct sk_buff *skb)); +extern int netlink_donothing(int, struct sk_buff *skb); +extern void netlink_detach(int unit); +extern int netlink_post(int unit, struct sk_buff *skb); +extern int init_netlink(void); + +#define NETLINK_ROUTE 0 /* Routing/device hook */ +#define NETLINK_SKIP 1 /* Reserved for ENskip */ +#define NETLINK_USERSOCK 2 /* Reserved for user mode socket protocols */ +#define NETLINK_FIREWALL 3 /* Firewalling hook */ +#define NETLINK_PSI 4 /* PSI devices - 4 to 7 */ +#define NETLINK_ARPD 8 +#define NETLINK_IPSEC 10 /* IPSEC */ +#define NETLINK_ROUTE6 11 /* af_inet6 route comm channel */ +#define NETLINK_ + +#ifdef CONFIG_RTNETLINK +extern void ip_netlink_msg(unsigned long, __u32, __u32, __u32, short, short, char *); +#else +#define ip_netlink_msg(a,b,c,d,e,f,g) +#endif +#endif diff --git a/include/net/netrom.h b/include/net/netrom.h index c6f772920..ce398d23c 100644 --- a/include/net/netrom.h +++ b/include/net/netrom.h @@ -7,6 +7,12 @@ #ifndef _NETROM_H #define _NETROM_H #include <linux/netrom.h> + +#define NR_T1CLAMPLO (1 * PR_SLOWHZ) /* If defined, clamp at 1 second **/ +#define NR_T1CLAMPHI (300 * PR_SLOWHZ) /* If defined, clamp at 30 seconds **/ + +#define NR_NETWORK_LEN 15 +#define NR_TRANSPORT_LEN 5 #define NR_PROTO_IP 0x0C @@ -29,35 +35,51 @@ #define NR_STATE_2 2 #define NR_STATE_3 3 -#define NR_DEFAULT_T1 (120 * PR_SLOWHZ) /* Outstanding frames - 10 seconds */ -#define NR_DEFAULT_T2 (5 * PR_SLOWHZ) /* Response delay - 3 seconds */ -#define NR_DEFAULT_N2 3 /* Number of Retries */ -#define NR_DEFAULT_T4 (180 * PR_SLOWHZ) /* Transport Busy Delay */ -#define NR_DEFAULT_WINDOW 4 /* Default Window Size */ -#define NR_DEFAULT_OBS 6 /* Default Obscolesence Count */ -#define NR_DEFAULT_QUAL 10 /* Default Neighbour Quality */ -#define NR_DEFAULT_TTL 16 /* Default Time To Live */ +#define NR_DEFAULT_T1 (120 * PR_SLOWHZ) /* Outstanding frames - 120 seconds */ +#define NR_DEFAULT_T2 (5 * PR_SLOWHZ) /* Response delay - 5 seconds */ +#define NR_DEFAULT_N2 3 /* Number of Retries - 3 */ +#define NR_DEFAULT_T4 (180 * PR_SLOWHZ) /* Busy Delay - 180 seconds */ +#define NR_DEFAULT_IDLE (20* 60 * PR_SLOWHZ) /* No Activuty Timeout - 900 seconds*/ +#define NR_DEFAULT_WINDOW 4 /* Default Window Size - 4 */ +#define NR_DEFAULT_OBS 6 /* Default Obsolescence Count - 6 */ +#define NR_DEFAULT_QUAL 10 /* Default Neighbour Quality - 10 */ +#define NR_DEFAULT_TTL 16 /* Default Time To Live - 16 */ #define NR_MODULUS 256 -#define NR_MAX_WINDOW_SIZE 127 /* Maximum Window Allowable */ +#define NR_MAX_WINDOW_SIZE 127 /* Maximum Window Allowable - 127 */ +#define NR_DEFAULT_PACLEN 236 /* Default Packet Length - 236 */ typedef struct { ax25_address user_addr, source_addr, dest_addr; - unsigned char my_index, my_id; - unsigned char your_index, your_id; - unsigned char state; + struct device *device; + unsigned char my_index, my_id; + unsigned char your_index, your_id; + unsigned char state, condition, bpqext, hdrincl; unsigned short vs, vr, va, vl; - unsigned char condition; unsigned char n2, n2count; - unsigned short t1, t2, rtt; - unsigned short t1timer, t2timer, t4timer; - struct sk_buff_head ack_queue, reseq_queue; + unsigned short t1, t2, t4, idle, rtt; + unsigned short t1timer, t2timer, t4timer, idletimer; + unsigned short fraglen, paclen; + struct sk_buff_head ack_queue; + struct sk_buff_head reseq_queue; + struct sk_buff_head frag_queue; struct sock *sk; /* Backlink to socket */ } nr_cb; +struct nr_neigh { + struct nr_neigh *next; + ax25_address callsign; + ax25_digi *digipeat; + struct device *dev; + unsigned char quality; + unsigned char locked; + unsigned short count; + unsigned int number; +}; + struct nr_route { - unsigned char quality; - unsigned char obs_count; - unsigned short neighbour; + unsigned char quality; + unsigned char obs_count; + struct nr_neigh *neighbour; }; struct nr_node { @@ -69,37 +91,35 @@ struct nr_node { struct nr_route routes[3]; }; -struct nr_neigh { - struct nr_neigh *next; - ax25_address callsign; - struct device *dev; - unsigned char quality; - unsigned char locked; - unsigned short count; - unsigned short number; -}; - -/* netrom.c */ -extern struct nr_parms_struct nr_default; +/* af_netrom.c */ +extern int sysctl_netrom_default_path_quality; +extern int sysctl_netrom_obsolescence_count_initialiser; +extern int sysctl_netrom_network_ttl_initialiser; +extern int sysctl_netrom_transport_timeout; +extern int sysctl_netrom_transport_maximum_tries; +extern int sysctl_netrom_transport_acknowledge_delay; +extern int sysctl_netrom_transport_busy_delay; +extern int sysctl_netrom_transport_requested_window_size; +extern int sysctl_netrom_transport_no_activity_timeout; +extern int sysctl_netrom_transport_packet_length; +extern int sysctl_netrom_routing_control; extern int nr_rx_frame(struct sk_buff *, struct device *); extern void nr_destroy_socket(struct sock *); -extern int nr_get_info(char *, char **, off_t, int); /* nr_dev.c */ extern int nr_rx_ip(struct sk_buff *, struct device *); extern int nr_init(struct device *); -#include "nrcall.h" +#include <net/nrcall.h> /* nr_in.c */ extern int nr_process_rx_frame(struct sock *, struct sk_buff *); /* nr_out.c */ -extern int nr_output(struct sock *, struct sk_buff *); +extern void nr_output(struct sock *, struct sk_buff *); extern void nr_send_nak_frame(struct sock *); extern void nr_kick(struct sock *); extern void nr_transmit_buffer(struct sock *, struct sk_buff *); -extern void nr_nr_error_recovery(struct sock *); extern void nr_establish_data_link(struct sock *); extern void nr_enquiry_response(struct sock *); extern void nr_check_iframes_acked(struct sock *, unsigned short); @@ -110,12 +130,13 @@ extern struct device *nr_dev_first(void); extern struct device *nr_dev_get(ax25_address *); extern int nr_rt_ioctl(unsigned int, void *); extern void nr_link_failed(ax25_address *, struct device *); -extern int nr_route_frame(struct sk_buff *, struct device *); -extern int nr_nodes_get_info(char *, char **, off_t, int); -extern int nr_neigh_get_info(char *, char **, off_t, int); +extern int nr_route_frame(struct sk_buff *, ax25_cb *); +extern int nr_nodes_get_info(char *, char **, off_t, int, int); +extern int nr_neigh_get_info(char *, char **, off_t, int, int); +extern void nr_rt_free(void); /* nr_subr.c */ -extern void nr_clear_tx_queue(struct sock *); +extern void nr_clear_queues(struct sock *); extern void nr_frames_acked(struct sock *, unsigned short); extern void nr_requeue_frames(struct sock *); extern int nr_validate_nr(struct sock *, unsigned short); @@ -125,7 +146,11 @@ extern void nr_transmit_dm(struct sk_buff *); extern unsigned short nr_calculate_t1(struct sock *); extern void nr_calculate_rtt(struct sock *); -/* ax25_timer */ +/* nr_timer.c */ extern void nr_set_timer(struct sock *); +/* sysctl_net_netrom.c */ +extern void nr_register_sysctl(void); +extern void nr_unregister_sysctl(void); + #endif diff --git a/include/net/nrcall.h b/include/net/nrcall.h index f58c2d4fe..09ee699d8 100644 --- a/include/net/nrcall.h +++ b/include/net/nrcall.h @@ -1,2 +1,2 @@ -/* Seperate to keep compilation of protocols.c simpler */ +/* Separate to keep compilation of protocols.c simpler */ extern void nr_proto_init(struct net_proto *pro); diff --git a/include/net/p8022.h b/include/net/p8022.h index 52c676be2..03d7c3d66 100644 --- a/include/net/p8022.h +++ b/include/net/p8022.h @@ -1,2 +1,7 @@ -struct datalink_proto *register_8022_client(unsigned char type, int (*rcvfunc)(struct sk_buff *, struct device *, struct packet_type *)); +#ifndef _NET_P8022_H +#define _NET_P8022_H +extern struct datalink_proto *register_8022_client(unsigned char type, int (*rcvfunc)(struct sk_buff *, struct device *, struct packet_type *)); +extern void unregister_8022_client(unsigned char type); + +#endif diff --git a/include/net/p8022tr.h b/include/net/p8022tr.h new file mode 100644 index 000000000..f4231ecee --- /dev/null +++ b/include/net/p8022tr.h @@ -0,0 +1,8 @@ +#ifndef _NET_P8022TR_H +#define _NET_P8022TR_H + +extern struct datalink_proto *register_8022tr_client(unsigned char type, int (*rcvfunc)(struct sk_buff *, struct device *, struct packet_type *)); +extern void unregister_8022tr_client(unsigned char type); + +#endif + diff --git a/include/net/p8022trcall.h b/include/net/p8022trcall.h new file mode 100644 index 000000000..3ce6f3cdb --- /dev/null +++ b/include/net/p8022trcall.h @@ -0,0 +1,3 @@ +/* Separate to keep compilation of Space.c simpler */ +extern void p8022tr_proto_init(struct net_proto *); + diff --git a/include/net/protocol.h b/include/net/protocol.h index 3e0b6fb3c..979298832 100644 --- a/include/net/protocol.h +++ b/include/net/protocol.h @@ -17,11 +17,18 @@ * Changes: * Alan Cox : Added a name field and a frag handler * field for later. + * Alan Cox : Cleaned up, and sorted types. + * Pedro Roque : inet6 protocols */ #ifndef _PROTOCOL_H #define _PROTOCOL_H +#include <linux/config.h> +#include <linux/in6.h> +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) +#include <linux/ipv6.h> +#endif #define MAX_INET_PROTOS 32 /* Must be a power of 2 */ @@ -29,31 +36,54 @@ /* This is used to register protocols. */ struct inet_protocol { int (*handler)(struct sk_buff *skb, struct device *dev, - struct options *opt, unsigned long daddr, - unsigned short len, unsigned long saddr, + struct options *opt, __u32 daddr, + unsigned short len, __u32 saddr, int redo, struct inet_protocol *protocol); - int (*frag_handler)(struct sk_buff *skb, struct device *dev, - struct options *opt, unsigned long daddr, - unsigned short len, unsigned long saddr, - int redo, struct inet_protocol *protocol); - void (*err_handler)(int err, unsigned char *buff, - unsigned long daddr, - unsigned long saddr, - struct inet_protocol *protocol); + void (*err_handler)(int type, int code, unsigned char *buff, + __u32 info, __u32 daddr, __u32 saddr, + struct inet_protocol *protocol, int len); struct inet_protocol *next; unsigned char protocol; unsigned char copy:1; void *data; - char *name; + const char *name; }; +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) +struct inet6_protocol { + int (*handler)(struct sk_buff *skb, struct device *dev, + struct in6_addr *saddr, + struct in6_addr *daddr, + struct ipv6_options *opt, + unsigned short len, + int redo, struct inet6_protocol *protocol); + + void (*err_handler)(int type, int code, unsigned char *buff, + __u32 info, struct in6_addr *saddr, + struct in6_addr *daddr, + struct inet6_protocol *protocol); + struct inet6_protocol *next; + unsigned char protocol; + unsigned char copy:1; + void *data; + const char *name; +}; +#endif extern struct inet_protocol *inet_protocol_base; extern struct inet_protocol *inet_protos[MAX_INET_PROTOS]; +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) +extern struct inet6_protocol *inet6_protocol_base; +extern struct inet6_protocol *inet6_protos[MAX_INET_PROTOS]; +#endif extern void inet_add_protocol(struct inet_protocol *prot); extern int inet_del_protocol(struct inet_protocol *prot); +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) +extern void inet6_add_protocol(struct inet6_protocol *prot); +extern int inet6_del_protocol(struct inet6_protocol *prot); +#endif #endif /* _PROTOCOL_H */ diff --git a/include/net/psnap.h b/include/net/psnap.h index b69859dbd..49a68f7e9 100644 --- a/include/net/psnap.h +++ b/include/net/psnap.h @@ -1,2 +1,7 @@ -struct datalink_proto *register_snap_client(unsigned char *desc, int (*rcvfunc)(struct sk_buff *, struct device *, struct packet_type *)); +#ifndef _NET_PSNAP_H +#define _NET_PSNAP_H +extern struct datalink_proto *register_snap_client(unsigned char *desc, int (*rcvfunc)(struct sk_buff *, struct device *, struct packet_type *)); +extern void unregister_snap_client(unsigned char *desc); + +#endif diff --git a/include/net/rarp.h b/include/net/rarp.h index 02ee7784f..7bfb08ef1 100644 --- a/include/net/rarp.h +++ b/include/net/rarp.h @@ -3,12 +3,10 @@ #define _RARP_H extern int rarp_ioctl(unsigned int cmd, void *arg); -extern int rarp_rcv(struct sk_buff *skb, - struct device *dev, - struct packet_type *pt); extern int rarp_get_info(char *buffer, char **start, off_t offset, - int length); + int length, + int dummy); #endif /* _RARP_H */ diff --git a/include/net/raw.h b/include/net/raw.h index 8f1cf0c22..4b4248790 100644 --- a/include/net/raw.h +++ b/include/net/raw.h @@ -21,14 +21,14 @@ extern struct proto raw_prot; -extern void raw_err(int err, unsigned char *header, unsigned long daddr, - unsigned long saddr, struct inet_protocol *protocol); +extern void raw_err(int type, int code, unsigned char *header, __u32 daddr, + __u32 saddr, struct inet_protocol *protocol); extern int raw_recvfrom(struct sock *sk, unsigned char *to, int len, int noblock, unsigned flags, struct sockaddr_in *sin, int *addr_len); extern int raw_read(struct sock *sk, unsigned char *buff, int len, int noblock, unsigned flags); extern int raw_rcv(struct sock *, struct sk_buff *, struct device *, - long, long); + __u32, __u32); #endif /* _RAW_H */ diff --git a/include/net/rawv6.h b/include/net/rawv6.h new file mode 100644 index 000000000..30ecc7962 --- /dev/null +++ b/include/net/rawv6.h @@ -0,0 +1,21 @@ +#ifndef _NET_RAWV6_H +#define _NET_RAWV6_H + +#ifdef __KERNEL__ +extern int rawv6_rcv(struct sk_buff *skb, + struct device *dev, + struct in6_addr *saddr, + struct in6_addr *daddr, + struct ipv6_options *opt, + unsigned short len); + + +extern void rawv6_err(struct sock *sk, + int type, int code, + unsigned char *buff, + struct in6_addr *saddr, + struct in6_addr *daddr); + +#endif + +#endif diff --git a/include/net/rose.h b/include/net/rose.h new file mode 100644 index 000000000..84d4e9654 --- /dev/null +++ b/include/net/rose.h @@ -0,0 +1,183 @@ +/* + * Declarations of Rose type objects. + * + * Jonathan Naylor G4KLX 25/8/96 + */ + +#ifndef _ROSE_H +#define _ROSE_H +#include <linux/rose.h> + +#define ROSE_ADDR_LEN 5 + +#define ROSE_MIN_LEN 3 + +#define GFI 0x10 +#define Q_BIT 0x80 +#define D_BIT 0x40 +#define M_BIT 0x10 + +#define ROSE_CALL_REQUEST 0x0B +#define ROSE_CALL_ACCEPTED 0x0F +#define ROSE_CLEAR_REQUEST 0x13 +#define ROSE_CLEAR_CONFIRMATION 0x17 +#define ROSE_DATA 0x00 +#define ROSE_INTERRUPT 0x23 +#define ROSE_INTERRUPT_CONFIRMATION 0x27 +#define ROSE_RR 0x01 +#define ROSE_RNR 0x05 +#define ROSE_REJ 0x09 +#define ROSE_RESET_REQUEST 0x1B +#define ROSE_RESET_CONFIRMATION 0x1F +#define ROSE_REGISTRATION_REQUEST 0xF3 +#define ROSE_REGISTRATION_CONFIRMATION 0xF7 +#define ROSE_RESTART_REQUEST 0xFB +#define ROSE_RESTART_CONFIRMATION 0xFF +#define ROSE_DIAGNOSTIC 0xF1 +#define ROSE_ILLEGAL 0xFD + +/* Define Link State constants. */ + +#define ROSE_STATE_0 0 /* Ready */ +#define ROSE_STATE_1 1 /* Awaiting Call Accepted */ +#define ROSE_STATE_2 2 /* Awaiting Clear Confirmation */ +#define ROSE_STATE_3 3 /* Data Transfer */ +#define ROSE_STATE_4 4 /* Awaiting Reset Confirmation */ + +#define ROSE_DEFAULT_T0 (180 * PR_SLOWHZ) /* Default T10 T20 value */ +#define ROSE_DEFAULT_T1 (200 * PR_SLOWHZ) /* Default T11 T21 value */ +#define ROSE_DEFAULT_T2 (180 * PR_SLOWHZ) /* Default T12 T22 value */ +#define ROSE_DEFAULT_T3 (180 * PR_SLOWHZ) /* Default T13 T23 value */ +#define ROSE_DEFAULT_IDLE (20 * 60 * PR_SLOWHZ) /* Default No Activity value */ +#define ROSE_DEFAULT_WINDOW 2 /* Default Window Size */ +#define ROSE_MODULUS 8 +#define ROSE_MAX_WINDOW_SIZE 7 /* Maximum Window Allowable */ +#define ROSE_PACLEN 128 /* Default Packet Length */ + +#define FAC_NATIONAL 0x00 +#define FAC_CCITT 0x0F + +#define FAC_NATIONAL_RAND 0x7F +#define FAC_NATIONAL_FLAGS 0x3F +#define FAC_NATIONAL_DEST_DIGI 0xE9 +#define FAC_NATIONAL_SRC_DIGI 0xEB + +#define FAC_CCITT_DEST_NSAP 0xC9 +#define FAC_CCITT_SRC_NSAP 0xCB + +struct rose_neigh { + struct rose_neigh *next; + ax25_address callsign; + ax25_digi *digipeat; + struct device *dev; + unsigned short count; + unsigned int number; + int restarted; + struct sk_buff_head queue; + unsigned short t0, t0timer; + struct timer_list timer; +}; + +struct rose_node { + struct rose_node *next; + rose_address address; + unsigned char which; + unsigned char count; + struct rose_neigh *neighbour[3]; +}; + +struct rose_route { + struct rose_route *next; + unsigned int lci1, lci2; + struct rose_neigh *neigh1, *neigh2; + unsigned int rand; +}; + +typedef struct { + rose_address source_addr, dest_addr; + ax25_address source_call, dest_call; + unsigned char source_ndigis, dest_ndigis; + ax25_address source_digi, dest_digi; + struct rose_neigh *neighbour; + struct device *device; + unsigned int lci, rand; + unsigned char state, condition, hdrincl; + unsigned short vs, vr, va, vl; + unsigned short timer; + unsigned short t1, t2, t3, idle; + unsigned short fraglen; + struct sk_buff_head ack_queue; + struct sk_buff_head frag_queue; + struct sock *sk; /* Backlink to socket */ +} rose_cb; + +/* af_rose.c */ +extern int sysctl_rose_restart_request_timeout; +extern int sysctl_rose_call_request_timeout; +extern int sysctl_rose_reset_request_timeout; +extern int sysctl_rose_clear_request_timeout; +extern int sysctl_rose_no_activity_timeout; +extern int sysctl_rose_routing_control; +extern int rosecmp(rose_address *, rose_address *); +extern char *rose2asc(rose_address *); +extern struct sock *rose_find_socket(unsigned int, struct device *); +extern unsigned int rose_new_lci(struct device *); +extern int rose_rx_call_request(struct sk_buff *, struct device *, struct rose_neigh *, unsigned int); +extern void rose_destroy_socket(struct sock *); + +/* rose_dev.c */ +extern int rose_rx_ip(struct sk_buff *, struct device *); +extern int rose_init(struct device *); + +#include <net/rosecall.h> + +/* rose_in.c */ +extern int rose_process_rx_frame(struct sock *, struct sk_buff *); + +/* rose_link.c */ +extern void rose_link_rx_restart(struct sk_buff *, struct rose_neigh *, unsigned short); +extern void rose_transmit_restart_request(struct rose_neigh *); +extern void rose_transmit_restart_confirmation(struct rose_neigh *); +extern void rose_transmit_diagnostic(struct rose_neigh *, unsigned char); +extern void rose_transmit_clear_request(struct rose_neigh *, unsigned int, unsigned char); +extern void rose_transmit_link(struct sk_buff *, struct rose_neigh *); + +/* rose_out.c */ +extern void rose_output(struct sock *, struct sk_buff *); +extern void rose_kick(struct sock *); +extern void rose_enquiry_response(struct sock *); +extern void rose_check_iframes_acked(struct sock *, unsigned short); + +/* rose_route.c */ +extern void rose_rt_device_down(struct device *); +extern void rose_link_device_down(struct device *); +extern struct device *rose_dev_first(void); +extern struct device *rose_dev_get(rose_address *); +extern struct device *rose_ax25_dev_get(char *); +extern struct rose_neigh *rose_get_neigh(rose_address *); +extern int rose_rt_ioctl(unsigned int, void *); +extern void rose_link_failed(ax25_address *, struct device *); +extern int rose_route_frame(struct sk_buff *, ax25_cb *); +extern int rose_nodes_get_info(char *, char **, off_t, int, int); +extern int rose_neigh_get_info(char *, char **, off_t, int, int); +extern int rose_routes_get_info(char *, char **, off_t, int, int); +extern void rose_rt_free(void); + +/* rose_subr.c */ +extern void rose_clear_queues(struct sock *); +extern void rose_frames_acked(struct sock *, unsigned short); +extern void rose_requeue_frames(struct sock *); +extern int rose_validate_nr(struct sock *, unsigned short); +extern void rose_write_internal(struct sock *, int); +extern int rose_decode(struct sk_buff *, int *, int *, int *, int *, int *); +extern int rose_parse_facilities(struct sk_buff *, rose_cb *); +extern int rose_create_facilities(unsigned char *, rose_cb *); + +/* rose_timer.c */ +extern void rose_set_timer(struct sock *); + +/* sysctl_net_rose.c */ +extern void rose_register_sysctl(void); +extern void rose_unregister_sysctl(void); + +#endif diff --git a/include/net/rosecall.h b/include/net/rosecall.h new file mode 100644 index 000000000..5bbe69cce --- /dev/null +++ b/include/net/rosecall.h @@ -0,0 +1,2 @@ +/* Separate to keep compilation of protocols.c simpler */ +extern void rose_proto_init(struct net_proto *pro); diff --git a/include/net/route.h b/include/net/route.h index d85fefdcd..de59bda48 100644 --- a/include/net/route.h +++ b/include/net/route.h @@ -12,6 +12,10 @@ * Fixes: * Alan Cox : Reformatted. Added ip_rt_local() * Alan Cox : Support for TCP parameters. + * Alexey Kuznetsov: Major changes for new routing code. + * + * FIXME: + * Make atomic ops more generic and hide them in asm/... * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -21,36 +25,153 @@ #ifndef _ROUTE_H #define _ROUTE_H +#include <linux/config.h> + +/* + * 0 - no debugging messages + * 1 - rare events and bugs situations (default) + * 2 - trace mode. + */ +#define RT_CACHE_DEBUG 0 + +#define RT_HASH_DIVISOR 256 +#define RT_CACHE_SIZE_MAX 256 + +#define RTZ_HASH_DIVISOR 256 + +#if RT_CACHE_DEBUG >= 2 +#define RTZ_HASHING_LIMIT 0 +#else +#define RTZ_HASHING_LIMIT 16 +#endif + +/* + * Maximal time to live for unused entry. + */ +#define RT_CACHE_TIMEOUT (HZ*300) + +/* + * Prevents LRU trashing, entries considered equivalent, + * if the difference between last use times is less then this number. + */ +#define RT_CACHE_BUBBLE_THRESHOLD (HZ*5) #include <linux/route.h> +#ifdef __KERNEL__ +#define RTF_LOCAL 0x8000 +#endif -/* This is an entry in the IP routing table. */ struct rtable { struct rtable *rt_next; - unsigned long rt_dst; - unsigned long rt_mask; - unsigned long rt_gateway; - unsigned char rt_flags; - unsigned char rt_metric; - short rt_refcnt; - unsigned long rt_use; - unsigned short rt_mss; - unsigned short rt_irtt; + __u32 rt_dst; + __u32 rt_src; + __u32 rt_gateway; + atomic_t rt_refcnt; + atomic_t rt_use; unsigned long rt_window; + atomic_t rt_lastuse; + struct hh_cache *rt_hh; struct device *rt_dev; + unsigned short rt_flags; + unsigned short rt_mtu; + unsigned short rt_irtt; + unsigned char rt_tos; }; - extern void ip_rt_flush(struct device *dev); -extern void ip_rt_add(short flags, unsigned long addr, unsigned long mask, - unsigned long gw, struct device *dev, unsigned short mss, unsigned long window, unsigned short irtt); -extern struct rtable *ip_rt_route(unsigned long daddr, struct options *opt, unsigned long *src_addr); -extern struct rtable *ip_rt_local(unsigned long daddr, struct options *opt, unsigned long *src_addr); -extern int rt_get_info(char * buffer, char **start, off_t offset, int length); +extern void ip_rt_update(int event, struct device *dev); +extern void ip_rt_redirect(__u32 src, __u32 dst, __u32 gw, struct device *dev); +extern struct rtable *ip_rt_slow_route(__u32 daddr, int local); +extern int rt_get_info(char * buffer, char **start, off_t offset, int length, int dummy); +extern int rt_cache_get_info(char *buffer, char **start, off_t offset, int length, int dummy); extern int ip_rt_ioctl(unsigned int cmd, void *arg); +extern int ip_rt_new(struct rtentry *rt); +extern int ip_rt_kill(struct rtentry *rt); +extern void ip_rt_check_expire(void); +extern void ip_rt_advice(struct rtable **rp, int advice); + +extern void ip_rt_run_bh(void); +extern atomic_t ip_rt_lock; +extern unsigned ip_rt_bh_mask; +extern struct rtable *ip_rt_hash_table[RT_HASH_DIVISOR]; + +extern __inline__ void ip_rt_fast_lock(void) +{ + atomic_inc(&ip_rt_lock); +} + +extern __inline__ void ip_rt_fast_unlock(void) +{ + atomic_dec(&ip_rt_lock); +} + +extern __inline__ void ip_rt_unlock(void) +{ + if (atomic_dec_and_test(&ip_rt_lock) && ip_rt_bh_mask) + ip_rt_run_bh(); +} + +extern __inline__ unsigned ip_rt_hash_code(__u32 addr) +{ + unsigned tmp = addr + (addr>>16); + return (tmp + (tmp>>8)) & 0xFF; +} + + +extern __inline__ void ip_rt_put(struct rtable * rt) +#ifndef MODULE +{ + if (rt) + atomic_dec(&rt->rt_refcnt); +} +#else +; +#endif + +#ifdef CONFIG_KERNELD +extern struct rtable * ip_rt_route(__u32 daddr, int local); +#else +extern __inline__ struct rtable * ip_rt_route(__u32 daddr, int local) +#ifndef MODULE +{ + struct rtable * rth; + + ip_rt_fast_lock(); + + for (rth=ip_rt_hash_table[ip_rt_hash_code(daddr)^local]; rth; rth=rth->rt_next) + { + if (rth->rt_dst == daddr) + { + rth->rt_lastuse = jiffies; + atomic_inc(&rth->rt_use); + atomic_inc(&rth->rt_refcnt); + ip_rt_unlock(); + return rth; + } + } + return ip_rt_slow_route (daddr, local); +} +#else +; +#endif +#endif + +extern __inline__ struct rtable * ip_check_route(struct rtable ** rp, + __u32 daddr, int local) +{ + struct rtable * rt = *rp; + + if (!rt || rt->rt_dst != daddr || !(rt->rt_flags&RTF_UP) + || ((local==1)^((rt->rt_flags&RTF_LOCAL) != 0))) + { + ip_rt_put(rt); + rt = ip_rt_route(daddr, local); + *rp = rt; + } + return rt; +} -extern unsigned long rt_stamp; #endif /* _ROUTE_H */ diff --git a/include/net/sit.h b/include/net/sit.h new file mode 100644 index 000000000..98bb5b386 --- /dev/null +++ b/include/net/sit.h @@ -0,0 +1,39 @@ +/* + * SIT tunneling device - definitions + * Linux INET6 implementation + * + * Authors: + * Pedro Roque <roque@di.fc.ul.pt> + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ + +#ifndef _NET_SIT_H +#define _NET_SIT_H + +struct sit_mtu_info { + __u32 addr; /* IPv4 destination */ + unsigned long tstamp; /* last use tstamp */ + __u32 mtu; /* Path MTU */ + struct sit_mtu_info *next; +}; + +struct sit_vif { + char name[8]; + struct device *dev; + struct sit_vif *next; +}; + +extern int sit_init(void); +extern void sit_cleanup(void); + +extern struct device * sit_add_tunnel(__u32 dstaddr); + +#define SIT_GC_TIMEOUT (3*60*HZ) +#define SIT_GC_FREQUENCY (2*60*HZ) + +#endif diff --git a/include/net/slhc.h b/include/net/slhc.h new file mode 100644 index 000000000..c7b39db55 --- /dev/null +++ b/include/net/slhc.h @@ -0,0 +1,6 @@ +#ifndef __NET_SLHC_H +#define __NET_SLHC_H + +extern void slhc_install(void); + +#endif diff --git a/include/net/slhc_vj.h b/include/net/slhc_vj.h new file mode 100644 index 000000000..387b848d8 --- /dev/null +++ b/include/net/slhc_vj.h @@ -0,0 +1,187 @@ +#ifndef _SLHC_H +#define _SLHC_H +/* + * Definitions for tcp compression routines. + * + * $Header: slcompress.h,v 1.10 89/12/31 08:53:02 van Exp $ + * + * Copyright (c) 1989 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989: + * - Initial distribution. + * + * + * modified for KA9Q Internet Software Package by + * Katie Stevens (dkstevens@ucdavis.edu) + * University of California, Davis + * Computing Services + * - 01-31-90 initial adaptation + * + * - Feb 1991 Bill_Simpson@um.cc.umich.edu + * variable number of conversation slots + * allow zero or one slots + * separate routines + * status display + */ + +/* + * Compressed packet format: + * + * The first octet contains the packet type (top 3 bits), TCP + * 'push' bit, and flags that indicate which of the 4 TCP sequence + * numbers have changed (bottom 5 bits). The next octet is a + * conversation number that associates a saved IP/TCP header with + * the compressed packet. The next two octets are the TCP checksum + * from the original datagram. The next 0 to 15 octets are + * sequence number changes, one change per bit set in the header + * (there may be no changes and there are two special cases where + * the receiver implicitly knows what changed -- see below). + * + * There are 5 numbers which can change (they are always inserted + * in the following order): TCP urgent pointer, window, + * acknowledgment, sequence number and IP ID. (The urgent pointer + * is different from the others in that its value is sent, not the + * change in value.) Since typical use of SLIP links is biased + * toward small packets (see comments on MTU/MSS below), changes + * use a variable length coding with one octet for numbers in the + * range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the + * range 256 - 65535 or 0. (If the change in sequence number or + * ack is more than 65535, an uncompressed packet is sent.) + */ + +/* + * Packet types (must not conflict with IP protocol version) + * + * The top nibble of the first octet is the packet type. There are + * three possible types: IP (not proto TCP or tcp with one of the + * control flags set); uncompressed TCP (a normal IP/TCP packet but + * with the 8-bit protocol field replaced by an 8-bit connection id -- + * this type of packet syncs the sender & receiver); and compressed + * TCP (described above). + * + * LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and + * is logically part of the 4-bit "changes" field that follows. Top + * three bits are actual packet type. For backward compatibility + * and in the interest of conserving bits, numbers are chosen so the + * IP protocol version number (4) which normally appears in this nibble + * means "IP packet". + */ + +/* SLIP compression masks for len/vers byte */ +#define SL_TYPE_IP 0x40 +#define SL_TYPE_UNCOMPRESSED_TCP 0x70 +#define SL_TYPE_COMPRESSED_TCP 0x80 +#define SL_TYPE_ERROR 0x00 + +/* Bits in first octet of compressed packet */ +#define NEW_C 0x40 /* flag bits for what changed in a packet */ +#define NEW_I 0x20 +#define NEW_S 0x08 +#define NEW_A 0x04 +#define NEW_W 0x02 +#define NEW_U 0x01 + +/* reserved, special-case values of above */ +#define SPECIAL_I (NEW_S|NEW_W|NEW_U) /* echoed interactive traffic */ +#define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U) /* unidirectional data */ +#define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U) + +#define TCP_PUSH_BIT 0x10 + +/* + * data type and sizes conversion assumptions: + * + * VJ code KA9Q style generic + * u_char byte_t unsigned char 8 bits + * u_short int16 unsigned short 16 bits + * u_int int16 unsigned short 16 bits + * u_long unsigned long unsigned long 32 bits + * int int32 long 32 bits + */ + +typedef unsigned char byte_t; +typedef unsigned long int32; + +/* + * "state" data for each active tcp conversation on the wire. This is + * basically a copy of the entire IP/TCP header from the last packet + * we saw from the conversation together with a small identifier + * the transmit & receive ends of the line use to locate saved header. + */ +struct cstate { + byte_t cs_this; /* connection id number (xmit) */ + struct cstate *next; /* next in ring (xmit) */ + struct iphdr cs_ip; /* ip/tcp hdr from most recent packet */ + struct tcphdr cs_tcp; + unsigned char cs_ipopt[64]; + unsigned char cs_tcpopt[64]; + int cs_hsize; +}; +#define NULLSLSTATE (struct cstate *)0 + +/* + * all the state data for one serial line (we need one of these per line). + */ +struct slcompress { + struct cstate *tstate; /* transmit connection states (array)*/ + struct cstate *rstate; /* receive connection states (array)*/ + + byte_t tslot_limit; /* highest transmit slot id (0-l)*/ + byte_t rslot_limit; /* highest receive slot id (0-l)*/ + + byte_t xmit_oldest; /* oldest xmit in ring */ + byte_t xmit_current; /* most recent xmit id */ + byte_t recv_current; /* most recent rcvd id */ + + byte_t flags; +#define SLF_TOSS 0x01 /* tossing rcvd frames until id received */ + + int32 sls_o_nontcp; /* outbound non-TCP packets */ + int32 sls_o_tcp; /* outbound TCP packets */ + int32 sls_o_uncompressed; /* outbound uncompressed packets */ + int32 sls_o_compressed; /* outbound compressed packets */ + int32 sls_o_searches; /* searches for connection state */ + int32 sls_o_misses; /* times couldn't find conn. state */ + + int32 sls_i_uncompressed; /* inbound uncompressed packets */ + int32 sls_i_compressed; /* inbound compressed packets */ + int32 sls_i_error; /* inbound error packets */ + int32 sls_i_tossed; /* inbound packets tossed because of error */ + + int32 sls_i_runt; + int32 sls_i_badcheck; +}; +#define NULLSLCOMPR (struct slcompress *)0 + +#define __ARGS(x) x + +/* In slhc.c: */ +struct slcompress *slhc_init __ARGS((int rslots, int tslots)); +void slhc_free __ARGS((struct slcompress *comp)); + +int slhc_compress __ARGS((struct slcompress *comp, unsigned char *icp, + int isize, unsigned char *ocp, unsigned char **cpp, + int compress_cid)); +int slhc_uncompress __ARGS((struct slcompress *comp, unsigned char *icp, + int isize)); +int slhc_remember __ARGS((struct slcompress *comp, unsigned char *icp, + int isize)); +int slhc_toss __ARGS((struct slcompress *comp)); + +void slhc_i_status __ARGS((struct slcompress *comp)); +void slhc_o_status __ARGS((struct slcompress *comp)); + +#endif /* _SLHC_H */ diff --git a/include/net/snmp.h b/include/net/snmp.h index 552292be6..a9dd844d1 100644 --- a/include/net/snmp.h +++ b/include/net/snmp.h @@ -48,6 +48,26 @@ struct ip_mib unsigned long IpFragCreates; }; +struct ipv6_mib +{ + unsigned long Ip6InReceives; + unsigned long Ip6InHdrErrors; + unsigned long Ip6InAddrErrors; + unsigned long Ip6ForwDatagrams; + unsigned long Ip6InUnknownProtos; + unsigned long Ip6InDiscards; + unsigned long Ip6InDelivers; + unsigned long Ip6OutRequests; + unsigned long Ip6OutDiscards; + unsigned long Ip6OutNoRoutes; + unsigned long Ip6ReasmTimeout; + unsigned long Ip6ReasmReqds; + unsigned long Ip6ReasmOKs; + unsigned long Ip6ReasmFails; + unsigned long Ip6FragOKs; + unsigned long Ip6FragFails; + unsigned long Ip6FragCreates; +}; struct icmp_mib { diff --git a/include/net/sock.h b/include/net/sock.h index be7c84591..eeb364159 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -21,6 +21,7 @@ * a socket is reset and must stay shut up * Alan Cox : New fields for options * Pauline Middelink : identd support + * Alan Cox : Eliminate low level recv/recvfrom * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -30,57 +31,289 @@ #ifndef _SOCK_H #define _SOCK_H +#include <linux/config.h> #include <linux/timer.h> #include <linux/ip.h> /* struct options */ #include <linux/in.h> /* struct sockaddr_in */ + +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) +#include <linux/in6.h> /* struct sockaddr_in6 */ +#include <linux/ipv6.h> /* dest_cache, inet6_options */ +#include <linux/icmpv6.h> +#include <net/if_inet6.h> /* struct ipv6_mc_socklist */ +#endif + #include <linux/tcp.h> /* struct tcphdr */ #include <linux/config.h> +#include <linux/netdevice.h> #include <linux/skbuff.h> /* struct sk_buff */ -#include "protocol.h" /* struct inet_protocol */ -#ifdef CONFIG_AX25 -#include "ax25.h" -#ifdef CONFIG_NETROM -#include "netrom.h" +#include <net/protocol.h> /* struct inet_protocol */ +#if defined(CONFIG_X25) || defined(CONFIG_X25_MODULE) +#/* notyet */include <net/x25.h> +#endif +#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE) +#include <net/ax25.h> +#if defined(CONFIG_NETROM) || defined(CONFIG_NETROM_MODULE) +#include <net/netrom.h> #endif +#if defined(CONFIG_ROSE) || defined(CONFIG_ROSE_MODULE) +#include <net/rose.h> #endif -#ifdef CONFIG_IPX -#include "ipx.h" #endif -#ifdef CONFIG_ATALK -#include "atalk.h" + +#if defined(CONFIG_IPX) || defined(CONFIG_IPX_MODULE) +#include <net/ipx.h> +#endif + +#if defined(CONFIG_ATALK) || defined(CONFIG_ATALK_MODULE) +#include <linux/atalk.h> #endif #include <linux/igmp.h> -#define SOCK_ARRAY_SIZE 256 /* Think big (also on some systems a byte is faster */ +#include <asm/atomic.h> + +/* Think big (also on some systems a byte is faster) */ +#define SOCK_ARRAY_SIZE 256 /* + * The AF_UNIX specific socket options + */ + +struct unix_opt +{ + int family; + char * name; + int locks; + struct inode * inode; + struct semaphore readsem; + struct sock * other; + int marksweep; +#define MARKED 1 + int inflight; +}; + +/* + * IP packet socket options + */ + +struct inet_packet_opt +{ + struct notifier_block notifier; /* Used when bound */ + struct device *bound_dev; + unsigned long dev_stamp; + struct packet_type *prot_hook; + char device_name[15]; +}; + +/* + * Once the IPX ncpd patches are in these are going into protinfo + */ + +#if defined(CONFIG_IPX) || defined(CONFIG_IPX_MODULE) +struct ipx_opt +{ + ipx_address dest_addr; + ipx_interface *intrfc; + unsigned short port; +#ifdef CONFIG_IPX_INTERN + unsigned char node[IPX_NODE_LEN]; +#endif + unsigned short type; +/* + * To handle asynchronous messages from the NetWare server, we have to + * know the connection this socket belongs to. + */ + struct ncp_server *ncp_server; + +}; +#endif + +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) +struct ipv6_pinfo +{ + struct in6_addr saddr; + struct in6_addr rcv_saddr; + struct in6_addr daddr; + + __u32 flow_lbl; + __u8 priority; + __u8 hop_limit; + + __u8 mcast_hops; + + /* sockopt flags */ + + __u8 recvsrcrt:1, + rxinfo:1, + mc_loop:1, + unused:4; + + /* device for outgoing mcast packets */ + + struct device *mc_if; + + struct ipv6_mc_socklist *ipv6_mc_list; + /* + * destination cache entry pointer + * contains a pointer to neighbour cache + * and other info related to network level + * (ex. PMTU) + */ + + struct dest_entry *dest; + __u32 dc_sernum; + + struct ipv6_options *opt; +}; + +struct raw6_opt { + __u32 checksum; /* perform checksum */ + __u32 offset; /* checksum offset */ + + struct icmp6_filter filter; +}; + +#endif /* IPV6 */ + +struct tcp_opt +{ +/* + * RFC793 variables by their proper names. This means you can + * read the code and the spec side by side (and laugh ...) + * See RFC793 and RFC1122. The RFC writes these in capitals. + */ + __u32 rcv_nxt; /* What we want to receive next */ + __u32 rcv_up; /* The urgent point (may not be valid) */ + __u32 rcv_wnd; /* Current receiver window */ + __u32 snd_nxt; /* Next sequence we send */ + __u32 snd_una; /* First byte we want an ack for */ + __u32 snd_up; /* Outgoing urgent pointer */ + __u32 snd_wl1; /* Sequence for window update */ + __u32 snd_wl2; /* Ack sequence for update */ + + __u32 rcv_wup; /* rcv_nxt on last window update sent */ + + + __u32 srtt; /* smothed round trip time << 3 */ + __u32 mdev; /* medium deviation */ + __u32 rto; /* retransmit timeout */ + __u32 backoff; /* backoff */ +/* + * Slow start and congestion control (see also Nagle, and Karn & Partridge) + */ + __u32 snd_cwnd; /* Sending congestion window */ + __u32 snd_ssthresh; /* Slow start size threshold */ +/* + * Timers used by the TCP protocol layer + */ + struct timer_list delack_timer; /* Ack delay */ + struct timer_list idle_timer; /* Idle watch */ + struct timer_list completion_timer; /* Up/Down timer */ + struct timer_list probe_timer; /* Probes */ + struct timer_list retransmit_timer; /* Resend (no ack) */ + + __u32 basertt; /* Vegas baseRTT */ + + __u8 delayed_acks; + __u8 dup_acks; + + __u32 lrcvtime; /* timestamp of last received data packet */ + __u32 rcv_tstamp; /* timestamp of last received packet */ + __u32 iat_mdev; /* interarrival time medium deviation */ + __u32 iat; /* interarrival time */ + __u32 ato; /* delayed ack timeout */ + + __u32 high_seq; +/* + * new send pointers + */ + struct sk_buff * send_head; + struct sk_buff * retrans_head; /* retrans head can be + * different to the head of + * write queue if we are doing + * fast retransmit + */ +/* + * pending events + */ + __u8 pending; + +/* + * Header prediction flags + * 0x5?10 << 16 + snd_wnd in net byte order + */ + __u32 pred_flags; + __u32 snd_wnd; /* The window we expect to receive */ + + __u32 probes_out; /* unanswered 0 window probes */ + + struct open_request *syn_wait_queue; + struct tcp_func *af_specific; +}; + + +/* * This structure really needs to be cleaned up. * Most of it is for TCP, and not used by any of * the other protocols. */ -struct sock { - struct options *opt; - volatile unsigned long wmem_alloc; - volatile unsigned long rmem_alloc; - unsigned long write_seq; - unsigned long sent_seq; - unsigned long acked_seq; - unsigned long copied_seq; - unsigned long rcv_ack_seq; - unsigned long window_seq; - unsigned long fin_seq; - unsigned long urg_seq; - unsigned long urg_data; +/* + * The idea is to start moving to a newer struct gradualy + * + * IMHO the newer struct should have the following format: + * + * struct sock { + * sockmem [mem, proto, callbacks] + * + * union or struct { + * netrom; + * ax_25; + * } ll_pinfo; + * + * union { + * ipv4; + * ipv6; + * ipx; + * } net_pinfo; + * + * union { + * tcp; + * udp; + * spx; + * } tp_pinfo; + * + * } + */ + +/* + * TCP will start to use the new protinfo while *still using the old* fields + */ + +struct sock +{ + struct options *opt; + atomic_t wmem_alloc; + atomic_t rmem_alloc; + unsigned long allocation; /* Allocation mode */ + __u32 write_seq; + __u32 copied_seq; + __u32 fin_seq; + __u32 syn_seq; + __u32 urg_seq; + __u32 urg_data; + int users; /* user count */ + + unsigned char delayed_acks, + dup_acks; /* - * Not all are volatile, but some are, so we - * might as well say they all are. + * Not all are volatile, but some are, so we + * might as well say they all are. */ - volatile char inuse, - dead, + volatile char dead, urginline, intr, blog, @@ -88,209 +321,338 @@ struct sock { reuse, keepopen, linger, - delay_acks, destroy, ack_timed, no_check, zapped, /* In ax25 & ipx means not linked */ broadcast, - nonagle; - unsigned long lingertime; - int proc; - struct sock *next; - struct sock *prev; /* Doubly linked chain.. */ - struct sock *pair; - struct sk_buff * volatile send_head; - struct sk_buff * volatile send_tail; - struct sk_buff_head back_log; - struct sk_buff *partial; - struct timer_list partial_timer; - long retransmits; - struct sk_buff_head write_queue, - receive_queue; - struct proto *prot; - struct wait_queue **sleep; - unsigned long daddr; - unsigned long saddr; - unsigned short max_unacked; - unsigned short window; - unsigned short bytes_rcv; -/* mss is min(mtu, max_window) */ - unsigned short mtu; /* mss negotiated in the syn's */ - volatile unsigned short mss; /* current eff. mss - can change */ - volatile unsigned short user_mss; /* mss requested by user in ioctl */ - volatile unsigned short max_window; - unsigned long window_clamp; - unsigned short num; - volatile unsigned short cong_window; - volatile unsigned short cong_count; - volatile unsigned short ssthresh; - volatile unsigned short packets_out; - volatile unsigned short shutdown; - volatile unsigned long rtt; - volatile unsigned long mdev; - volatile unsigned long rto; -/* currently backoff isn't used, but I'm maintaining it in case - * we want to go back to a backoff formula that needs it + nonagle, + bsdism; + unsigned long lingertime; + int proc; + struct sock *next; + struct sock *prev; /* Doubly linked chain.. */ + struct sock *pair; + + struct sk_buff * send_head; + struct sk_buff * send_tail; + + struct sk_buff_head back_log; + struct sk_buff *partial; + struct timer_list partial_timer; + atomic_t retransmits; + + struct sk_buff_head write_queue, + receive_queue, + out_of_order_queue; + + unsigned short family; + struct proto *prot; + struct wait_queue **sleep; + + __u32 daddr; + __u32 saddr; /* Sending source */ + __u32 rcv_saddr; /* Bound address */ + + unsigned short max_unacked; + + + unsigned short bytes_rcv; +/* + * mss is min(mtu, max_window) */ - volatile unsigned short backoff; - volatile short err; - unsigned char protocol; - volatile unsigned char state; - volatile unsigned char ack_backlog; - unsigned char max_ack_backlog; - unsigned char priority; - unsigned char debug; - unsigned short rcvbuf; - unsigned short sndbuf; - unsigned short type; - unsigned char localroute; /* Route locally only */ -#ifdef CONFIG_IPX - ipx_address ipx_dest_addr; - ipx_interface *ipx_intrfc; - unsigned short ipx_port; - unsigned short ipx_type; + unsigned short mtu; /* mss negotiated in the syn's */ + unsigned short mss; /* current eff. mss - can change */ + unsigned short user_mss; /* mss requested by user in ioctl */ + unsigned short max_window; + unsigned long window_clamp; + unsigned int ssthresh; + unsigned short num; + + unsigned short cong_window; + unsigned short cong_count; + atomic_t packets_out; + unsigned short shutdown; + + unsigned short window; /* used by netrom/ax.25 */ + +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) + union { + struct ipv6_pinfo af_inet6; + } net_pinfo; +#endif + + union { + struct tcp_opt af_tcp; +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) + struct raw6_opt tp_raw; +#endif + } tp_pinfo; +/* + * currently backoff isn't used, but I'm maintaining it in case + * we want to go back to a backoff formula that needs it + */ +/* + unsigned short backoff; + */ + int err, err_soft; /* Soft holds errors that don't + cause failure but are the cause + of a persistent failure not just + 'timed out' */ + unsigned char protocol; + volatile unsigned char state; + unsigned char ack_backlog; + unsigned char max_ack_backlog; + unsigned char priority; + unsigned char debug; + int rcvbuf; + int sndbuf; + unsigned short type; + unsigned char localroute; /* Route locally only */ + +/* + * This is where all the private (optional) areas that don't + * overlap will eventually live. + */ + + union + { + struct unix_opt af_unix; +#if defined(CONFIG_ATALK) || defined(CONFIG_ATALK_MODULE) + struct atalk_sock af_at; +#endif +#if defined(CONFIG_IPX) || defined(CONFIG_IPX_MODULE) + struct ipx_opt af_ipx; +#endif +#ifdef CONFIG_INET + struct inet_packet_opt af_packet; +#ifdef CONFIG_NUTCP + struct tcp_opt af_tcp; +#endif #endif -#ifdef CONFIG_AX25 - ax25_cb *ax25; -#ifdef CONFIG_NETROM - nr_cb *nr; +#if defined(CONFIG_X25) || defined(CONFIG_X25_MODULE) + x25_cb *x25; #endif +#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE) + ax25_cb *ax25; +#if defined(CONFIG_NETROM) || defined(CONFIG_NETROM_MODULE) + nr_cb *nr; #endif -#ifdef CONFIG_ATALK - struct atalk_sock at; +#if defined(CONFIG_ROSE) || defined(CONFIG_ROSE_MODULE) + rose_cb *rose; #endif +#endif + } protinfo; -/* IP 'private area' or will be eventually */ - int ip_ttl; /* TTL setting */ - int ip_tos; /* TOS */ - struct tcphdr dummy_th; - struct timer_list keepalive_timer; /* TCP keepalive hack */ - struct timer_list retransmit_timer; /* TCP retransmit timer */ - struct timer_list ack_timer; /* TCP delayed ack timer */ - int ip_xmit_timeout; /* Why the timeout is running */ - struct rtable *ip_route_cache; /* Cached output route */ - unsigned long ip_route_stamp; /* Route cache stamp */ - unsigned long ip_route_daddr; /* Target address */ - unsigned long ip_route_saddr; /* Source address */ - int ip_route_local; /* State of locality flag */ - unsigned long ip_hcache_stamp; /* Header cache stamp */ - unsigned long *ip_hcache_ver; /* Pointer to version of cache */ - char ip_hcache_data[16]; /* Cached header */ - int ip_hcache_state; /* Have we a cached header */ - unsigned char ip_option_len; /* Length of IP options */ - unsigned char ip_option_flen; /* Second fragment option length */ - unsigned char ip_opt_next_strict; /* Next hop is strict route */ - unsigned long ip_opt_next_hop; /* Next hop if forced */ - unsigned char *ip_opt_ptr[2]; /* IP option pointers */ +/* + * IP 'private area' or will be eventually + */ + int ip_ttl; /* TTL setting */ + int ip_tos; /* TOS */ + struct tcphdr dummy_th; + struct timer_list keepalive_timer; /* TCP keepalive hack */ + struct timer_list retransmit_timer; /* TCP retransmit timer */ + struct timer_list delack_timer; /* TCP delayed ack timer */ + int ip_xmit_timeout; /* Why the timeout is running */ + struct rtable *ip_route_cache; /* Cached output route */ + unsigned char ip_hdrincl; /* Include headers ? */ #ifdef CONFIG_IP_MULTICAST - int ip_mc_ttl; /* Multicasting TTL */ - int ip_mc_loop; /* Loopback */ - char ip_mc_name[MAX_ADDR_LEN]; /* Multicast device name */ - struct ip_mc_socklist *ip_mc_list; /* Group array */ + int ip_mc_ttl; /* Multicasting TTL */ + int ip_mc_loop; /* Loopback */ + char ip_mc_name[MAX_ADDR_LEN];/* Multicast device name */ + struct ip_mc_socklist *ip_mc_list; /* Group array */ #endif - /* This part is used for the timeout functions (timer.c). */ - int timeout; /* What are we waiting for? */ - struct timer_list timer; /* This is the TIME_WAIT/receive timer when we are doing IP */ - struct timeval stamp; +/* + * This part is used for the timeout functions (timer.c). + */ + + int timeout; /* What are we waiting for? */ + struct timer_list timer; /* This is the TIME_WAIT/receive timer + * when we are doing IP + */ + struct timeval stamp; - /* identd */ - struct socket *socket; + /* + * Identd + */ - /* Callbacks */ - void (*state_change)(struct sock *sk); - void (*data_ready)(struct sock *sk,int bytes); - void (*write_space)(struct sock *sk); - void (*error_report)(struct sock *sk); + struct socket *socket; + /* + * Callbacks + */ + + void (*state_change)(struct sock *sk); + void (*data_ready)(struct sock *sk,int bytes); + void (*write_space)(struct sock *sk); + void (*error_report)(struct sock *sk); + + int (*backlog_rcv) (struct sock *sk, + struct sk_buff *skb); +}; + +#if 0 +/* + * Inet protocol options + */ +struct inet_options { + __u8 version; + union { + struct options opt_v4; + struct ipv6_options opt_v6; + } u; }; +#endif + +/* + * IP protocol blocks we attach to sockets. + * socket layer -> transport layer interface + * transport -> network interface is defined by struct inet_proto + */ + +struct proto +{ + void (*close)(struct sock *sk, + unsigned long timeout); + int (*connect)(struct sock *sk, + struct sockaddr *uaddr, + int addr_len); + + struct sock * (*accept) (struct sock *sk, int flags); + void (*retransmit)(struct sock *sk, int all); + void (*write_wakeup)(struct sock *sk); + void (*read_wakeup)(struct sock *sk); + + int (*select)(struct sock *sk, int which, + select_table *wait); + + int (*ioctl)(struct sock *sk, int cmd, + unsigned long arg); + int (*init)(struct sock *sk); + int (*destroy)(struct sock *sk); + void (*shutdown)(struct sock *sk, int how); + int (*setsockopt)(struct sock *sk, int level, + int optname, char *optval, int optlen); + int (*getsockopt)(struct sock *sk, int level, + int optname, char *optval, + int *option); + int (*sendmsg)(struct sock *sk, struct msghdr *msg, + int len, int noblock, int flags); + int (*recvmsg)(struct sock *sk, struct msghdr *msg, + int len, int noblock, int flags, + int *addr_len); + int (*bind)(struct sock *sk, + struct sockaddr *uaddr, int addr_len); + + int (*backlog_rcv) (struct sock *sk, + struct sk_buff *skb); -struct proto { - struct sk_buff * (*wmalloc)(struct sock *sk, - unsigned long size, int force, - int priority); - struct sk_buff * (*rmalloc)(struct sock *sk, - unsigned long size, int force, - int priority); - void (*wfree)(struct sock *sk, struct sk_buff *skb, - unsigned long size); - void (*rfree)(struct sock *sk, struct sk_buff *skb, - unsigned long size); - unsigned long (*rspace)(struct sock *sk); - unsigned long (*wspace)(struct sock *sk); - void (*close)(struct sock *sk, int timeout); - int (*read)(struct sock *sk, unsigned char *to, - int len, int nonblock, unsigned flags); - int (*write)(struct sock *sk, unsigned char *to, - int len, int nonblock, unsigned flags); - int (*sendto)(struct sock *sk, - unsigned char *from, int len, int noblock, - unsigned flags, struct sockaddr_in *usin, - int addr_len); - int (*recvfrom)(struct sock *sk, - unsigned char *from, int len, int noblock, - unsigned flags, struct sockaddr_in *usin, - int *addr_len); - int (*build_header)(struct sk_buff *skb, - unsigned long saddr, - unsigned long daddr, - struct device **dev, int type, - struct options *opt, int len, int tos, int ttl); - int (*connect)(struct sock *sk, - struct sockaddr_in *usin, int addr_len); - struct sock * (*accept) (struct sock *sk, int flags); - void (*queue_xmit)(struct sock *sk, - struct device *dev, struct sk_buff *skb, - int free); - void (*retransmit)(struct sock *sk, int all); - void (*write_wakeup)(struct sock *sk); - void (*read_wakeup)(struct sock *sk); - int (*rcv)(struct sk_buff *buff, struct device *dev, - struct options *opt, unsigned long daddr, - unsigned short len, unsigned long saddr, - int redo, struct inet_protocol *protocol); - int (*select)(struct sock *sk, int which, - select_table *wait); - int (*ioctl)(struct sock *sk, int cmd, - unsigned long arg); - int (*init)(struct sock *sk); - void (*shutdown)(struct sock *sk, int how); - int (*setsockopt)(struct sock *sk, int level, int optname, - char *optval, int optlen); - int (*getsockopt)(struct sock *sk, int level, int optname, - char *optval, int *option); - unsigned short max_header; - unsigned long retransmits; - char name[32]; - int inuse, highestinuse; -#ifndef PACKET_C /* Hack to save 1K for packet sockets */ - struct sock * sock_array[SOCK_ARRAY_SIZE]; -#endif PACKET_C + unsigned short max_header; + unsigned long retransmits; + char name[32]; + int inuse, highestinuse; + struct sock ** sock_array; }; -#define TIME_WRITE 1 -#define TIME_CLOSE 2 -#define TIME_KEEPOPEN 3 -#define TIME_DESTROY 4 -#define TIME_DONE 5 /* used to absorb those last few packets */ -#define TIME_PROBE0 6 -#define SOCK_DESTROY_TIME 1000 /* about 10 seconds */ +#define TIME_WRITE 1 /* Not yet used */ +#define TIME_RETRANS 2 /* Retransmit timer */ +#define TIME_DACK 3 /* Delayed ack timer */ +#define TIME_CLOSE 4 +#define TIME_KEEPOPEN 5 +#define TIME_DESTROY 6 +#define TIME_DONE 7 /* Used to absorb those last few packets */ +#define TIME_PROBE0 8 -#define PROT_SOCK 1024 /* Sockets 0-1023 can't be bound too unless you are superuser */ +/* + * About 10 seconds + */ + +#define SOCK_DESTROY_TIME (10*HZ) + +/* + * Sockets 0-1023 can't be bound to unless you are superuser + */ + +#define PROT_SOCK 1024 #define SHUTDOWN_MASK 3 #define RCV_SHUTDOWN 1 #define SEND_SHUTDOWN 2 +/* + * Used by processes to "lock" a socket state, so that + * interrupts and bottom half handlers won't change it + * from under us. It essentially blocks any incoming + * packets, so that we won't get any new data or any + * packets that change the state of the socket. + * + * Note the 'barrier()' calls: gcc may not move a lock + * "downwards" or a unlock "upwards" when optimizing. + */ +extern void __release_sock(struct sock *sk); +static inline void lock_sock(struct sock *sk) +{ +#if 0 +/* debugging code: the test isn't even 100% correct, but it can catch bugs */ +/* Note that a double lock is ok in theory - it's just _usually_ a bug */ + if (sk->users) { + __label__ here; + printk("double lock on socket at %p\n", &&here); +here: + } +#endif + sk->users++; + barrier(); +} + +static inline void release_sock(struct sock *sk) +{ + barrier(); +#if 0 +/* debugging code: remove me when ok */ + if (sk->users == 0) { + __label__ here; + sk->users = 1; + printk("trying to unlock unlocked socket at %p\n", &&here); +here: + } +#endif + if ((sk->users = sk->users-1) == 0) + __release_sock(sk); +} + +/* + * This might not be the most apropriate place for this two + * but since they are used by a lot of the net related code + * at least they get declared on a include that is common to all + */ + +static __inline__ int min(unsigned int a, unsigned int b) +{ + if (a > b) + a = b; + return a; +} + +static __inline__ int max(unsigned int a, unsigned int b) +{ + if (a < b) + a = b; + return a; +} + +extern struct sock * sk_alloc(int priority); +extern void sk_free(struct sock *sk); extern void destroy_sock(struct sock *sk); -extern unsigned short get_new_socknum(struct proto *, unsigned short); -extern void put_sock(unsigned short, struct sock *); -extern void release_sock(struct sock *sk); +extern unsigned short get_new_socknum(struct proto *, + unsigned short); +extern void inet_put_sock(unsigned short, struct sock *); extern struct sock *get_sock(struct proto *, unsigned short, unsigned long, unsigned short, - unsigned long); + unsigned long, + unsigned long, unsigned short); extern struct sock *get_sock_mcast(struct sock *, unsigned short, unsigned long, unsigned short, unsigned long); @@ -303,52 +665,84 @@ extern struct sk_buff *sock_wmalloc(struct sock *sk, extern struct sk_buff *sock_rmalloc(struct sock *sk, unsigned long size, int force, int priority); -extern void sock_wfree(struct sock *sk, struct sk_buff *skb, - unsigned long size); -extern void sock_rfree(struct sock *sk, struct sk_buff *skb, - unsigned long size); +extern void sock_wfree(struct sock *sk, + struct sk_buff *skb); +extern void sock_rfree(struct sock *sk, + struct sk_buff *skb); extern unsigned long sock_rspace(struct sock *sk); extern unsigned long sock_wspace(struct sock *sk); -extern int sock_setsockopt(struct sock *sk,int level,int op,char *optval,int optlen); +extern int sock_setsockopt(struct sock *sk, int level, + int op, char *optval, + int optlen); -extern int sock_getsockopt(struct sock *sk,int level,int op,char *optval,int *optlen); -extern struct sk_buff *sock_alloc_send_skb(struct sock *skb, unsigned long size, int noblock, int *errcode); +extern int sock_getsockopt(struct sock *sk, int level, + int op, char *optval, + int *optlen); +extern struct sk_buff *sock_alloc_send_skb(struct sock *skb, + unsigned long size, + unsigned long fallback, + int noblock, + int *errcode); /* - * Queue a received datagram if it will fit. Stream and sequenced protocols - * can't normally use this as they need to fit buffers in and play with them. + * Queue a received datagram if it will fit. Stream and sequenced + * protocols can't normally use this as they need to fit buffers in + * and play with them. * - * Inlined as its very short and called for pretty much every packet ever - * received. + * Inlined as it's very short and called for pretty much every + * packet ever received. */ extern __inline__ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) { - unsigned long flags; - if(sk->rmem_alloc + skb->mem_len >= sk->rcvbuf) + if (sk->rmem_alloc + skb->truesize >= sk->rcvbuf) return -ENOMEM; - save_flags(flags); - cli(); - sk->rmem_alloc+=skb->mem_len; + atomic_add(skb->truesize, &sk->rmem_alloc); skb->sk=sk; - restore_flags(flags); skb_queue_tail(&sk->receive_queue,skb); - if(!sk->dead) + if (!sk->dead) + sk->data_ready(sk,skb->len); + return 0; +} + +extern __inline__ int __sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) +{ + if (sk->rmem_alloc + skb->truesize >= sk->rcvbuf) + return -ENOMEM; + atomic_add(skb->truesize, &sk->rmem_alloc); + skb->sk=sk; + __skb_queue_tail(&sk->receive_queue,skb); + if (!sk->dead) sk->data_ready(sk,skb->len); return 0; } -/* declarations from timer.c */ +/* + * Recover an error report and clear atomically + */ + +extern __inline__ int sock_error(struct sock *sk) +{ + int err=xchg(&sk->err,0); + return -err; +} + +/* + * Declarations from timer.c + */ + extern struct sock *timer_base; -void delete_timer (struct sock *); -void reset_timer (struct sock *, int, unsigned long); -void net_timer (unsigned long); +extern void net_delete_timer (struct sock *); +extern void net_reset_timer (struct sock *, int, unsigned long); +extern void net_timer (unsigned long); -/* Enable debug/info messages */ +/* + * Enable debug/info messages + */ -#define NETDEBUG(x) x +#define NETDEBUG(x) do { } while (0) #endif /* _SOCK_H */ diff --git a/include/net/spx.h b/include/net/spx.h new file mode 100644 index 000000000..3e9b1d185 --- /dev/null +++ b/include/net/spx.h @@ -0,0 +1,38 @@ +#ifndef __NET_SPX_H +#define __NET_SPX_H + +/* + * Internal definitions for the SPX protocol. + */ + +/* + * The SPX header following an IPX header. + */ + +struct spxhdr +{ + __u8 cctl; +#define CCTL_SPXII_XHD 0x01 /* SPX2 extended header */ +#define CCTL_SPX_UNKNOWN 0x02 /* Unknown (unused ??) */ +#define CCTL_SPXII_NEG 0x04 /* Negotiate size */ +#define CCTL_SPXII 0x08 /* Set for SPX2 */ +#define CCTL_EOM 0x10 /* End of message marker */ +#define CCTL_URG 0x20 /* Urgent marker in SPP (not used in SPX?) */ +#define CCTL_ACK 0x40 /* Send me an ACK */ +#define CCTL_CTL 0x80 /* Control message */ + __u8 dtype; +#define SPX_DTYPE_ECONN 0xFE /* Finished */ +#define SPX_DTYPE_ECACK 0xFF /* Ok */ + __u16 sconn; /* Connection ID */ + __u16 dconn; /* Connection ID */ + __u16 sequence; + __u16 ackseq; + __u16 allocseq; +}; + +#define IPXTYPE_SPX 5 + + + + +#endif diff --git a/include/net/tcp.h b/include/net/tcp.h index efeaac0da..23fd54501 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -18,15 +18,33 @@ #ifndef _TCP_H #define _TCP_H +#include <linux/config.h> #include <linux/tcp.h> +#include <net/checksum.h> -#define MAX_SYN_SIZE 44 + MAX_HEADER -#define MAX_FIN_SIZE 40 + MAX_HEADER -#define MAX_ACK_SIZE 40 + MAX_HEADER -#define MAX_RESET_SIZE 40 + MAX_HEADER -#define MAX_WINDOW 16384 + +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) +#define NETHDR_SIZE sizeof(struct ipv6hdr) +#else +#define NETHDR_SIZE sizeof(struct iphdr) + 40 +#endif + +/* + * 40 is maximal IP options size + * 4 is TCP option size (MSS) + */ + +#define MAX_SYN_SIZE (NETHDR_SIZE + sizeof(struct tcphdr) + 4 + MAX_HEADER + 15) +#define MAX_FIN_SIZE (NETHDR_SIZE + sizeof(struct tcphdr) + MAX_HEADER + 15) +#define MAX_ACK_SIZE (NETHDR_SIZE + sizeof(struct tcphdr) + MAX_HEADER + 15) +#define MAX_RESET_SIZE (NETHDR_SIZE + sizeof(struct tcphdr) + MAX_HEADER + 15) + +#define MAX_WINDOW 32767 /* Never offer a window over 32767 without using + window scaling (not yet supported). Some poor + stacks do signed 16bit maths! */ #define MIN_WINDOW 2048 #define MAX_ACK_BACKLOG 2 +#define MAX_DELAY_ACK 2 #define MIN_WRITE_SPACE 2048 #define TCP_WINDOW_DIFF 2048 @@ -49,22 +67,26 @@ #define TCP_TIMEOUT_LEN (15*60*HZ) /* should be about 15 mins */ #define TCP_TIMEWAIT_LEN (60*HZ) /* how long to wait to successfully * close the socket, about 60 seconds */ -#define TCP_FIN_TIMEOUT (3*60*HZ) /* BSD style FIN_WAIT2 deadlock breaker */ +#define TCP_FIN_TIMEOUT (3*60*HZ) /* BSD style FIN_WAIT2 deadlock breaker */ + #define TCP_ACK_TIME (3*HZ) /* time to delay before sending an ACK */ -#define TCP_DONE_TIME 250 /* maximum time to wait before actually +#define TCP_DONE_TIME (5*HZ/2)/* maximum time to wait before actually * destroying a socket */ -#define TCP_WRITE_TIME 3000 /* initial time to wait for an ACK, +#define TCP_WRITE_TIME (30*HZ) /* initial time to wait for an ACK, * after last transmit */ #define TCP_TIMEOUT_INIT (3*HZ) /* RFC 1122 initial timeout value */ #define TCP_SYN_RETRIES 10 /* number of times to retry opening a * connection (TCP_RETR2-....) */ -#define TCP_PROBEWAIT_LEN 100 /* time to wait between probes when +#define TCP_PROBEWAIT_LEN (1*HZ)/* time to wait between probes when * I've got something to write and * there is no window */ - +#define TCP_KEEPALIVE_TIME (180*60*HZ) /* two hours */ +#define TCP_KEEPALIVE_PROBES 9 /* Max of 9 keepalive probes */ +#define TCP_KEEPALIVE_PERIOD (75*HZ) /* period of keepalive check */ #define TCP_NO_CHECK 0 /* turn to one if you want the default * to be no checksum */ +#define TCP_SYNACK_PERIOD (HZ/2) /* * TCP option @@ -79,64 +101,428 @@ #define TCPOPT_WINDOW 3 /* Window scaling */ #define TCPOPT_TIMESTAMP 8 /* Better RTT estimations/PAWS */ +/* + * TCP option lengths + */ + +#define TCPOLEN_MSS 4 +#define TCPOLEN_WINDOW 3 +#define TCPOLEN_TIMESTAMP 10 + + +/* + * TCP Vegas constants + */ + +#define TCP_VEGAS_ALPHA 2 /* v_cong_detect_top_nseg */ +#define TCP_VEGAS_BETA 4 /* v_cong_detect_bot_nseg */ +#define TCP_VEGAS_GAMMA 1 /* v_exp_inc_nseg */ + +struct open_request; + +struct or_calltable { + void (*rtx_syn_ack) (struct sock *sk, struct open_request *req); + void (*destructor) (struct open_request *req); +}; + +struct open_request { + struct open_request *dl_next; + struct open_request *dl_prev; + __u32 rcv_isn; + __u32 snt_isn; + __u16 mss; + __u16 rmt_port; + unsigned long expires; + int retrans; + struct or_calltable *class; + struct sock *sk; +}; + +struct tcp_v4_open_req { + struct open_request req; + __u32 loc_addr; + __u32 rmt_addr; + struct options *opt; +}; + +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) +struct tcp_v6_open_req { + struct open_request req; + struct in6_addr loc_addr; + struct in6_addr rmt_addr; + struct ipv6_options *opt; + struct device *dev; +}; +#endif + +/* + * Pointers to address related TCP functions + * (i.e. things that depend on the address family) + */ + +struct tcp_func { + int (*build_net_header) (struct sock *sk, + struct sk_buff *skb); + + void (*queue_xmit) (struct sock *sk, + struct device *dev, + struct sk_buff *skb, + int free); + + void (*send_check) (struct sock *sk, + struct tcphdr *th, + int len, + struct sk_buff *skb); + + int (*rebuild_header) (struct sock *sk, + struct sk_buff *skb); + + int (*conn_request) (struct sock *sk, + struct sk_buff *skb, + void *opt, + __u32 isn); + + struct sock * (*syn_recv_sock) (struct sock *sk, + struct sk_buff *skb, + struct open_request *req); + + __u32 (*init_sequence) (struct sock *sk, + struct sk_buff *skb); + + struct sock * (*get_sock) (struct sk_buff *skb, + struct tcphdr *th); + + int (*setsockopt) (struct sock *sk, + int level, + int optname, + char *optval, + int optlen); + + int (*getsockopt) (struct sock *sk, + int level, + int optname, + char *optval, + int *optlen); + + + void (*addr2sockaddr) (struct sock *sk, + struct sockaddr *); + + int sockaddr_len; +}; /* * The next routines deal with comparing 32 bit unsigned ints * and worry about wraparound (automatic with unsigned arithmetic). */ -extern __inline int before(unsigned long seq1, unsigned long seq2) +extern __inline int before(__u32 seq1, __u32 seq2) { - return (long)(seq1-seq2) < 0; + return (__s32)(seq1-seq2) < 0; } -extern __inline int after(unsigned long seq1, unsigned long seq2) +extern __inline int after(__u32 seq1, __u32 seq2) { - return (long)(seq1-seq2) > 0; + return (__s32)(seq2-seq1) < 0; } /* is s2<=s1<=s3 ? */ -extern __inline int between(unsigned long seq1, unsigned long seq2, unsigned long seq3) +extern __inline int between(__u32 seq1, __u32 seq2, __u32 seq3) { return (after(seq1+1, seq2) && before(seq1, seq3+1)); } +extern struct proto tcp_prot; +extern struct tcp_mib tcp_statistics; + +extern void tcp_v4_err(int type, int code, + unsigned char *header, __u32 info, + __u32 daddr, __u32 saddr, + struct inet_protocol *protocol, + int len); + +extern void tcp_shutdown (struct sock *sk, int how); + +extern int tcp_v4_rcv(struct sk_buff *skb, + struct device *dev, + struct options *opt, __u32 daddr, + unsigned short len, __u32 saddr, + int redo, + struct inet_protocol *protocol); + +extern int tcp_do_sendmsg(struct sock *sk, + int iovlen, struct iovec *iov, + int len, int nonblock, + int flags); + +extern int tcp_ioctl(struct sock *sk, + int cmd, + unsigned long arg); + +extern int tcp_rcv_state_process(struct sock *sk, + struct sk_buff *skb, + struct tcphdr *th, + void *opt, __u16 len); + +extern void tcp_rcv_established(struct sock *sk, + struct sk_buff *skb, + struct tcphdr *th, + __u16 len); + +extern void tcp_close(struct sock *sk, + unsigned long timeout); +extern struct sock * tcp_accept(struct sock *sk, int flags); +extern int tcp_select(struct sock *sk, int sel_type, + select_table *wait); +extern int tcp_getsockopt(struct sock *sk, int level, + int optname, char *optval, + int *optlen); +extern int tcp_setsockopt(struct sock *sk, int level, + int optname, char *optval, + int optlen); +extern void tcp_set_keepalive(struct sock *sk, int val); +extern int tcp_recvmsg(struct sock *sk, + struct msghdr *msg, + int len, int nonblock, + int flags, int *addr_len); + +extern int tcp_parse_options(struct tcphdr *th); + +/* + * TCP v4 functions exported for the inet6 API + */ + +extern int tcp_v4_rebuild_header(struct sock *sk, + struct sk_buff *skb); + +extern int tcp_v4_build_header(struct sock *sk, + struct sk_buff *skb); + +extern void tcp_v4_send_check(struct sock *sk, + struct tcphdr *th, int len, + struct sk_buff *skb); + +extern int tcp_v4_conn_request(struct sock *sk, + struct sk_buff *skb, + void *ptr, __u32 isn); + +extern struct sock * tcp_v4_syn_recv_sock(struct sock *sk, + struct sk_buff *skb, + struct open_request *req); + +extern int tcp_v4_backlog_rcv(struct sock *sk, + struct sk_buff *skb); +extern int tcp_v4_connect(struct sock *sk, + struct sockaddr *uaddr, + int addr_len); + + +extern void tcp_read_wakeup(struct sock *); +extern void tcp_write_xmit(struct sock *); +extern void tcp_time_wait(struct sock *); +extern void tcp_do_retransmit(struct sock *, int); + +/* tcp_output.c */ + +extern void tcp_send_probe0(struct sock *); +extern void tcp_send_partial(struct sock *); +extern void tcp_write_wakeup(struct sock *); +extern void tcp_send_fin(struct sock *sk); +extern int tcp_send_synack(struct sock *); +extern int tcp_send_skb(struct sock *, struct sk_buff *); +extern void tcp_send_ack(struct sock *sk); +extern void tcp_send_delayed_ack(struct sock *sk, int max_timeout); + +/* tcp_input.c */ +extern void tcp_cache_zap(void); + +/* CONFIG_IP_TRANSPARENT_PROXY */ +extern int tcp_chkaddr(struct sk_buff *); + +/* tcp_timer.c */ +#define tcp_reset_msl_timer(x,y,z) net_reset_timer(x,y,z) +extern void tcp_reset_xmit_timer(struct sock *, int, unsigned long); +extern void tcp_clear_xmit_timer(struct sock *, int); +extern int tcp_timer_is_set(struct sock *, int); +extern void tcp_init_xmit_timers(struct sock *); +extern void tcp_clear_xmit_timers(struct sock *); + +extern void tcp_retransmit_timer(unsigned long); +extern void tcp_delack_timer(unsigned long); +extern void tcp_probe_timer(unsigned long); + + +/* + * TCP slow timer + */ +extern struct timer_list tcp_slow_timer; + +struct tcp_sl_timer { + atomic_t count; + unsigned long period; + unsigned long last; + void (*handler) (unsigned long); +}; + +#define TCP_SLT_SYNACK 0 +#define TCP_SLT_KEEPALIVE 1 +#define TCP_SLT_MAX 2 + +extern struct tcp_sl_timer tcp_slt_array[TCP_SLT_MAX]; + +static __inline__ unsigned short tcp_raise_window(struct sock *sk) +{ + struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + long cur_win; + int res = 0; + + /* + * compute the actual window i.e. + * old_window - received_bytes_on_that_win + */ + + cur_win = tp->rcv_wup - (tp->rcv_nxt - tp->rcv_wnd); + + + /* + * We need to send an ack right away if + * our rcv window is blocking the sender and + * we have more free space to offer. + */ + + if (cur_win < (sk->mss << 1)) + res = 1; + return res; +} + +extern unsigned short tcp_select_window(struct sock *sk); + /* * List all states of a TCP socket that can be viewed as a "connected" * state. This now includes TCP_SYN_RECV, although I am not yet fully * convinced that this is the solution for the 'getpeername(2)' * problem. Thanks to Stephen A. Wood <saw@cebaf.gov> -FvK */ -extern __inline const int -tcp_connected(const int state) + +extern __inline const int tcp_connected(const int state) { return(state == TCP_ESTABLISHED || state == TCP_CLOSE_WAIT || state == TCP_FIN_WAIT1 || state == TCP_FIN_WAIT2 || state == TCP_SYN_RECV); } +/* + * Calculate(/check) TCP checksum + */ +static __inline__ u16 tcp_v4_check(struct tcphdr *th, int len, + unsigned long saddr, unsigned long daddr, + unsigned long base) +{ + return csum_tcpudp_magic(saddr,daddr,len,IPPROTO_TCP,base); +} + -extern struct proto tcp_prot; +#undef STATE_TRACE +#ifdef STATE_TRACE +static char *statename[]={ + "Unused","Established","Syn Sent","Syn Recv", + "Fin Wait 1","Fin Wait 2","Time Wait", "Close", + "Close Wait","Last ACK","Listen","Closing" +}; +#endif -extern void tcp_err(int err, unsigned char *header, unsigned long daddr, - unsigned long saddr, struct inet_protocol *protocol); -extern void tcp_shutdown (struct sock *sk, int how); -extern int tcp_rcv(struct sk_buff *skb, struct device *dev, - struct options *opt, unsigned long daddr, - unsigned short len, unsigned long saddr, int redo, - struct inet_protocol *protocol); +static __inline__ void tcp_set_state(struct sock *sk, int state) +{ + struct tcp_opt *tp = &sk->tp_pinfo.af_tcp; + int oldstate = sk->state; -extern int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg); + sk->state = state; -extern int tcp_select_window(struct sock *sk); -extern void tcp_send_check(struct tcphdr *th, unsigned long saddr, - unsigned long daddr, int len, struct sock *sk); -extern void tcp_send_probe0(struct sock *sk); -extern void tcp_enqueue_partial(struct sk_buff *, struct sock *); -extern struct sk_buff * tcp_dequeue_partial(struct sock *); -extern void tcp_cache_zap(void); +#ifdef STATE_TRACE + if(sk->debug) + printk("TCP sk=%p, State %s -> %s\n",sk, statename[oldstate],statename[state]); +#endif + + switch (state) { + case TCP_ESTABLISHED: + if (oldstate != TCP_ESTABLISHED) { + tcp_statistics.TcpCurrEstab++; + } + break; + + case TCP_CLOSE: + tcp_cache_zap(); + /* Should be about 2 rtt's */ + net_reset_timer(sk, TIME_DONE, min(tp->srtt * 2, TCP_DONE_TIME)); + /* fall through */ + default: + if (oldstate==TCP_ESTABLISHED) + tcp_statistics.TcpCurrEstab--; + } +} + +extern __inline__ void tcp_synq_unlink(struct tcp_opt *tp, struct open_request *req) +{ + if (req->dl_next == req) + { + tp->syn_wait_queue = NULL; + } + else + { + req->dl_prev->dl_next = req->dl_next; + req->dl_next->dl_prev = req->dl_prev; + + if (tp->syn_wait_queue == req) + { + tp->syn_wait_queue = req->dl_next; + } + } + + req->dl_prev = req->dl_next = NULL; +} + +extern __inline__ void tcp_synq_queue(struct tcp_opt *tp, struct open_request *req) +{ + if (!tp->syn_wait_queue) + { + req->dl_next = req; + req->dl_prev = req; + tp->syn_wait_queue = req; + } + else + { + struct open_request *list = tp->syn_wait_queue; + + req->dl_next = list; + req->dl_prev = list->dl_prev; + list->dl_prev->dl_next = req; + list->dl_prev = req; + } + +} + +extern void __tcp_inc_slow_timer(struct tcp_sl_timer *slt); +extern __inline__ void tcp_inc_slow_timer(int timer) +{ + struct tcp_sl_timer *slt = &tcp_slt_array[timer]; + + if (slt->count == 0) + { + __tcp_inc_slow_timer(slt); + } + + atomic_inc(&slt->count); +} + +extern __inline__ void tcp_dec_slow_timer(int timer) +{ + struct tcp_sl_timer *slt = &tcp_slt_array[timer]; + + atomic_dec(&slt->count); +} #endif /* _TCP_H */ + diff --git a/include/net/transp_v6.h b/include/net/transp_v6.h new file mode 100644 index 000000000..412943e4d --- /dev/null +++ b/include/net/transp_v6.h @@ -0,0 +1,42 @@ +#ifndef _TRANSP_V6_H +#define _TRANSP_V6_H + +#include <net/checksum.h> + +/* + * IPv6 transport protocols + */ + +#ifdef __KERNEL__ + +extern struct proto rawv6_prot; +extern struct proto udpv6_prot; +extern struct proto tcpv6_prot; + +extern void rawv6_init(void); +extern void udpv6_init(void); +extern void tcpv6_init(void); + +extern int udpv6_connect(struct sock *sk, + struct sockaddr *uaddr, + int addr_len); + +extern int datagram_recv_ctl(struct sock *sk, + struct msghdr *msg, + struct sk_buff *skb); + +extern int datagram_send_ctl(struct msghdr *msg, + struct device **src_dev, + struct in6_addr **src_addr, + struct ipv6_options *opt); + +#define LOOPBACK4_IPV6 __constant_htonl(0x7f000006) + +/* + * address family specific functions + */ +extern struct tcp_func ipv4_specific; + +#endif + +#endif diff --git a/include/net/udp.h b/include/net/udp.h index 62f0c7a0e..d834feb6d 100644 --- a/include/net/udp.h +++ b/include/net/udp.h @@ -31,22 +31,25 @@ extern struct proto udp_prot; -extern void udp_err(int err, unsigned char *header, unsigned long daddr, - unsigned long saddr, struct inet_protocol *protocol); -extern void udp_send_check(struct udphdr *uh, unsigned long saddr, - unsigned long daddr, int len, struct sock *sk); -extern int udp_recvfrom(struct sock *sk, unsigned char *to, - int len, int noblock, unsigned flags, - struct sockaddr_in *sin, int *addr_len); -extern int udp_read(struct sock *sk, unsigned char *buff, - int len, int noblock, unsigned flags); +extern void udp_err(int type, int code, unsigned char *header, + __u32 info, __u32 daddr, __u32 saddr, + struct inet_protocol *protocol, int len); +extern void udp_send_check(struct udphdr *uh, __u32 saddr, + __u32 daddr, int len, struct sock *sk); extern int udp_connect(struct sock *sk, - struct sockaddr_in *usin, int addr_len); + struct sockaddr *usin, int addr_len); + +extern int udp_sendmsg(struct sock *sk, struct msghdr *msg, + int len, int noblock, int flags); + extern int udp_rcv(struct sk_buff *skb, struct device *dev, - struct options *opt, unsigned long daddr, - unsigned short len, unsigned long saddr, int redo, + struct options *opt, __u32 daddr, + unsigned short len, __u32 saddr, int redo, struct inet_protocol *protocol); extern int udp_ioctl(struct sock *sk, int cmd, unsigned long arg); extern void udp_cache_zap(void); /* Remove udp last socket cache */ +/* CONFIG_IP_TRANSPARENT_PROXY */ +extern int udp_chkaddr(struct sk_buff *skb); + #endif /* _UDP_H */ diff --git a/include/net/unix.h b/include/net/unix.h deleted file mode 100644 index dba43800f..000000000 --- a/include/net/unix.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * UNIX An implementation of the AF_UNIX network domain for the - * LINUX operating system. UNIX is implemented using the - * BSD Socket interface as the means of communication with - * the user level. - * - * This file describes some things of the UNIX protocol family - * module. It is mainly used for the "proc" sub-module now, - * but it may be useful for cleaning up the UNIX module as a - * whole later. - * - * Version: @(#)unix.h 1.0.3 05/25/93 - * - * Authors: Orest Zborowski, <obz@Kodak.COM> - * Ross Biro, <bir7@leland.Stanford.Edu> - * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> - * - * Fixes: - * Dmitry Gorodchanin - proc locking - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - */ - - -#ifdef _LINUX_UN_H - - -struct unix_proto_data { - int refcnt; /* cnt of reference 0=free */ - /* -1=not initialised -bgm */ - struct socket *socket; /* socket we're bound to */ - int protocol; - struct sockaddr_un sockaddr_un; - short sockaddr_len; /* >0 if name bound */ - char *buf; - int bp_head, bp_tail; - struct inode *inode; - struct unix_proto_data *peerupd; - struct wait_queue *wait; /* Lock across page faults (FvK) */ - int lock_flag; -}; - -extern struct unix_proto_data unix_datas[NSOCKETS_UNIX]; - - -#define last_unix_data (unix_datas + NSOCKETS_UNIX - 1) - - -#define UN_DATA(SOCK) ((struct unix_proto_data *)(SOCK)->data) -#define UN_PATH_OFFSET ((unsigned long)((struct sockaddr_un *)0) \ - ->sun_path) - -/* - * Buffer size must be power of 2. buffer mgmt inspired by pipe code. - * note that buffer contents can wraparound, and we can write one byte less - * than full size to discern full vs empty. - */ -#define BUF_SIZE PAGE_SIZE -#define UN_BUF_AVAIL(UPD) (((UPD)->bp_head - (UPD)->bp_tail) & \ - (BUF_SIZE-1)) -#define UN_BUF_SPACE(UPD) ((BUF_SIZE-1) - UN_BUF_AVAIL(UPD)) - -#endif /* _LINUX_UN_H */ - - -extern void unix_proto_init(struct net_proto *pro); diff --git a/include/net/x25call.h b/include/net/x25call.h new file mode 100644 index 000000000..7c478a1d9 --- /dev/null +++ b/include/net/x25call.h @@ -0,0 +1,2 @@ +/* Separate to keep compilation of protocols.c simpler */ +extern void x25_proto_init(struct net_proto *pro); |