Please wait until the page is fully downloaded and then press the "Expand" button or the blue line numbers.

0038001 /*
0038002 ip_int.h
0038003 
0038004 Copyright 1995 Philip Homburg
0038005 */
0038006 
0038007 #ifndef INET_IP_INT_H
0038008 #define INET_IP_INT_H
0038009 
0038010 #define IP_FD_NR       (8*IP_PORT_MAX)
0038011 #define IP_ASS_NR       3
0038012 
0038013 #define IP_42BSD_BCAST              1       /* hostnumber 0 is also network
0038014                                               broadcast */
0038015 
0038016 struct ip_port;
0038017 struct ip_fd;
0038018 typedef void (*ip_dev_t) ARGS(( struct ip_port *ip_port ));
0038019 typedef int (*ip_dev_send_t) ARGS(( struct ip_port *ip_port, ipaddr_t dest,
0038020                                           acc_t *pack, int broadcast ));
0038021 
0038022 #define IP_PROTO_HASH_NR       32
0038023 
0038024 typedef struct ip_port
0038025 {
0038026          int ip_flags, ip_dl_type;
0038027          int ip_port;
0038028          union
0038029          {
0038030                   struct
0038031                   {
0038032                            int de_state;
0038033                            int de_flags;
0038034                            int de_port;
0038035                            int de_fd;
0038036                            acc_t *de_frame;
0038037                            acc_t *de_q_head;
0038038                            acc_t *de_q_tail;
0038039                            acc_t *de_arp_head;
0038040                            acc_t *de_arp_tail;
0038041                   } dl_eth;
0038042                   struct
0038043                   {
0038044                            int ps_port;
0038045                            acc_t *ps_send_head;
0038046                            acc_t *ps_send_tail;
0038047                   } dl_ps;
0038048          } ip_dl;
0038049          ipaddr_t ip_ipaddr;
0038050          ipaddr_t ip_netmask;
0038051          ipaddr_t ip_subnetmask;
0038052          u16_t ip_frame_id;
0038053          u16_t ip_mss;
0038054          ip_dev_t ip_dev_main;
0038055          ip_dev_t ip_dev_set_ipaddr;
0038056          ip_dev_send_t ip_dev_send;
0038057          acc_t *ip_loopb_head;
0038058          acc_t *ip_loopb_tail;
0038059          event_t ip_loopb_event;
0038060          struct ip_fd *ip_proto_any;
0038061          struct ip_fd *ip_proto[IP_PROTO_HASH_NR];
0038062 } ip_port_t;
0038063 
0038064 #define IES_EMPTY       0x0
0038065 #define       IES_SETPROTO       0x1
0038066 #define       IES_GETIPADDR       0x2
0038067 #define       IES_MAIN       0x3
0038068 #define       IES_ERROR       0x4
0038069 
0038070 #define IEF_EMPTY       0x1
0038071 #define IEF_SUSPEND       0x8
0038072 #define IEF_READ_IP       0x10
0038073 #define IEF_READ_SP       0x20
0038074 #define IEF_WRITE_SP       0x80
0038075 
0038076 #define IPF_EMPTY       0x0
0038077 #define IPF_CONFIGURED       0x1
0038078 #define IPF_IPADDRSET       0x2
0038079 #define IPF_NETMASKSET       0x4
0038080 
0038081 #define IPDL_ETH       NETTYPE_ETH
0038082 #define IPDL_PSIP       NETTYPE_PSIP
0038083 
0038084 typedef struct ip_ass
0038085 {
0038086          acc_t *ia_frags;
0038087          int ia_min_ttl;
0038088          ip_port_t *ia_port;
0038089          time_t ia_first_time;
0038090          ipaddr_t ia_srcaddr, ia_dstaddr;
0038091          int ia_proto, ia_id;
0038092 } ip_ass_t;
0038093 
0038094 typedef struct ip_fd
0038095 {
0038096          int if_flags;
0038097          struct nwio_ipopt if_ipopt;
0038098          ip_port_t *if_port;
0038099          struct ip_fd *if_proto_next;
0038100          int if_srfd;
0038101          acc_t *if_rdbuf_head;
0038102          acc_t *if_rdbuf_tail;
0038103          get_userdata_t if_get_userdata;
0038104          put_userdata_t if_put_userdata;
0038105          put_pkt_t if_put_pkt;
0038106          time_t if_exp_time;
0038107          size_t if_rd_count;
0038108 } ip_fd_t;
0038109 
0038110 #define IFF_EMPTY       0x0
0038111 #define IFF_INUSE       0x1
0038112 #define IFF_OPTSET       0x2
0038113 #define IFF_BUSY       0xC
0038114 #       define IFF_READ_IP       0x4
0038115 #       define IFF_GIPCONF_IP       0x8
0038116 
0038117 typedef enum nettype
0038118 {
0038119          IPNT_ZERO,              /* 0.xx.xx.xx */
0038120          IPNT_CLASS_A,              /* 1.xx.xx.xx .. 126.xx.xx.xx */
0038121          IPNT_LOCAL,              /* 127.xx.xx.xx */
0038122          IPNT_CLASS_B,              /* 128.xx.xx.xx .. 191.xx.xx.xx */
0038123          IPNT_CLASS_C,              /* 192.xx.xx.xx .. 223.xx.xx.xx */
0038124          IPNT_CLASS_D,              /* 224.xx.xx.xx .. 239.xx.xx.xx */
0038125          IPNT_CLASS_E,              /* 240.xx.xx.xx .. 247.xx.xx.xx */
0038126          IPNT_MARTIAN,              /* 248.xx.xx.xx .. 254.xx.xx.xx + others */
0038127          IPNT_BROADCAST              /* 255.255.255.255 */
0038128 } nettype_t;
0038129 
0038130 /* ip_eth.c */
0038131 int ipeth_init ARGS(( ip_port_t *ip_port ));
0038132 
0038133 /* ip_ioctl.c */
0038134 void ip_hash_proto ARGS(( ip_fd_t *ip_fd ));
0038135 void ip_unhash_proto ARGS(( ip_fd_t *ip_fd ));
0038136 
0038137 /* ip_lib.c */
0038138 ipaddr_t ip_get_netmask ARGS(( ipaddr_t hostaddr ));
0038139 ipaddr_t ip_get_ifaddr ARGS(( int ip_port_nr ));
0038140 int ip_chk_hdropt ARGS(( u8_t *opt, int optlen ));
0038141 void ip_print_frags ARGS(( acc_t *acc ));
0038142 nettype_t ip_nettype ARGS(( ipaddr_t ipaddr ));
0038143 ipaddr_t ip_netmask ARGS(( nettype_t nettype ));
0038144 char *ip_nettoa ARGS(( nettype_t nettype ));
0038145 
0038146 /* ip_ps.c */
0038147 int ipps_init ARGS(( ip_port_t *ip_port ));
0038148 void ipps_get ARGS(( int ip_port_nr ));
0038149 void ipps_put ARGS(( int ip_port_nr, acc_t *pack ));
0038150 
0038151 /* ip_read.c */
0038152 void ip_port_arrive ARGS(( ip_port_t *port, acc_t *pack, ip_hdr_t *ip_hdr ));
0038153 void ip_arrived ARGS(( ip_port_t *port, acc_t *pack ));
0038154 void ip_arrived_broadcast ARGS(( ip_port_t *port, acc_t *pack ));
0038155 void ip_process_loopb ARGS(( event_t *ev, ev_arg_t arg ));
0038156 
0038157 /* ip_write.c */
0038158 void dll_eth_write_frame ARGS(( ip_port_t *port ));
0038159 acc_t *ip_split_pack ARGS(( ip_port_t *ip_port, acc_t **ref_last,
0038160                                                  int first_size ));
0038161 void ip_hdr_chksum ARGS(( ip_hdr_t *ip_hdr, int ip_hdr_len ));
0038162 
0038163 
0038164 extern ip_fd_t ip_fd_table[IP_FD_NR];
0038165 extern ip_port_t *ip_port_table;
0038166 extern ip_ass_t ip_ass_table[IP_ASS_NR];
0038167 
0038168 #define NWIO_DEFAULT (NWIO_EN_LOC | NWIO_EN_BROAD | NWIO_REMANY | \
0038169          NWIO_RWDATALL | NWIO_HDR_O_SPEC)
0038170 
0038171 #endif /* INET_IP_INT_H */
0038172 
0038173 /*
0038174  * $PchId: ip_int.h,v 1.6 1996/12/17 07:59:36 philip Exp $
0038175  */