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

0054001 /*
0054002 tcp_int.h
0054003 
0054004 Copyright 1995 Philip Homburg
0054005 */
0054006 
0054007 #ifndef TCP_INT_H
0054008 #define TCP_INT_H
0054009 
0054010 #define TCP_CONN_HASH_SHIFT       4
0054011 #define TCP_CONN_HASH_NR       (1 << TCP_CONN_HASH_SHIFT)
0054012 
0054013 typedef struct tcp_port
0054014 {
0054015          int tp_ipdev;
0054016          int tp_flags;
0054017          int tp_state;
0054018          int tp_ipfd;
0054019          acc_t *tp_pack;
0054020          ipaddr_t tp_ipaddr;
0054021          struct tcp_conn *tp_snd_head;
0054022          struct tcp_conn *tp_snd_tail;
0054023          event_t tp_snd_event;
0054024          struct tcp_conn *tp_conn_hash[TCP_CONN_HASH_NR][4];
0054025 } tcp_port_t;
0054026 
0054027 #define TPF_EMPTY       0x0
0054028 #define TPF_SUSPEND       0x1
0054029 #define TPF_READ_IP       0x2
0054030 #define TPF_READ_SP       0x4
0054031 #define TPF_WRITE_IP       0x8
0054032 #define TPF_WRITE_SP       0x10
0054033 #define TPF_DELAY_TCP       0x40
0054034 
0054035 #define TPS_EMPTY       0
0054036 #define TPS_SETPROTO       1
0054037 #define TPS_GETCONF       2
0054038 #define TPS_MAIN       3
0054039 #define TPS_ERROR       4
0054040 
0054041 typedef struct tcp_fd
0054042 {
0054043          int tf_flags;
0054044          tcp_port_t *tf_port;
0054045          int tf_srfd;
0054046          ioreq_t tf_ioreq;
0054047          nwio_tcpconf_t tf_tcpconf;
0054048          nwio_tcpopt_t tf_tcpopt;
0054049          get_userdata_t tf_get_userdata;
0054050          put_userdata_t tf_put_userdata;
0054051          struct tcp_conn *tf_conn;
0054052          size_t tf_write_offset;
0054053          size_t tf_write_count;
0054054          size_t tf_read_offset;
0054055          size_t tf_read_count;
0054056 } tcp_fd_t;
0054057 
0054058 #define TFF_EMPTY        0x0
0054059 #define TFF_INUSE        0x1
0054060 #define TFF_IOCTL_IP        0x2
0054061 #define TFF_CONF_SET        0x4
0054062 #define TFF_IOC_INIT_SP        0x8
0054063 #define TFF_CONNECT        0x20
0054064 #define TFF_WRITE_IP        0x80
0054065 #define TFF_WR_URG        0x100
0054066 #define TFF_PUSH_DATA        0x200
0054067 #define TFF_READ_IP        0x400
0054068 #define TFF_RECV_URG        0x800
0054069 #define TFF_CONNECTED       0x1000
0054070 #define TFF_DEL_RST       0x2000
0054071 
0054072 typedef struct tcp_conn
0054073 {
0054074          int tc_flags;
0054075          int tc_state;
0054076          int tc_busy;              /* do not steal buffer when a counnection is
0054077                                      * busy
0054078                                      */
0054079          tcp_port_t *tc_port;
0054080          tcp_fd_t *tc_fd;
0054081 
0054082          tcpport_t tc_locport;
0054083          ipaddr_t tc_locaddr;
0054084          tcpport_t tc_remport;
0054085          ipaddr_t tc_remaddr;
0054086 
0054087 #if 1
0054088          int tc_connInprogress;
0054089 #endif
0054090          int tc_orglisten;
0054091          time_t tc_senddis;
0054092 
0054093          /* Sending side */
0054094          u32_t tc_ISS;              /* initial sequence number */
0054095          u32_t tc_SND_UNA;       /* least unacknowledged sequence number */
0054096          u32_t tc_SND_TRM;       /* next sequence number to be transmitted */
0054097          u32_t tc_SND_NXT;       /* next sequence number for new data */
0054098          u32_t tc_SND_UP;       /* urgent pointer, first sequence number not
0054099                                      * urgent */
0054100          u32_t tc_SND_PSH;       /* push pointer, data should be pushed until
0054101                                      * the push pointer is reached */
0054102 
0054103          u32_t tc_snd_cwnd;       /* highest sequence number to be sent */
0054104          u32_t tc_snd_cthresh;       /* threshold for send window */
0054105          u32_t tc_snd_cinc;       /* increment for send window threshold */
0054106          u16_t tc_snd_wnd;       /* max send queue size */
0054107 
0054108          /* round trip calculation. */
0054109          time_t tc_rt_time;
0054110          u32_t tc_rt_seq;
0054111          u32_t tc_rt_threshold;
0054112          time_t tc_rtt;
0054113 
0054114          acc_t *tc_send_data;
0054115          acc_t *tc_frag2send;
0054116          struct tcp_conn *tc_send_link;
0054117 
0054118          /* Receiving side */
0054119          u32_t tc_IRS;
0054120          u32_t tc_RCV_LO;
0054121          u32_t tc_RCV_NXT;
0054122          u32_t tc_RCV_HI;
0054123          u32_t tc_RCV_UP;
0054124 
0054125          u16_t tc_rcv_wnd;
0054126          acc_t *tc_rcvd_data;
0054127          acc_t *tc_adv_data;
0054128          u32_t tc_adv_seq;
0054129 
0054130          acc_t *tc_remipopt;
0054131          acc_t *tc_tcpopt;
0054132          u8_t tc_tos;
0054133          u8_t tc_ttl;
0054134          u16_t tc_mss;
0054135 
0054136          struct timer tc_transmit_timer;
0054137          u32_t tc_transmit_seq;
0054138          time_t tc_0wnd_to;
0054139          time_t tc_stt;              /* time of first send after last ack */
0054140          time_t tc_rt_dead;
0054141 
0054142          int tc_error;
0054143          int tc_inconsistent;
0054144 } tcp_conn_t;
0054145 
0054146 #define TCF_EMPTY              0x0
0054147 #define TCF_INUSE              0x1
0054148 #define TCF_FIN_RECV              0x2
0054149 #define TCF_RCV_PUSH              0x4
0054150 #define TCF_MORE2WRITE              0x8
0054151 #define TCF_SEND_ACK              0x10
0054152 #define TCF_FIN_SENT              0x20
0054153 #define TCF_BSD_URG              0x40
0054154 
0054155 #if DEBUG & 0x200
0054156 #define TCF_DEBUG              0x1000
0054157 #endif
0054158 
0054159 #define TCS_CLOSED              0
0054160 #define TCS_LISTEN              1
0054161 #define TCS_SYN_RECEIVED       2
0054162 #define TCS_SYN_SENT              3
0054163 #define TCS_ESTABLISHED              4
0054164 #define TCS_CLOSING              5
0054165 
0054166 /* tcp_recv.c */
0054167 void tcp_frag2conn ARGS(( tcp_conn_t *tcp_conn, ip_hdr_t *ip_hdr,
0054168          tcp_hdr_t *tcp_hdr, acc_t *tcp_data, size_t data_len ));
0054169 void tcp_fd_read ARGS(( tcp_conn_t *tcp_conn, int enq ));
0054170 
0054171 /* tcp_send.c */
0054172 void tcp_conn_write ARGS(( tcp_conn_t *tcp_conn, int enq ));
0054173 void tcp_release_retrans ARGS(( tcp_conn_t *tcp_conn, u32_t seg_ack,
0054174          U16_t new_win ));
0054175 void tcp_set_send_timer ARGS(( tcp_conn_t *tcp_conn ));
0054176 void tcp_fd_write ARGS(( tcp_conn_t *tcp_conn ));
0054177 void tcp_close_connection ARGS(( tcp_conn_t *tcp_conn,
0054178          int error ));
0054179 void tcp_port_write ARGS(( tcp_port_t *tcp_port ));
0054180 void tcp_shutdown ARGS(( tcp_conn_t *tcp_conn ));
0054181 
0054182 /* tcp_lib.c */
0054183 void tcp_extract_ipopt ARGS(( tcp_conn_t *tcp_conn,
0054184          ip_hdr_t *ip_hdr ));
0054185 void tcp_extract_tcpopt ARGS(( tcp_conn_t *tcp_conn,
0054186          tcp_hdr_t *tcp_hdr ));
0054187 void tcp_get_ipopt ARGS(( tcp_conn_t *tcp_conn, ip_hdropt_t
0054188          *ip_hdropt ));
0054189 void tcp_get_tcpopt ARGS(( tcp_conn_t *tcp_conn, tcp_hdropt_t
0054190          *tcp_hdropt ));
0054191 acc_t *tcp_make_header ARGS(( tcp_conn_t *tcp_conn,
0054192          ip_hdr_t **ref_ip_hdr, tcp_hdr_t **ref_tcp_hdr, acc_t *data ));
0054193 u16_t tcp_pack_oneCsum ARGS(( ip_hdr_t *ip_hdr, acc_t *tcp_pack ));
0054194 int tcp_check_conn ARGS(( tcp_conn_t *tcp_conn ));
0054195 void tcp_print_pack ARGS(( ip_hdr_t *ip_hdr, tcp_hdr_t *tcp_hdr ));
0054196 void tcp_print_state ARGS(( tcp_conn_t *tcp_conn ));
0054197 void tcp_print_conn ARGS(( tcp_conn_t *tcp_conn ));
0054198 int tcp_LEmod4G ARGS(( u32_t n1, u32_t n2 ));
0054199 int tcp_Lmod4G ARGS(( u32_t n1, u32_t n2 ));
0054200 int tcp_GEmod4G ARGS(( u32_t n1, u32_t n2 ));
0054201 int tcp_Gmod4G ARGS(( u32_t n1, u32_t n2 ));
0054202 
0054203 /* tcp.c */
0054204 void tcp_restart_connect ARGS(( tcp_fd_t *tcp_fd ));
0054205 int tcp_su4listen ARGS(( tcp_fd_t *tcp_fd ));
0054206 void tcp_reply_ioctl ARGS(( tcp_fd_t *tcp_fd, int reply ));
0054207 void tcp_reply_write ARGS(( tcp_fd_t *tcp_fd, size_t reply ));
0054208 void tcp_reply_read ARGS(( tcp_fd_t *tcp_fd, size_t reply ));
0054209 void tcp_notreach ARGS(( tcp_conn_t *tcp_conn ));
0054210 
0054211 #define TCP_FD_NR       (10*IP_PORT_MAX)
0054212 #define TCP_CONN_NR       (2*TCP_FD_NR)
0054213 
0054214 EXTERN tcp_port_t *tcp_port_table;
0054215 EXTERN tcp_conn_t tcp_conn_table[TCP_CONN_NR];
0054216 EXTERN tcp_fd_t tcp_fd_table[TCP_FD_NR];
0054217 
0054218 #define tcp_Lmod4G(n1,n2)       (!!(((n1)-(n2)) & 0x80000000L))
0054219 #define tcp_GEmod4G(n1,n2)       (!(((n1)-(n2)) & 0x80000000L))
0054220 #define tcp_Gmod4G(n1,n2)       (!!(((n2)-(n1)) & 0x80000000L))
0054221 #define tcp_LEmod4G(n1,n2)       (!(((n2)-(n1)) & 0x80000000L))
0054222 
0054223 #endif /* TCP_INT_H */
0054224 
0054225 /*
0054226  * $PchId: tcp_int.h,v 1.10 1996/05/07 20:51:59 philip Exp $
0054227  */