Free (GPLv2) TCP/IP stack developed by TASS Belgium

Dependents:   lpc1768-picotcp-demo ZeroMQ_PicoTCP_Publisher_demo TCPSocket_HelloWorld_PicoTCP Pico_TCP_UDP_Test ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers proxy_endpoint.h Source File

proxy_endpoint.h

00001 /*********************************************************************
00002 PicoTCP. Copyright (c) 2013 TASS Belgium NV. Some rights reserved.
00003 See LICENSE and COPYING for usage.
00004 
00005 Author: Daniele Lacamera <daniele.lacamera@tass.be>
00006 *********************************************************************/
00007 
00008 #ifndef __PICOTCP_BSD_LAYER
00009 #define __PICOTCP_BSD_LAYER
00010 
00011 extern "C"  {
00012 #include "pico_stack.h"
00013 #include "pico_tree.h"
00014 #include "pico_dns_client.h"
00015 #include "pico_socket.h"
00016 #include "pico_addressing.h"
00017 #include "pico_protocol.h"
00018 #include "pico_config.h"
00019 #include "pico_ipv4.h"
00020 #include "pico_device.h"
00021 };
00022 #include "mbed.h"
00023 #include "rtos.h"
00024 #include "Queue.h"
00025 #include "PicoCondition.h"
00026 
00027 struct sockaddr;
00028 
00029 struct ip_addr_s {
00030     uint32_t s_addr;
00031 };
00032 
00033 typedef struct ip_addr_s ip_addr_t;
00034 
00035 struct sockaddr_in 
00036 {
00037     ip_addr_t sin_addr;
00038     uint16_t sin_family;
00039     uint16_t sin_port;
00040 };
00041 
00042 struct timeval {
00043     uint32_t tv_sec;
00044     uint32_t tv_usec;
00045 };
00046 
00047 /* Description of data base entry for a single host.  */
00048 struct hostent
00049 {
00050   char *h_name;     /* Official name of host.  */
00051   char **h_aliases;   /* Alias list.  */
00052   int h_addrtype;   /* Host address type.  */
00053   int h_length;     /* Length of address.  */
00054   char **h_addr_list;   /* List of addresses from name server.  */
00055 # define  h_addr  h_addr_list[0] /* Address, for backward compatibility.*/
00056 };
00057 
00058 #ifndef PF_INET
00059 #define PF_INET     2
00060 #define PF_INET6    10
00061 #define AF_INET     PF_INET
00062 #define AF_INET6    PF_INET6
00063 
00064 #define SOCK_STREAM 1
00065 #define SOCK_DGRAM  2
00066 
00067 #define SOL_SOCKET 1
00068 #define SO_BROADCAST  6
00069 
00070 #define INADDR_ANY 0u
00071 
00072 #endif
00073 
00074 //#define mbed_dbg printf
00075 #define mbed_dbg(...)
00076 
00077 enum socket_state_e {
00078     SOCK_OPEN,
00079     SOCK_BOUND,
00080     SOCK_LISTEN,
00081     SOCK_CONNECTED,
00082     SOCK_RESET_BY_PEER,
00083     SOCK_CLOSED
00084 };
00085 
00086 typedef int socklen_t;
00087 
00088 void picotcp_init(void);
00089 
00090 struct stack_endpoint * picotcp_socket(uint16_t net, uint16_t proto, uint16_t flags);
00091 int picotcp_state(struct stack_endpoint *);
00092 int picotcp_bind(struct stack_endpoint *, struct sockaddr *local_addr, socklen_t len);
00093 
00094 int picotcp_listen(struct stack_endpoint *, int queue);
00095 int picotcp_connect(struct stack_endpoint *, struct sockaddr *srv_addr, socklen_t len);
00096 struct stack_endpoint * picotcp_accept(struct stack_endpoint *, struct sockaddr *orig, socklen_t *);
00097 int picotcp_select(struct stack_endpoint *, struct timeval *timeout, int read, int write);
00098 
00099 int picotcp_send(struct stack_endpoint *,void * buff, int len, int flags);
00100 int picotcp_recv(struct stack_endpoint *,void * buff, int len, int flags);
00101 int picotcp_sendto(struct stack_endpoint *,void * buff, int len, struct sockaddr*,socklen_t);
00102 int picotcp_recvfrom(struct stack_endpoint *,void * buff, int len, struct sockaddr *, socklen_t *);
00103 int picotcp_read(struct stack_endpoint *,void *buf, int len);
00104 int picotcp_write(struct stack_endpoint *,void *buf, int len);
00105 int picotcp_setsockopt(struct stack_endpoint *, int option, void *value);
00106 int picotcp_getsockopt(struct stack_endpoint *, int option, void *value);
00107 struct hostent * picotcp_gethostbyname(const char *url);
00108 char * picotcp_gethostbyaddr(const char *ip);
00109 int picotcp_close(struct stack_endpoint *);
00110 // set blocking
00111 int picotcp_setblocking(struct stack_endpoint *,int blocking);
00112 int picotcp_join_multicast(struct stack_endpoint *,const char* address,const char* local);
00113 
00114 void picotcp_async_interrupt(void *arg);
00115 struct hostent *picotcp_gethostbyname(const char *name);
00116 
00117 int picotcp_dhcp_server_start(struct pico_dhcp_server_setting *setting);
00118 int picotcp_dns_client_nameserver(const char *ip, int flag);
00119 
00120 #endif