source: trunk/minix/servers/inet/generic/ip_int.h@ 11

Last change on this file since 11 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 4.6 KB
RevLine 
[9]1/*
2ip_int.h
3
4Copyright 1995 Philip Homburg
5*/
6
7#ifndef INET_IP_INT_H
8#define INET_IP_INT_H
9
10#define IP_FD_NR (8*IP_PORT_MAX)
11#define IP_ASS_NR 3
12
13#define IP_42BSD_BCAST 1 /* hostnumber 0 is also network
14 broadcast */
15
16#define IP_LT_NORMAL 0 /* Normal */
17#define IP_LT_BROADCAST 1 /* Broadcast */
18#define IP_LT_MULTICAST 2 /* Multicast */
19
20struct ip_port;
21struct ip_fd;
22typedef void (*ip_dev_t) ARGS(( struct ip_port *ip_port ));
23typedef int (*ip_dev_send_t) ARGS(( struct ip_port *ip_port, ipaddr_t dest,
24 acc_t *pack, int type ));
25
26#define IP_PROTO_HASH_NR 32
27
28typedef struct ip_port
29{
30 int ip_flags, ip_dl_type;
31 int ip_port;
32 union
33 {
34 struct
35 {
36 int de_state;
37 int de_flags;
38 int de_port;
39 int de_fd;
40 acc_t *de_frame;
41 acc_t *de_q_head;
42 acc_t *de_q_tail;
43 acc_t *de_arp_head;
44 acc_t *de_arp_tail;
45 } dl_eth;
46 struct
47 {
48 int ps_port;
49 acc_t *ps_send_head;
50 acc_t *ps_send_tail;
51 } dl_ps;
52 } ip_dl;
53 ipaddr_t ip_ipaddr;
54 ipaddr_t ip_subnetmask;
55 ipaddr_t ip_classfulmask;
56 u16_t ip_frame_id;
57 u16_t ip_mtu;
58 u16_t ip_mtu_max; /* Max MTU for this kind of network */
59 ip_dev_t ip_dev_main;
60 ip_dev_t ip_dev_set_ipaddr;
61 ip_dev_send_t ip_dev_send;
62 acc_t *ip_loopb_head;
63 acc_t *ip_loopb_tail;
64 event_t ip_loopb_event;
65 acc_t *ip_routeq_head;
66 acc_t *ip_routeq_tail;
67 event_t ip_routeq_event;
68 struct ip_fd *ip_proto_any;
69 struct ip_fd *ip_proto[IP_PROTO_HASH_NR];
70} ip_port_t;
71
72#define IES_EMPTY 0x0
73#define IES_SETPROTO 0x1
74#define IES_GETIPADDR 0x2
75#define IES_MAIN 0x3
76#define IES_ERROR 0x4
77
78#define IEF_EMPTY 0x1
79#define IEF_SUSPEND 0x8
80#define IEF_READ_IP 0x10
81#define IEF_READ_SP 0x20
82#define IEF_WRITE_SP 0x80
83
84#define IPF_EMPTY 0x0
85#define IPF_CONFIGURED 0x1
86#define IPF_IPADDRSET 0x2
87#define IPF_NETMASKSET 0x4
88#define IPF_SUBNET_BCAST 0x8 /* Subset support subnet broadcasts */
89
90#define IPDL_ETH NETTYPE_ETH
91#define IPDL_PSIP NETTYPE_PSIP
92
93typedef struct ip_ass
94{
95 acc_t *ia_frags;
96 int ia_min_ttl;
97 ip_port_t *ia_port;
98 time_t ia_first_time;
99 ipaddr_t ia_srcaddr, ia_dstaddr;
100 int ia_proto, ia_id;
101} ip_ass_t;
102
103typedef struct ip_fd
104{
105 int if_flags;
106 struct nwio_ipopt if_ipopt;
107 ip_port_t *if_port;
108 struct ip_fd *if_proto_next;
109 int if_srfd;
110 acc_t *if_rdbuf_head;
111 acc_t *if_rdbuf_tail;
112 get_userdata_t if_get_userdata;
113 put_userdata_t if_put_userdata;
114 put_pkt_t if_put_pkt;
115 time_t if_exp_time;
116 size_t if_rd_count;
117 ioreq_t if_ioctl;
118} ip_fd_t;
119
120#define IFF_EMPTY 0x00
121#define IFF_INUSE 0x01
122#define IFF_OPTSET 0x02
123#define IFF_BUSY 0x1C
124# define IFF_READ_IP 0x04
125# define IFF_IOCTL_IP 0x08
126
127typedef enum nettype
128{
129 IPNT_ZERO, /* 0.xx.xx.xx */
130 IPNT_CLASS_A, /* 1.xx.xx.xx .. 126.xx.xx.xx */
131 IPNT_LOCAL, /* 127.xx.xx.xx */
132 IPNT_CLASS_B, /* 128.xx.xx.xx .. 191.xx.xx.xx */
133 IPNT_CLASS_C, /* 192.xx.xx.xx .. 223.xx.xx.xx */
134 IPNT_CLASS_D, /* 224.xx.xx.xx .. 239.xx.xx.xx */
135 IPNT_CLASS_E, /* 240.xx.xx.xx .. 247.xx.xx.xx */
136 IPNT_MARTIAN, /* 248.xx.xx.xx .. 254.xx.xx.xx + others */
137 IPNT_BROADCAST /* 255.255.255.255 */
138} nettype_t;
139
140struct nwio_ipconf;
141
142/* ip_eth.c */
143int ipeth_init ARGS(( ip_port_t *ip_port ));
144
145/* ip_ioctl.c */
146void ip_hash_proto ARGS(( ip_fd_t *ip_fd ));
147void ip_unhash_proto ARGS(( ip_fd_t *ip_fd ));
148int ip_setconf ARGS(( int ip_port, struct nwio_ipconf *ipconfp ));
149
150/* ip_lib.c */
151ipaddr_t ip_get_netmask ARGS(( ipaddr_t hostaddr ));
152ipaddr_t ip_get_ifaddr ARGS(( int ip_port_nr ));
153int ip_chk_hdropt ARGS(( u8_t *opt, int optlen ));
154void ip_print_frags ARGS(( acc_t *acc ));
155nettype_t ip_nettype ARGS(( ipaddr_t ipaddr ));
156ipaddr_t ip_netmask ARGS(( nettype_t nettype ));
157char *ip_nettoa ARGS(( nettype_t nettype ));
158
159/* ip_ps.c */
160int ipps_init ARGS(( ip_port_t *ip_port ));
161void ipps_get ARGS(( int ip_port_nr ));
162void ipps_put ARGS(( int ip_port_nr, ipaddr_t nexthop, acc_t *pack ));
163
164/* ip_read.c */
165void ip_port_arrive ARGS(( ip_port_t *port, acc_t *pack, ip_hdr_t *ip_hdr ));
166void ip_arrived ARGS(( ip_port_t *port, acc_t *pack ));
167void ip_arrived_broadcast ARGS(( ip_port_t *port, acc_t *pack ));
168void ip_process_loopb ARGS(( event_t *ev, ev_arg_t arg ));
169void ip_packet2user ARGS(( ip_fd_t *ip_fd, acc_t *pack, time_t exp_time,
170 size_t data_len ));
171
172/* ip_write.c */
173void dll_eth_write_frame ARGS(( ip_port_t *port ));
174acc_t *ip_split_pack ARGS(( ip_port_t *ip_port, acc_t **ref_last, int mtu ));
175void ip_hdr_chksum ARGS(( ip_hdr_t *ip_hdr, int ip_hdr_len ));
176
177
178extern ip_fd_t ip_fd_table[IP_FD_NR];
179extern ip_port_t *ip_port_table;
180extern ip_ass_t ip_ass_table[IP_ASS_NR];
181
182#define NWIO_DEFAULT (NWIO_EN_LOC | NWIO_EN_BROAD | NWIO_REMANY | \
183 NWIO_RWDATALL | NWIO_HDR_O_SPEC)
184
185#endif /* INET_IP_INT_H */
186
187/*
188 * $PchId: ip_int.h,v 1.19 2004/08/03 16:24:23 philip Exp $
189 */
Note: See TracBrowser for help on using the repository browser.