diff options
Diffstat (limited to 'include/net')
-rw-r--r-- | include/net/arp.h | 20 | ||||
-rw-r--r-- | include/net/atalk.h | 144 | ||||
-rw-r--r-- | include/net/atalkcall.h | 2 | ||||
-rw-r--r-- | include/net/ax25.h | 188 | ||||
-rw-r--r-- | include/net/ax25call.h | 2 | ||||
-rw-r--r-- | include/net/checksum.h | 237 | ||||
-rw-r--r-- | include/net/datalink.h | 17 | ||||
-rw-r--r-- | include/net/eth.h | 36 | ||||
-rw-r--r-- | include/net/head_explode.h | 140 | ||||
-rw-r--r-- | include/net/icmp.h | 38 | ||||
-rw-r--r-- | include/net/ip.h | 115 | ||||
-rw-r--r-- | include/net/ipip.h | 4 | ||||
-rw-r--r-- | include/net/ipx.h | 84 | ||||
-rw-r--r-- | include/net/ipxcall.h | 2 | ||||
-rw-r--r-- | include/net/netrom.h | 131 | ||||
-rw-r--r-- | include/net/nrcall.h | 2 | ||||
-rw-r--r-- | include/net/p8022.h | 2 | ||||
-rw-r--r-- | include/net/p8022call.h | 2 | ||||
-rw-r--r-- | include/net/protocol.h | 59 | ||||
-rw-r--r-- | include/net/psnap.h | 2 | ||||
-rw-r--r-- | include/net/psnapcall.h | 2 | ||||
-rw-r--r-- | include/net/rarp.h | 14 | ||||
-rw-r--r-- | include/net/raw.h | 34 | ||||
-rw-r--r-- | include/net/route.h | 56 | ||||
-rw-r--r-- | include/net/snmp.h | 107 | ||||
-rw-r--r-- | include/net/sock.h | 354 | ||||
-rw-r--r-- | include/net/tcp.h | 142 | ||||
-rw-r--r-- | include/net/udp.h | 52 | ||||
-rw-r--r-- | include/net/unix.h | 69 |
29 files changed, 2057 insertions, 0 deletions
diff --git a/include/net/arp.h b/include/net/arp.h new file mode 100644 index 000000000..e8fa572ea --- /dev/null +++ b/include/net/arp.h @@ -0,0 +1,20 @@ +/* linux/net/inet/arp.h */ +#ifndef _ARP_H +#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_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; +#endif /* _ARP_H */ diff --git a/include/net/atalk.h b/include/net/atalk.h new file mode 100644 index 000000000..08760cdac --- /dev/null +++ b/include/net/atalk.h @@ -0,0 +1,144 @@ +/* + * 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/atalkcall.h b/include/net/atalkcall.h new file mode 100644 index 000000000..726e33cd9 --- /dev/null +++ b/include/net/atalkcall.h @@ -0,0 +1,2 @@ +/* Separate to keep compilation of protocols.c simpler */ +extern void atalk_proto_init(struct net_proto *pro); diff --git a/include/net/ax25.h b/include/net/ax25.h new file mode 100644 index 000000000..4195c1246 --- /dev/null +++ b/include/net/ax25.h @@ -0,0 +1,188 @@ +/* + * Declarations of AX.25 type objects. + * + * Alan Cox (GW4PTS) 10/11/93 + */ + +#ifndef _AX25_H +#define _AX25_H +#include <linux/ax25.h> + +#define AX25_P_IP 0xCC +#define AX25_P_ARP 0xCD +#define AX25_P_TEXT 0xF0 +#define AX25_P_NETROM 0xCF + +#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 AX25_REPEATED 0x80 + +#define ACK_PENDING_CONDITION 0x01 +#define REJECT_CONDITION 0x02 +#define PEER_RX_BUSY_CONDITION 0x04 +#define OWN_RX_BUSY_CONDITION 0x08 + +#ifndef _LINUX_NETDEVICE_H +#include <linux/netdevice.h> +#endif + +/* + * These headers are taken from the KA9Q package by Phil Karn. These specific + * files have been placed under the GPL (not the whole package) by Phil. + * + * + * Copyright 1991 Phil Karn, KA9Q + * + * 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; version 2 dated June, 1991. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave., Cambridge, MA 02139, USA. + */ + +/* Upper sub-layer (LAPB) definitions */ + +/* Control field templates */ +#define I 0x00 /* Information frames */ +#define S 0x01 /* Supervisory frames */ +#define RR 0x01 /* Receiver ready */ +#define RNR 0x05 /* Receiver not ready */ +#define REJ 0x09 /* Reject */ +#define U 0x03 /* Unnumbered frames */ +#define SABM 0x2f /* Set Asynchronous Balanced Mode */ +#define SABME 0x6f /* Set Asynchronous Balanced Mode Extended */ +#define DISC 0x43 /* Disconnect */ +#define DM 0x0f /* Disconnected mode */ +#define UA 0x63 /* Unnumbered acknowledge */ +#define FRMR 0x87 /* Frame reject */ +#define UI 0x03 /* Unnumbered information */ +#define PF 0x10 /* Poll/final bit */ + +#define ILLEGAL 0x100 /* Impossible to be a real frame type */ + +#define MMASK 7 /* Mask for modulo-8 sequence numbers */ + +/* AX25 L2 C-bit */ + +#define C_COMMAND 1 /* C_ otherwise it clashes with the de600 defines (sigh)) */ +#define C_RESPONSE 2 + +/* Define Link State constants. */ + +#define AX25_STATE_0 0 +#define AX25_STATE_1 1 +#define AX25_STATE_2 2 +#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 */ + +typedef struct ax25_uid_assoc { + struct ax25_uid_assoc *next; + uid_t uid; + ax25_address call; +} ax25_uid_assoc; + +typedef struct { + ax25_address calls[6]; + unsigned char repeated[6]; + unsigned char ndigi; + char lastrepeat; +} ax25_digi; + +typedef struct ax25_cb { + struct ax25_cb *next; + ax25_address source_addr, dest_addr; + struct device *device; + unsigned char state; + unsigned short vs, vr, va; + unsigned char condition; + unsigned char n2, n2count; + unsigned short t1, t2, t3, rtt; + unsigned short t1timer, t2timer, t3timer; + ax25_digi *digipeat; + struct sk_buff_head write_queue; + struct sk_buff_head ack_queue; + unsigned char window; + struct timer_list timer; + struct sock *sk; /* Backlink to socket */ +} ax25_cb; + +/* ax25.c */ +extern char *ax2asc(ax25_address *); +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 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_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); + +#include "ax25call.h" + +/* ax25_in.c */ +extern int ax25_process_rx_frame(ax25_cb *, struct sk_buff *, int); + +/* ax25_out.c */ +extern int 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_check_iframes_acked(ax25_cb *, unsigned short); +extern void ax25_check_need_response(ax25_cb *, int, int); + +/* 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 int ax25_rt_autobind(ax25_cb *, ax25_address *); +extern void ax25_rt_device_down(struct device *); +extern void ax25_ip_mode_set(ax25_address *, struct device *, char); +extern char ax25_ip_mode_get(ax25_address *, struct device *); + +/* ax25_subr.c */ +extern void ax25_clear_tx_queue(ax25_cb *); +extern void ax25_frames_acked(ax25_cb *, unsigned short); +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 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 *); +extern int build_ax25_addr(unsigned char *, ax25_address *, ax25_address *, + ax25_digi *, 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 *); + +/* ax25_timer */ +extern void ax25_set_timer(ax25_cb *); + +#endif diff --git a/include/net/ax25call.h b/include/net/ax25call.h new file mode 100644 index 000000000..89569656b --- /dev/null +++ b/include/net/ax25call.h @@ -0,0 +1,2 @@ +/* Seperate to keep compilation of protocols.c simpler */ +extern void ax25_proto_init(struct net_proto *pro); diff --git a/include/net/checksum.h b/include/net/checksum.h new file mode 100644 index 000000000..7f9492328 --- /dev/null +++ b/include/net/checksum.h @@ -0,0 +1,237 @@ +/* + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. INET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * Checksumming functions for IP, TCP, UDP and so on + * + * Authors: Jorge Cwik, <jorge@laser.satlink.net> + * Arnt Gulbrandsen, <agulbra@nvg.unit.no> + * Borrows very liberally from tcp.c and ip.c, see those + * files for more names. + * + * 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 _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. + * + * By Jorge Cwik <jorge@laser.satlink.net>, adapted for linux by + * Arnt Gulbrandsen. + */ +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); +} + + + + +/* + * 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); +} + + + +/* + * 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 new file mode 100644 index 000000000..34ae08daa --- /dev/null +++ b/include/net/datalink.h @@ -0,0 +1,17 @@ +#ifndef _NET_INET_DATALINK_H_ +#define _NET_INET_DATALINK_H_ + +struct datalink_proto { + unsigned short type_len; + unsigned char type[8]; + char *string_name; + unsigned short header_length; + int (*rcvfunc)(struct sk_buff *, struct device *, + struct packet_type *); + void (*datalink_header)(struct datalink_proto *, struct sk_buff *, + unsigned char *); + struct datalink_proto *next; +}; + +#endif + diff --git a/include/net/eth.h b/include/net/eth.h new file mode 100644 index 000000000..3c11603e0 --- /dev/null +++ b/include/net/eth.h @@ -0,0 +1,36 @@ +/* + * 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/head_explode.h b/include/net/head_explode.h new file mode 100644 index 000000000..90276fafe --- /dev/null +++ b/include/net/head_explode.h @@ -0,0 +1,140 @@ +/* + * 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 new file mode 100644 index 000000000..8f1c34983 --- /dev/null +++ b/include/net/icmp.h @@ -0,0 +1,38 @@ +/* + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. INET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * Definitions for the ICMP module. + * + * Version: @(#)icmp.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 _ICMP_H +#define _ICMP_H + +#include <linux/icmp.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, + int redo, struct inet_protocol *protocol); + +extern int icmp_ioctl(struct sock *sk, int cmd, + unsigned long arg); + +#endif /* _ICMP_H */ diff --git a/include/net/ip.h b/include/net/ip.h new file mode 100644 index 000000000..6726e8a48 --- /dev/null +++ b/include/net/ip.h @@ -0,0 +1,115 @@ +/* + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. INET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * Definitions for the IP module. + * + * Version: @(#)ip.h 1.0.2 05/07/93 + * + * Authors: Ross Biro, <bir7@leland.Stanford.Edu> + * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> + * Alan Cox, <gw4pts@gw4pts.ampr.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 _IP_H +#define _IP_H + + +#include <linux/config.h> +#include <linux/types.h> +#include <linux/socket.h> +#include <linux/ip.h> +#include <linux/netdevice.h> + +#ifndef _SNMP_H +#include "snmp.h" +#endif + +#include "sock.h" /* struct sock */ + +/* IP flags. */ +#define IP_CE 0x8000 /* Flag: "Congestion" */ +#define IP_DF 0x4000 /* Flag: "Don't Fragment" */ +#define IP_MF 0x2000 /* Flag: "More Fragments" */ +#define IP_OFFSET 0x1FFF /* "Fragment Offset" part */ + +#define IP_FRAG_TIME (30 * HZ) /* fragment lifetime */ + +#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))) +#endif + + +/* 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; +}; + +/* 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); + +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, + 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);*/ +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 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, + unsigned short int length, + int daddr, + int flags, + int type); + +extern struct ip_mib ip_statistics; + +#endif /* _IP_H */ diff --git a/include/net/ipip.h b/include/net/ipip.h new file mode 100644 index 000000000..398e375de --- /dev/null +++ b/include/net/ipip.h @@ -0,0 +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, + int redo, struct inet_protocol *protocol); + diff --git a/include/net/ipx.h b/include/net/ipx.h new file mode 100644 index 000000000..6842c8325 --- /dev/null +++ b/include/net/ipx.h @@ -0,0 +1,84 @@ + +/* + * The following information is in its entirety obtained from: + * + * Novell 'IPX Router Specification' Version 1.10 + * Part No. 107-000029-001 + * + * Which is available from ftp.novell.com + */ + +#ifndef _NET_INET_IPX_H_ +#define _NET_INET_IPX_H_ + +#include <linux/skbuff.h> +#include "datalink.h" +#include <linux/ipx.h> + +typedef struct +{ + unsigned long net; + unsigned char node[IPX_NODE_LEN]; + unsigned short sock; +} ipx_address; + +#define ipx_broadcast_node "\377\377\377\377\377\377" + +typedef struct ipx_packet +{ + unsigned short ipx_checksum; +#define IPX_NO_CHECKSUM 0xFFFF + unsigned short ipx_pktsize; + unsigned char ipx_tctrl; + unsigned char ipx_type; +#define IPX_TYPE_UNKNOWN 0x00 +#define IPX_TYPE_RIP 0x01 /* may also be 0 */ +#define IPX_TYPE_SAP 0x04 /* may also be 0 */ +#define IPX_TYPE_SPX 0x05 /* Not yet implemented */ +#define IPX_TYPE_NCP 0x11 /* $lots for docs on this (SPIT) */ +#define IPX_TYPE_PPROP 0x14 /* complicated flood fill brdcast [Not supported] */ + ipx_address ipx_dest __attribute__ ((packed)); + ipx_address ipx_source __attribute__ ((packed)); +} ipx_packet; + + +typedef struct sock ipx_socket; + +#include "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); + +typedef struct ipx_interface { + /* IPX address */ + unsigned long if_netnum; + unsigned char if_node[IPX_NODE_LEN]; + + /* physical device info */ + struct device *if_dev; + struct datalink_proto *if_dlink; + unsigned short if_dlink_type; + + /* socket support */ + unsigned short if_sknum; + ipx_socket *if_sklist; + + /* administrative overhead */ + int if_ipx_offset; + unsigned char if_internal; + unsigned char if_primary; + + struct ipx_interface *if_next; +} ipx_interface; + +typedef struct ipx_route { + unsigned long ir_net; + ipx_interface *ir_intrfc; + unsigned char ir_routed; + unsigned char ir_router_node[IPX_NODE_LEN]; + struct ipx_route *ir_next; +} ipx_route; + +#define IPX_MIN_EPHEMERAL_SOCKET 0x4000 +#define IPX_MAX_EPHEMERAL_SOCKET 0x7fff + +#endif diff --git a/include/net/ipxcall.h b/include/net/ipxcall.h new file mode 100644 index 000000000..eb5bd2bd2 --- /dev/null +++ b/include/net/ipxcall.h @@ -0,0 +1,2 @@ +/* Separate to keep compilation of protocols.c simpler */ +extern void ipx_proto_init(struct net_proto *pro); diff --git a/include/net/netrom.h b/include/net/netrom.h new file mode 100644 index 000000000..c6f772920 --- /dev/null +++ b/include/net/netrom.h @@ -0,0 +1,131 @@ +/* + * Declarations of NET/ROM type objects. + * + * Jonathan Naylor G4KLX 9/4/95 + */ + +#ifndef _NETROM_H +#define _NETROM_H +#include <linux/netrom.h> + +#define NR_PROTO_IP 0x0C + +#define NR_PROTOEXT 0x00 +#define NR_CONNREQ 0x01 +#define NR_CONNACK 0x02 +#define NR_DISCREQ 0x03 +#define NR_DISCACK 0x04 +#define NR_INFO 0x05 +#define NR_INFOACK 0x06 + +#define NR_CHOKE_FLAG 0x80 +#define NR_NAK_FLAG 0x40 +#define NR_MORE_FLAG 0x20 + +/* Define Link State constants. */ + +#define NR_STATE_0 0 +#define NR_STATE_1 1 +#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_MODULUS 256 +#define NR_MAX_WINDOW_SIZE 127 /* Maximum Window Allowable */ + +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; + 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; + struct sock *sk; /* Backlink to socket */ +} nr_cb; + +struct nr_route { + unsigned char quality; + unsigned char obs_count; + unsigned short neighbour; +}; + +struct nr_node { + struct nr_node *next; + ax25_address callsign; + char mnemonic[7]; + unsigned char which; + unsigned char count; + 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; +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" + +/* 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_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); + +/* nr_route.c */ +extern void nr_rt_device_down(struct device *); +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); + +/* nr_subr.c */ +extern void nr_clear_tx_queue(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); +extern int nr_in_rx_window(struct sock *, unsigned short); +extern void nr_write_internal(struct sock *, int); +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 */ +extern void nr_set_timer(struct sock *); + +#endif diff --git a/include/net/nrcall.h b/include/net/nrcall.h new file mode 100644 index 000000000..f58c2d4fe --- /dev/null +++ b/include/net/nrcall.h @@ -0,0 +1,2 @@ +/* Seperate 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 new file mode 100644 index 000000000..52c676be2 --- /dev/null +++ b/include/net/p8022.h @@ -0,0 +1,2 @@ +struct datalink_proto *register_8022_client(unsigned char type, int (*rcvfunc)(struct sk_buff *, struct device *, struct packet_type *)); + diff --git a/include/net/p8022call.h b/include/net/p8022call.h new file mode 100644 index 000000000..14f0c2cee --- /dev/null +++ b/include/net/p8022call.h @@ -0,0 +1,2 @@ +/* Separate to keep compilation of Space.c simpler */ +extern void p8022_proto_init(struct net_proto *); diff --git a/include/net/protocol.h b/include/net/protocol.h new file mode 100644 index 000000000..3e0b6fb3c --- /dev/null +++ b/include/net/protocol.h @@ -0,0 +1,59 @@ +/* + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. INET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * Definitions for the protocol dispatcher. + * + * Version: @(#)protocol.h 1.0.2 05/07/93 + * + * Author: 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. + * + * Changes: + * Alan Cox : Added a name field and a frag handler + * field for later. + */ + +#ifndef _PROTOCOL_H +#define _PROTOCOL_H + + +#define MAX_INET_PROTOS 32 /* Must be a power of 2 */ + + +/* 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, + 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); + struct inet_protocol *next; + unsigned char protocol; + unsigned char copy:1; + void *data; + char *name; +}; + + +extern struct inet_protocol *inet_protocol_base; +extern struct inet_protocol *inet_protos[MAX_INET_PROTOS]; + + +extern void inet_add_protocol(struct inet_protocol *prot); +extern int inet_del_protocol(struct inet_protocol *prot); + + +#endif /* _PROTOCOL_H */ diff --git a/include/net/psnap.h b/include/net/psnap.h new file mode 100644 index 000000000..b69859dbd --- /dev/null +++ b/include/net/psnap.h @@ -0,0 +1,2 @@ +struct datalink_proto *register_snap_client(unsigned char *desc, int (*rcvfunc)(struct sk_buff *, struct device *, struct packet_type *)); + diff --git a/include/net/psnapcall.h b/include/net/psnapcall.h new file mode 100644 index 000000000..9da5763c5 --- /dev/null +++ b/include/net/psnapcall.h @@ -0,0 +1,2 @@ +/* Separate to keep compilation of Space.c simpler */ +extern void snap_proto_init(struct net_proto *); diff --git a/include/net/rarp.h b/include/net/rarp.h new file mode 100644 index 000000000..02ee7784f --- /dev/null +++ b/include/net/rarp.h @@ -0,0 +1,14 @@ +/* linux/net/inet/rarp.h */ +#ifndef _RARP_H +#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); +#endif /* _RARP_H */ + diff --git a/include/net/raw.h b/include/net/raw.h new file mode 100644 index 000000000..8f1cf0c22 --- /dev/null +++ b/include/net/raw.h @@ -0,0 +1,34 @@ +/* + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. INET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * Definitions for the RAW-IP module. + * + * Version: @(#)raw.h 1.0.2 05/07/93 + * + * Author: 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 _RAW_H +#define _RAW_H + + +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 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); + +#endif /* _RAW_H */ diff --git a/include/net/route.h b/include/net/route.h new file mode 100644 index 000000000..d85fefdcd --- /dev/null +++ b/include/net/route.h @@ -0,0 +1,56 @@ +/* + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. INET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * Definitions for the IP router. + * + * Version: @(#)route.h 1.0.4 05/27/93 + * + * Authors: Ross Biro, <bir7@leland.Stanford.Edu> + * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> + * Fixes: + * Alan Cox : Reformatted. Added ip_rt_local() + * Alan Cox : Support for TCP parameters. + * + * 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 _ROUTE_H +#define _ROUTE_H + + +#include <linux/route.h> + + +/* 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; + unsigned long rt_window; + struct device *rt_dev; +}; + + +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 int ip_rt_ioctl(unsigned int cmd, void *arg); + +extern unsigned long rt_stamp; + +#endif /* _ROUTE_H */ diff --git a/include/net/snmp.h b/include/net/snmp.h new file mode 100644 index 000000000..552292be6 --- /dev/null +++ b/include/net/snmp.h @@ -0,0 +1,107 @@ +/* + * + * SNMP MIB entries for the IP subsystem. + * + * Alan Cox <gw4pts@gw4pts.ampr.org> + * + * We don't chose to implement SNMP in the kernel (this would + * be silly as SNMP is a pain in the backside in places). We do + * however need to collect the MIB statistics and export them + * out of /proc (eventually) + * + * 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 _SNMP_H +#define _SNMP_H + +/* + * We use all unsigned longs. Linux will soon be so reliable that even these + * will rapidly get too small 8-). Seriously consider the IpInReceives count + * on the 20Gb/s + networks people expect in a few years time! + */ + +struct ip_mib +{ + unsigned long IpForwarding; + unsigned long IpDefaultTTL; + unsigned long IpInReceives; + unsigned long IpInHdrErrors; + unsigned long IpInAddrErrors; + unsigned long IpForwDatagrams; + unsigned long IpInUnknownProtos; + unsigned long IpInDiscards; + unsigned long IpInDelivers; + unsigned long IpOutRequests; + unsigned long IpOutDiscards; + unsigned long IpOutNoRoutes; + unsigned long IpReasmTimeout; + unsigned long IpReasmReqds; + unsigned long IpReasmOKs; + unsigned long IpReasmFails; + unsigned long IpFragOKs; + unsigned long IpFragFails; + unsigned long IpFragCreates; +}; + + +struct icmp_mib +{ + unsigned long IcmpInMsgs; + unsigned long IcmpInErrors; + unsigned long IcmpInDestUnreachs; + unsigned long IcmpInTimeExcds; + unsigned long IcmpInParmProbs; + unsigned long IcmpInSrcQuenchs; + unsigned long IcmpInRedirects; + unsigned long IcmpInEchos; + unsigned long IcmpInEchoReps; + unsigned long IcmpInTimestamps; + unsigned long IcmpInTimestampReps; + unsigned long IcmpInAddrMasks; + unsigned long IcmpInAddrMaskReps; + unsigned long IcmpOutMsgs; + unsigned long IcmpOutErrors; + unsigned long IcmpOutDestUnreachs; + unsigned long IcmpOutTimeExcds; + unsigned long IcmpOutParmProbs; + unsigned long IcmpOutSrcQuenchs; + unsigned long IcmpOutRedirects; + unsigned long IcmpOutEchos; + unsigned long IcmpOutEchoReps; + unsigned long IcmpOutTimestamps; + unsigned long IcmpOutTimestampReps; + unsigned long IcmpOutAddrMasks; + unsigned long IcmpOutAddrMaskReps; +}; + +struct tcp_mib +{ + unsigned long TcpRtoAlgorithm; + unsigned long TcpRtoMin; + unsigned long TcpRtoMax; + unsigned long TcpMaxConn; + unsigned long TcpActiveOpens; + unsigned long TcpPassiveOpens; + unsigned long TcpAttemptFails; + unsigned long TcpEstabResets; + unsigned long TcpCurrEstab; + unsigned long TcpInSegs; + unsigned long TcpOutSegs; + unsigned long TcpRetransSegs; +}; + +struct udp_mib +{ + unsigned long UdpInDatagrams; + unsigned long UdpNoPorts; + unsigned long UdpInErrors; + unsigned long UdpOutDatagrams; +}; + + +#endif diff --git a/include/net/sock.h b/include/net/sock.h new file mode 100644 index 000000000..be7c84591 --- /dev/null +++ b/include/net/sock.h @@ -0,0 +1,354 @@ +/* + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. INET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * Definitions for the AF_INET socket handler. + * + * Version: @(#)sock.h 1.0.4 05/13/93 + * + * Authors: Ross Biro, <bir7@leland.Stanford.Edu> + * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> + * Corey Minyard <wf-rch!minyard@relay.EU.net> + * Florian La Roche <flla@stud.uni-sb.de> + * + * Fixes: + * Alan Cox : Volatiles in skbuff pointers. See + * skbuff comments. May be overdone, + * better to prove they can be removed + * than the reverse. + * Alan Cox : Added a zapped field for tcp to note + * a socket is reset and must stay shut up + * Alan Cox : New fields for options + * Pauline Middelink : identd support + * + * 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 _SOCK_H +#define _SOCK_H + +#include <linux/timer.h> +#include <linux/ip.h> /* struct options */ +#include <linux/in.h> /* struct sockaddr_in */ +#include <linux/tcp.h> /* struct tcphdr */ +#include <linux/config.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" +#endif +#endif +#ifdef CONFIG_IPX +#include "ipx.h" +#endif +#ifdef CONFIG_ATALK +#include "atalk.h" +#endif + +#include <linux/igmp.h> + +#define SOCK_ARRAY_SIZE 256 /* Think big (also on some systems a byte is faster */ + + +/* + * 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; + + /* + * Not all are volatile, but some are, so we + * might as well say they all are. + */ + volatile char inuse, + dead, + urginline, + intr, + blog, + done, + 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 + */ + 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; +#endif +#ifdef CONFIG_AX25 + ax25_cb *ax25; +#ifdef CONFIG_NETROM + nr_cb *nr; +#endif +#endif +#ifdef CONFIG_ATALK + struct atalk_sock at; +#endif + +/* 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 */ +#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 */ +#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; + + /* identd */ + 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); + +}; + +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 +}; + +#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 PROT_SOCK 1024 /* Sockets 0-1023 can't be bound too unless you are superuser */ + +#define SHUTDOWN_MASK 3 +#define RCV_SHUTDOWN 1 +#define SEND_SHUTDOWN 2 + + +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 struct sock *get_sock(struct proto *, unsigned short, + unsigned long, unsigned short, + unsigned long); +extern struct sock *get_sock_mcast(struct sock *, unsigned short, + unsigned long, unsigned short, + unsigned long); +extern struct sock *get_sock_raw(struct sock *, unsigned short, + unsigned long, unsigned long); + +extern struct sk_buff *sock_wmalloc(struct sock *sk, + unsigned long size, int force, + int priority); +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 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_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); + +/* + * 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. + */ + +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) + return -ENOMEM; + save_flags(flags); + cli(); + sk->rmem_alloc+=skb->mem_len; + skb->sk=sk; + restore_flags(flags); + skb_queue_tail(&sk->receive_queue,skb); + if(!sk->dead) + sk->data_ready(sk,skb->len); + return 0; +} + +/* 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); + + +/* Enable debug/info messages */ + +#define NETDEBUG(x) x + +#endif /* _SOCK_H */ diff --git a/include/net/tcp.h b/include/net/tcp.h new file mode 100644 index 000000000..efeaac0da --- /dev/null +++ b/include/net/tcp.h @@ -0,0 +1,142 @@ +/* + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. INET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * Definitions for the TCP module. + * + * Version: @(#)tcp.h 1.0.5 05/23/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 _TCP_H +#define _TCP_H + +#include <linux/tcp.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 +#define MIN_WINDOW 2048 +#define MAX_ACK_BACKLOG 2 +#define MIN_WRITE_SPACE 2048 +#define TCP_WINDOW_DIFF 2048 + +/* urg_data states */ +#define URG_VALID 0x0100 +#define URG_NOTYET 0x0200 +#define URG_READ 0x0400 + +#define TCP_RETR1 7 /* + * This is how many retries it does before it + * tries to figure out if the gateway is + * down. + */ + +#define TCP_RETR2 15 /* + * This should take at least + * 90 minutes to time out. + */ + +#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_ACK_TIME (3*HZ) /* time to delay before sending an ACK */ +#define TCP_DONE_TIME 250 /* maximum time to wait before actually + * destroying a socket */ +#define TCP_WRITE_TIME 3000 /* 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 + * I've got something to write and + * there is no window */ + +#define TCP_NO_CHECK 0 /* turn to one if you want the default + * to be no checksum */ + + +/* + * TCP option + */ + +#define TCPOPT_NOP 1 /* Padding */ +#define TCPOPT_EOL 0 /* End of options */ +#define TCPOPT_MSS 2 /* Segment size negotiating */ +/* + * We don't use these yet, but they are for PAWS and big windows + */ +#define TCPOPT_WINDOW 3 /* Window scaling */ +#define TCPOPT_TIMESTAMP 8 /* Better RTT estimations/PAWS */ + + +/* + * 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) +{ + return (long)(seq1-seq2) < 0; +} + +extern __inline int after(unsigned long seq1, unsigned long seq2) +{ + return (long)(seq1-seq2) > 0; +} + + +/* is s2<=s1<=s3 ? */ +extern __inline int between(unsigned long seq1, unsigned long seq2, unsigned long seq3) +{ + return (after(seq1+1, seq2) && before(seq1, seq3+1)); +} + + +/* + * 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) +{ + return(state == TCP_ESTABLISHED || state == TCP_CLOSE_WAIT || + state == TCP_FIN_WAIT1 || state == TCP_FIN_WAIT2 || + state == TCP_SYN_RECV); +} + + +extern struct proto tcp_prot; + + +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); + +extern int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg); + +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); + +#endif /* _TCP_H */ diff --git a/include/net/udp.h b/include/net/udp.h new file mode 100644 index 000000000..62f0c7a0e --- /dev/null +++ b/include/net/udp.h @@ -0,0 +1,52 @@ +/* + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. INET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * Definitions for the UDP module. + * + * Version: @(#)udp.h 1.0.2 05/07/93 + * + * Authors: Ross Biro, <bir7@leland.Stanford.Edu> + * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> + * + * Fixes: + * Alan Cox : Turned on udp checksums. I don't want to + * chase 'memory corruption' bugs that aren't! + * + * 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 _UDP_H +#define _UDP_H + +#include <linux/udp.h> + + +#define UDP_NO_CHECK 0 + + +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 int udp_connect(struct sock *sk, + struct sockaddr_in *usin, int addr_len); +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 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 */ + +#endif /* _UDP_H */ diff --git a/include/net/unix.h b/include/net/unix.h new file mode 100644 index 000000000..dba43800f --- /dev/null +++ b/include/net/unix.h @@ -0,0 +1,69 @@ +/* + * 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); |