sock_var.h

Go to the documentation of this file.
00001 #ifndef _SYS_SOCK_VAR_H_
00002 #define _SYS_SOCK_VAR_H_
00003 
00004 /*
00005  * Copyright (C) 2001-2005 by egnite Software GmbH. All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions
00009  * are met:
00010  *
00011  * 1. Redistributions of source code must retain the above copyright
00012  *    notice, this list of conditions and the following disclaimer.
00013  * 2. Redistributions in binary form must reproduce the above copyright
00014  *    notice, this list of conditions and the following disclaimer in the
00015  *    documentation and/or other materials provided with the distribution.
00016  * 3. Neither the name of the copyright holders nor the names of
00017  *    contributors may be used to endorse or promote products derived
00018  *    from this software without specific prior written permission.
00019  *
00020  * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
00021  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00022  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00023  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
00024  * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00025  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00026  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00027  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00028  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00029  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00030  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00031  * SUCH DAMAGE.
00032  *
00033  * For additional information see http://www.ethernut.de/
00034  *
00035  * -
00036  * Portions Copyright (c) 1983, 1993 by
00037  *  The Regents of the University of California.  All rights reserved.
00038  *
00039  * Redistribution and use in source and binary forms, with or without
00040  * modification, are permitted provided that the following conditions
00041  * are met:
00042  * 1. Redistributions of source code must retain the above copyright
00043  *    notice, this list of conditions and the following disclaimer.
00044  * 2. Redistributions in binary form must reproduce the above copyright
00045  *    notice, this list of conditions and the following disclaimer in the
00046  *    documentation and/or other materials provided with the distribution.
00047  * 3. Neither the name of the University nor the names of its contributors
00048  *    may be used to endorse or promote products derived from this software
00049  *    without specific prior written permission.
00050  *
00051  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00052  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00053  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00054  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00055  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00056  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00057  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00058  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00059  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00060  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00061  * SUCH DAMAGE.
00062  */
00063 
00064 /*
00065  * $Log: sock_var.h,v $
00066  * Revision 1.10  2007/08/29 07:43:54  haraldkipp
00067  * Documentation updated and corrected.
00068  *
00069  * Revision 1.9  2006/03/21 21:22:19  drsung
00070  * Enhancement made to TCP state machine. Now TCP options
00071  * are read from peer and at least the maximum segment size is stored.
00072  *
00073  * Revision 1.8  2005/08/02 17:46:49  haraldkipp
00074  * Major API documentation update.
00075  *
00076  * Revision 1.7  2005/06/05 16:48:25  haraldkipp
00077  * Additional parameter enables NutUdpInput() to avoid responding to UDP
00078  * broadcasts with ICMP unreachable messages. Fixes bug #1215192.
00079  *
00080  * Revision 1.6  2004/07/30 19:54:46  drsung
00081  * Some code of TCP stack redesigned. Round trip time calculation is now
00082  * supported. Fixed several bugs in TCP state machine. Now TCP connections
00083  * should be more reliable under heavy traffic or poor physical connections.
00084  *
00085  * Revision 1.5  2004/03/16 16:48:44  haraldkipp
00086  * Added Jan Dubiec's H8/300 port.
00087  *
00088  * Revision 1.4  2004/01/14 19:33:13  drsung
00089  * New TCP output buffer handling
00090  *
00091  * Revision 1.3  2003/11/24 21:00:21  drsung
00092  * Packet queue added for UDP sockets.
00093  *
00094  * Revision 1.2  2003/07/13 19:32:12  haraldkipp
00095  * Faster TCP transfers by changing receive buffer
00096  *
00097  * Revision 1.1.1.1  2003/05/09 14:41:22  haraldkipp
00098  * Initial using 3.2.1
00099  *
00100  * Revision 1.10  2003/02/04 18:00:53  harald
00101  * Version 3 released
00102  *
00103  * Revision 1.9  2002/09/03 17:50:18  harald
00104  * Configurable receive buffer size
00105  *
00106  * Revision 1.8  2002/08/16 17:54:19  harald
00107  * Count out of sequence drops
00108  *
00109  * Revision 1.7  2002/06/26 17:29:29  harald
00110  * First pre-release with 2.4 stack
00111  *
00112  */
00113 
00114 #include <sys/types.h>
00115 #include <dev/netbuf.h>
00116 
00122 #ifdef __cplusplus
00123 extern "C" {
00124 #endif
00125 
00126 /*********************************************************************\
00127  * UDP
00128 \*********************************************************************/
00129 
00134 
00138 typedef struct udp_socket UDPSOCKET;
00139 
00146 struct udp_socket {
00147     UDPSOCKET *so_next;     
00148     u_short so_local_port;  
00149     NETBUF  *so_rx_nb;      
00150     HANDLE  so_rx_rdy;      
00151     u_short so_rx_cnt;      
00152     u_short so_rx_bsz;      
00153 };
00154 
00157 extern void NutUdpInput(NETBUF *nb, ureg_t bcast);
00158 extern int NutUdpOutput(UDPSOCKET *sock, u_long dest, u_short port, NETBUF *nb);
00159 
00160 
00161 /*********************************************************************\
00162  * TCP
00163 \*********************************************************************/
00164 
00169 
00173 typedef struct tcp_socket TCPSOCKET;
00174 
00181 struct tcp_socket {
00182     TCPSOCKET *so_next;     
00183     void *so_device;        
00184     u_char so_devtype;      
00185     int (*so_devread) (TCPSOCKET *, void *, int); 
00186     int (*so_devwrite) (TCPSOCKET *, CONST void *, int); 
00187 #ifdef __HARVARD_ARCH__
00188     int (*so_devwrite_P) (TCPSOCKET *, PGM_P, int); 
00189 #endif
00190     int (*so_devioctl) (TCPSOCKET *, int, void *); 
00192     u_short so_devocnt;     
00193     u_char *so_devobuf;     
00194     u_short so_devobsz;     
00196     volatile u_char  so_state;       
00197     u_long  so_local_addr;  
00198     u_short so_local_port;  
00199     u_long  so_remote_addr; 
00200     u_short so_remote_port; 
00202     u_char  so_tx_flags;    
00203     u_long  so_tx_isn;      
00204     u_long  so_tx_una;      
00205     u_long  so_tx_nxt;      
00206     u_long  so_tx_wl1;      
00207     u_long  so_tx_wl2;      
00208     u_short so_tx_win;      
00209     u_char  so_tx_dup;      
00210     NETBUF  *so_tx_nbq;     
00211     HANDLE  so_tx_tq;       
00213     u_long  so_rx_isn;      
00214     u_long  so_rx_nxt;      
00215     u_short so_rx_win;      
00216     u_short so_rx_cnt;      
00217     u_short so_rx_bsz;      
00218     u_short so_rd_cnt;      
00219     NETBUF  *so_rx_buf;     
00220     HANDLE  so_rx_tq;       
00221     NETBUF  *so_rx_nbq;     
00223     u_short so_mss;         
00225     u_long  so_rtt_seq;     
00226     u_short so_rtto;        
00227     u_short so_retransmits; 
00228     u_short so_time_wait;   
00229     u_short so_retran_time; 
00230     u_short so_last_error;  
00231     HANDLE  so_pc_tq;       
00232     HANDLE  so_ac_tq;       
00234     u_long  so_read_to;     
00235     u_long  so_write_to;    
00236     u_long  so_oos_drop;    
00237 };
00238 
00239 /*
00240  * TCP send flags.
00241  */
00242 #define SO_FIN      0x01    
00243 #define SO_SYN      0x02    
00244 #define SO_FORCE    0x08    
00245 #define SO_ACK      0x10    
00248 
00249 #include <netinet/tcp_fsm.h>
00250 
00251 extern int NutTcpOutput(TCPSOCKET *sock, CONST u_char *data, u_short size);
00252 extern int NutTcpReject(NETBUF *nb);
00253 
00254 #ifdef __cplusplus
00255 }
00256 #endif
00257 
00258 #endif

© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/