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.11  2008/04/18 13:32:00  haraldkipp
00067  * Changed size parameter from u_short to int, which is easier to handle
00068  * for 32-bit targets. You need to recompile your ARM code. No impact on
00069  * AVR expected
00070  * I changed u_int to int at some places to avoid some warnings during
00071  * compilation of Nut/Net.
00072  * libs.
00073  *
00074  * Revision 1.10  2007/08/29 07:43:54  haraldkipp
00075  * Documentation updated and corrected.
00076  *
00077  * Revision 1.9  2006/03/21 21:22:19  drsung
00078  * Enhancement made to TCP state machine. Now TCP options
00079  * are read from peer and at least the maximum segment size is stored.
00080  *
00081  * Revision 1.8  2005/08/02 17:46:49  haraldkipp
00082  * Major API documentation update.
00083  *
00084  * Revision 1.7  2005/06/05 16:48:25  haraldkipp
00085  * Additional parameter enables NutUdpInput() to avoid responding to UDP
00086  * broadcasts with ICMP unreachable messages. Fixes bug #1215192.
00087  *
00088  * Revision 1.6  2004/07/30 19:54:46  drsung
00089  * Some code of TCP stack redesigned. Round trip time calculation is now
00090  * supported. Fixed several bugs in TCP state machine. Now TCP connections
00091  * should be more reliable under heavy traffic or poor physical connections.
00092  *
00093  * Revision 1.5  2004/03/16 16:48:44  haraldkipp
00094  * Added Jan Dubiec's H8/300 port.
00095  *
00096  * Revision 1.4  2004/01/14 19:33:13  drsung
00097  * New TCP output buffer handling
00098  *
00099  * Revision 1.3  2003/11/24 21:00:21  drsung
00100  * Packet queue added for UDP sockets.
00101  *
00102  * Revision 1.2  2003/07/13 19:32:12  haraldkipp
00103  * Faster TCP transfers by changing receive buffer
00104  *
00105  * Revision 1.1.1.1  2003/05/09 14:41:22  haraldkipp
00106  * Initial using 3.2.1
00107  *
00108  * Revision 1.10  2003/02/04 18:00:53  harald
00109  * Version 3 released
00110  *
00111  * Revision 1.9  2002/09/03 17:50:18  harald
00112  * Configurable receive buffer size
00113  *
00114  * Revision 1.8  2002/08/16 17:54:19  harald
00115  * Count out of sequence drops
00116  *
00117  * Revision 1.7  2002/06/26 17:29:29  harald
00118  * First pre-release with 2.4 stack
00119  *
00120  */
00121 
00122 #include <stdint.h>
00123 #include <sys/types.h>
00124 #include <dev/netbuf.h>
00125 
00131 #ifdef __cplusplus
00132 extern "C" {
00133 #endif
00134 
00135 /*********************************************************************\
00136  * UDP
00137 \*********************************************************************/
00138 
00143 
00147 typedef struct udp_socket UDPSOCKET;
00148 
00155 struct udp_socket {
00156     UDPSOCKET *so_next;     
00157     u_short so_local_port;  
00158     NETBUF  *so_rx_nb;      
00159     HANDLE  so_rx_rdy;      
00160     int     so_rx_cnt;      
00161     int     so_rx_bsz;      
00162 };
00163 
00166 extern void NutUdpInput(NETBUF *nb, uint_fast8_t bcast);
00167 extern int NutUdpOutput(UDPSOCKET *sock, u_long dest, u_short port, NETBUF *nb);
00168 
00169 
00170 /*********************************************************************\
00171  * TCP
00172 \*********************************************************************/
00173 
00178 
00182 typedef struct tcp_socket TCPSOCKET;
00183 
00190 struct tcp_socket {
00191     TCPSOCKET *so_next;     
00192     void *so_device;        
00193     u_char so_devtype;      
00194     int (*so_devread) (TCPSOCKET *, void *, int); 
00195     int (*so_devwrite) (TCPSOCKET *, CONST void *, int); 
00196 #ifdef __HARVARD_ARCH__
00197     int (*so_devwrite_P) (TCPSOCKET *, PGM_P, int); 
00198 #endif
00199     int (*so_devioctl) (TCPSOCKET *, int, void *); 
00201     u_short so_devocnt;     
00202     u_char *so_devobuf;     
00203     u_short so_devobsz;     
00205     volatile u_char  so_state;       
00206     u_long  so_local_addr;  
00207     u_short so_local_port;  
00208     u_long  so_remote_addr; 
00209     u_short so_remote_port; 
00211     u_char  so_tx_flags;    
00212     u_long  so_tx_isn;      
00213     u_long  so_tx_una;      
00214     u_long  so_tx_nxt;      
00215     u_long  so_tx_wl1;      
00216     u_long  so_tx_wl2;      
00217     u_short so_tx_win;      
00218     u_char  so_tx_dup;      
00219     NETBUF  *so_tx_nbq;     
00220     HANDLE  so_tx_tq;       
00222     u_long  so_rx_isn;      
00223     u_long  so_rx_nxt;      
00224     u_short so_rx_win;      
00225     int     so_rx_cnt;      
00226     int     so_rx_bsz;      
00227     int     so_rd_cnt;      
00228     NETBUF  *so_rx_buf;     
00229     HANDLE  so_rx_tq;       
00230     NETBUF  *so_rx_nbq;     
00232     u_short so_mss;         
00234     u_long  so_rtt_seq;     
00235     u_short so_rtto;        
00236     u_short so_retransmits; 
00237     u_short so_time_wait;   
00238     u_short so_retran_time; 
00239     u_short so_last_error;  
00240     HANDLE  so_pc_tq;       
00241     HANDLE  so_ac_tq;       
00243     u_long  so_read_to;     
00244     u_long  so_write_to;    
00245     u_long  so_oos_drop;    
00246 };
00247 
00248 /*
00249  * TCP send flags.
00250  */
00251 #define SO_FIN      0x01    
00252 #define SO_SYN      0x02    
00253 #define SO_FORCE    0x08    
00254 #define SO_ACK      0x10    
00257 
00258 #include <netinet/tcp_fsm.h>
00259 
00260 extern int NutTcpOutput(TCPSOCKET *sock, CONST u_char *data, u_short size);
00261 extern int NutTcpReject(NETBUF *nb);
00262 
00263 #ifdef __cplusplus
00264 }
00265 #endif
00266 
00267 #endif

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