Milos RTOS v0.3.4a
Real Time Operating System
socket.h
Go to the documentation of this file.
00001 /***************************************************************************
00002  * socket.h
00003  * (C) 2011 Ivan Meleca
00004  * www.milos.it
00005  *
00006 
00007 #   This program is free software; you can redistribute it and/or modify
00008 #   it under the terms of the GNU General Public License as published by
00009 #   the Free Software Foundation; either version 2 of the License, or
00010 #   (at your option) any later version.
00011 #
00012 #   This program is distributed in the hope that it will be useful,
00013 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 #   GNU General Public License for more details.
00016 #
00017 #   You should have received a copy of the GNU General Public License
00018 #   along with this program; if not, write to the Free Software
00019 #   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020 
00021 ***************************************************************************/
00022 
00023 #ifndef __SOCKET_H__
00024 #define __SOCKET_H__
00025 
00026 #include <core/device.h>
00027 #include "netdefs.h"
00028 #include "netbuffer.h"
00029 
00030 #if __CONFIG_COMPILE_NET
00031 
00052 #define __SOCKET_TX_TIMEOUT     1000        
00053 #define __SOCKET_RX_TIMEOUT     1000        
00064 #define __SOCKET_INVALID        __DEV_INVALID
00065 
00075 #define __SOCK_TYPE_TCP         1
00076 #define __SOCK_TYPE_UDP         2
00077 
00090 #define __SOCK_SO_DEBUG         0x0001      
00091 #define __SOCK_SO_ACCEPTCONN    0x0002      
00092 #define __SOCK_SO_REUSEADDR     0x0004      
00093 #define __SOCK_SO_KEEPALIVE     0x0008      
00094 #define __SOCK_SO_DONTROUTE     0x0010      
00095 #define __SOCK_SO_BROADCAST     0x0020      
00096 #define __SOCK_SO_USELOOPBACK   0x0040      
00097 #define __SOCK_SO_LINGER        0x0080      
00098 #define __SOCK_SO_OOBINLINE     0x0100      
00100 #define __SOCK_SO_SNDBUF    0x1001          
00101 #define __SOCK_SO_RCVBUF    0x1002          
00102 #define __SOCK_SO_SNDLOWAT  0x1003          
00103 #define __SOCK_SO_RCVLOWAT  0x1004          
00104 #define __SOCK_SO_SNDTIMEO  0x1005          
00105 #define __SOCK_SO_RCVTIMEO  0x1006          
00106 #define __SOCK_SO_ERROR     0x1007          
00107 #define __SOCK_SO_TYPE      0x1008          
00122 typedef __DEVICE __SOCKET;      
00123 typedef __PDEVICE __PSOCKET;    
00128 typedef struct __socketPdbTag
00129 {
00130     struct __socketPdbTag*  next;           
00131     u8                      type;           
00132     __NET_ADDR              local_addr;     
00133     u16                     local_port;     
00134     __NET_ADDR              rx_src_addr;    
00135     u16                     rx_src_port;    
00136     __NET_ADDR              tx_dst_addr;    
00137     u16                     tx_dst_port;    
00138     __PNET_BUFFER           rxbuf;          
00139     u8                      rxcnt;          
00140     u32                     rxtmo;          
00141     u32                     txtmo;          
00142     u8                      rxsize;         
00143     u32                     rxloss;         
00144     __PSOCKET               sock;           
00146 } __SOCKET_PDB, *__PSOCKET_PDB;
00147 
00152 __PSOCKET __socketCreate(u8 type, u16 port);
00153 i32 __socketDestroy(__PSOCKET socket);
00154 i32 __socketListen(__PSOCKET socket, u16 port);
00155 i32 __socketConnect(__PSOCKET socket, u32 addr, u16 port);
00156 i32 __socketBind(__PSOCKET socket, u32 addr);
00157 i32 __socketClose(__PSOCKET socket);
00158 i32 __socketRecv(__PSOCKET socket, __PVOID buf, u32 qty);
00159 i32 __socketRecvFrom(__PSOCKET socket, u32* addr, u16* port, __PVOID buf, u32 qty);
00160 i32 __socketSend(__PSOCKET socket, __PVOID buf, u32 qty);
00161 i32 __socketSendTo(__PSOCKET socket, u32 addr, u16 port, __PVOID buf, u32 qty);
00162 i32 __socketSetSockOpt(__PSOCKET socket, i16 optname, __PVOID optval, u32 optlen);
00163 __PSOCKET __socketFind(u8 proto, u16 local_port, u16 remote_port, u32 remote_addr);
00164 __PSOCKET __socketAccept(__PSOCKET socket, u32* addr);
00165 
00174 #endif /* __CONFIG_COMPILE_NET */
00175 
00176 #endif /* __SOCKET_H__ */
 All Data Structures Files Functions Variables Typedefs Defines