. service tells you which device it couldn't stat
[minix3.git] / servers / inet / generic / ip_int.h
bloba9bbfa7039b9993073395eb68788a0d0c4f0b031
1 /*
2 ip_int.h
4 Copyright 1995 Philip Homburg
5 */
7 #ifndef INET_IP_INT_H
8 #define INET_IP_INT_H
10 #define IP_FD_NR (8*IP_PORT_MAX)
11 #define IP_ASS_NR 3
13 #define IP_42BSD_BCAST 1 /* hostnumber 0 is also network
14 broadcast */
16 #define IP_LT_NORMAL 0 /* Normal */
17 #define IP_LT_BROADCAST 1 /* Broadcast */
18 #define IP_LT_MULTICAST 2 /* Multicast */
20 struct ip_port;
21 struct ip_fd;
22 typedef void (*ip_dev_t) ARGS(( struct ip_port *ip_port ));
23 typedef int (*ip_dev_send_t) ARGS(( struct ip_port *ip_port, ipaddr_t dest,
24 acc_t *pack, int type ));
26 #define IP_PROTO_HASH_NR 32
28 typedef struct ip_port
30 int ip_flags, ip_dl_type;
31 int ip_port;
32 union
34 struct
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
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;
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
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
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 */
90 #define IPDL_ETH NETTYPE_ETH
91 #define IPDL_PSIP NETTYPE_PSIP
93 typedef struct ip_ass
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;
103 typedef struct ip_fd
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;
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
127 typedef enum nettype
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;
140 struct nwio_ipconf;
142 /* ip_eth.c */
143 int ipeth_init ARGS(( ip_port_t *ip_port ));
145 /* ip_ioctl.c */
146 void ip_hash_proto ARGS(( ip_fd_t *ip_fd ));
147 void ip_unhash_proto ARGS(( ip_fd_t *ip_fd ));
148 int ip_setconf ARGS(( int ip_port, struct nwio_ipconf *ipconfp ));
150 /* ip_lib.c */
151 ipaddr_t ip_get_netmask ARGS(( ipaddr_t hostaddr ));
152 ipaddr_t ip_get_ifaddr ARGS(( int ip_port_nr ));
153 int ip_chk_hdropt ARGS(( u8_t *opt, int optlen ));
154 void ip_print_frags ARGS(( acc_t *acc ));
155 nettype_t ip_nettype ARGS(( ipaddr_t ipaddr ));
156 ipaddr_t ip_netmask ARGS(( nettype_t nettype ));
157 char *ip_nettoa ARGS(( nettype_t nettype ));
159 /* ip_ps.c */
160 int ipps_init ARGS(( ip_port_t *ip_port ));
161 void ipps_get ARGS(( int ip_port_nr ));
162 void ipps_put ARGS(( int ip_port_nr, ipaddr_t nexthop, acc_t *pack ));
164 /* ip_read.c */
165 void ip_port_arrive ARGS(( ip_port_t *port, acc_t *pack, ip_hdr_t *ip_hdr ));
166 void ip_arrived ARGS(( ip_port_t *port, acc_t *pack ));
167 void ip_arrived_broadcast ARGS(( ip_port_t *port, acc_t *pack ));
168 void ip_process_loopb ARGS(( event_t *ev, ev_arg_t arg ));
169 void ip_packet2user ARGS(( ip_fd_t *ip_fd, acc_t *pack, time_t exp_time,
170 size_t data_len ));
172 /* ip_write.c */
173 void dll_eth_write_frame ARGS(( ip_port_t *port ));
174 acc_t *ip_split_pack ARGS(( ip_port_t *ip_port, acc_t **ref_last, int mtu ));
175 void ip_hdr_chksum ARGS(( ip_hdr_t *ip_hdr, int ip_hdr_len ));
178 extern ip_fd_t ip_fd_table[IP_FD_NR];
179 extern ip_port_t *ip_port_table;
180 extern ip_ass_t ip_ass_table[IP_ASS_NR];
182 #define NWIO_DEFAULT (NWIO_EN_LOC | NWIO_EN_BROAD | NWIO_REMANY | \
183 NWIO_RWDATALL | NWIO_HDR_O_SPEC)
185 #endif /* INET_IP_INT_H */
188 * $PchId: ip_int.h,v 1.19 2004/08/03 16:24:23 philip Exp $