2003-09-23 01:09:32 -07:00
|
|
|
#ifndef _ECORE_CON_PRIVATE_H
|
|
|
|
#define _ECORE_CON_PRIVATE_H
|
|
|
|
|
2008-10-30 08:26:11 -07:00
|
|
|
#include "ecore_private.h"
|
2006-11-05 08:49:55 -08:00
|
|
|
#include "Ecore_Con.h"
|
2005-09-05 03:17:08 -07:00
|
|
|
#include "Ecore_Data.h"
|
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
#define ECORE_MAGIC_CON_SERVER 0x77665544
|
|
|
|
#define ECORE_MAGIC_CON_CLIENT 0x77556677
|
2007-09-26 09:01:04 -07:00
|
|
|
#define ECORE_MAGIC_CON_URL 0x77074255
|
2003-09-23 01:09:32 -07:00
|
|
|
|
2008-01-08 13:06:43 -08:00
|
|
|
#define ECORE_CON_TYPE 0x0f
|
|
|
|
#define ECORE_CON_SSL 0xf0
|
|
|
|
|
2008-10-30 08:26:11 -07:00
|
|
|
#if USE_GNUTLS
|
|
|
|
# include <gnutls/gnutls.h>
|
|
|
|
#elif USE_OPENSSL
|
|
|
|
# include <openssl/ssl.h>
|
2004-03-31 08:47:45 -08:00
|
|
|
#endif
|
2005-06-24 06:38:27 -07:00
|
|
|
#ifdef HAVE_CURL
|
|
|
|
#include <curl/curl.h>
|
|
|
|
#endif
|
2004-03-31 08:47:45 -08:00
|
|
|
|
2004-04-03 07:03:33 -08:00
|
|
|
#define READBUFSIZ 65536
|
|
|
|
|
2008-10-01 08:27:52 -07:00
|
|
|
typedef enum _Ecore_Con_State
|
|
|
|
{
|
2008-10-30 08:26:11 -07:00
|
|
|
ECORE_CON_CONNECTED,
|
|
|
|
ECORE_CON_DISCONNECTED,
|
|
|
|
ECORE_CON_INPROGRESS
|
2008-10-01 08:27:52 -07:00
|
|
|
} Ecore_Con_State;
|
|
|
|
|
2008-10-30 08:26:11 -07:00
|
|
|
typedef enum _Ecore_Con_Ssl_Error
|
|
|
|
{
|
|
|
|
ECORE_CON_SSL_ERROR_NONE = 0,
|
|
|
|
ECORE_CON_SSL_ERROR_NOT_SUPPORTED,
|
|
|
|
ECORE_CON_SSL_ERROR_INIT_FAILED,
|
|
|
|
ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED,
|
|
|
|
ECORE_CON_SSL_ERROR_SSL2_NOT_SUPPORTED
|
|
|
|
} Ecore_Con_Ssl_Error;
|
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
struct _Ecore_Con_Client
|
|
|
|
{
|
|
|
|
ECORE_MAGIC;
|
|
|
|
int fd;
|
|
|
|
Ecore_Con_Server *server;
|
|
|
|
void *data;
|
|
|
|
Ecore_Fd_Handler *fd_handler;
|
|
|
|
int buf_size;
|
|
|
|
int buf_offset;
|
|
|
|
unsigned char *buf;
|
2006-03-19 23:45:58 -08:00
|
|
|
char *ip;
|
2006-03-19 21:53:12 -08:00
|
|
|
int event_count;
|
2008-10-30 08:26:11 -07:00
|
|
|
#if USE_GNUTLS
|
|
|
|
gnutls_session session;
|
|
|
|
#elif USE_OPENSSL
|
|
|
|
SSL_CTX *ssl_ctx;
|
|
|
|
SSL *ssl;
|
|
|
|
int ssl_err;
|
|
|
|
#endif
|
2003-09-23 01:09:32 -07:00
|
|
|
char dead : 1;
|
2006-03-19 21:53:12 -08:00
|
|
|
char delete_me : 1;
|
2003-09-23 01:09:32 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _Ecore_Con_Server
|
|
|
|
{
|
|
|
|
ECORE_MAGIC;
|
|
|
|
int fd;
|
|
|
|
Ecore_Con_Type type;
|
|
|
|
char *name;
|
|
|
|
int port;
|
|
|
|
char *path;
|
|
|
|
void *data;
|
|
|
|
Ecore_Fd_Handler *fd_handler;
|
2008-12-11 05:55:47 -08:00
|
|
|
Eina_List *clients;
|
2004-04-03 07:03:33 -08:00
|
|
|
int write_buf_size;
|
|
|
|
int write_buf_offset;
|
|
|
|
unsigned char *write_buf;
|
2006-03-19 21:53:12 -08:00
|
|
|
int event_count;
|
2005-04-28 21:51:31 -07:00
|
|
|
int client_limit;
|
2006-01-10 21:13:23 -08:00
|
|
|
pid_t ppid;
|
2008-10-30 08:26:11 -07:00
|
|
|
#if USE_GNUTLS
|
|
|
|
gnutls_session session;
|
|
|
|
gnutls_anon_client_credentials_t anoncred_c;
|
|
|
|
gnutls_anon_server_credentials_t anoncred_s;
|
|
|
|
#elif USE_OPENSSL
|
2004-03-31 08:47:45 -08:00
|
|
|
SSL_CTX *ssl_ctx;
|
|
|
|
SSL *ssl;
|
2008-10-30 08:26:11 -07:00
|
|
|
int ssl_err;
|
2004-03-31 08:47:45 -08:00
|
|
|
#endif
|
2006-03-19 23:45:58 -08:00
|
|
|
char *ip;
|
2006-03-19 21:53:12 -08:00
|
|
|
char dead : 1;
|
|
|
|
char created : 1;
|
|
|
|
char connecting : 1;
|
|
|
|
char reject_excess_clients : 1;
|
|
|
|
char delete_me : 1;
|
2003-09-23 01:09:32 -07:00
|
|
|
};
|
|
|
|
|
2005-06-24 06:38:27 -07:00
|
|
|
#ifdef HAVE_CURL
|
|
|
|
struct _Ecore_Con_Url
|
|
|
|
{
|
2007-09-26 09:01:04 -07:00
|
|
|
ECORE_MAGIC;
|
|
|
|
CURL *curl_easy;
|
2005-06-24 06:38:27 -07:00
|
|
|
struct curl_slist *headers;
|
2009-08-12 02:47:04 -07:00
|
|
|
Eina_List *additional_headers;
|
2009-08-24 02:41:07 -07:00
|
|
|
Eina_List *response_headers;
|
2007-09-26 09:01:04 -07:00
|
|
|
char *url;
|
|
|
|
|
|
|
|
Ecore_Con_Url_Time condition;
|
|
|
|
time_t time;
|
2007-09-26 10:18:52 -07:00
|
|
|
void *data;
|
2007-09-26 09:01:04 -07:00
|
|
|
|
|
|
|
Ecore_Fd_Handler *fd_handler;
|
2008-03-09 09:43:32 -07:00
|
|
|
int fd;
|
|
|
|
int flags;
|
|
|
|
|
|
|
|
int received;
|
|
|
|
int write_fd;
|
2007-09-26 09:01:04 -07:00
|
|
|
|
|
|
|
unsigned char active : 1;
|
2005-06-24 06:38:27 -07:00
|
|
|
};
|
|
|
|
#endif
|
2005-08-16 02:25:02 -07:00
|
|
|
|
2008-10-09 05:30:19 -07:00
|
|
|
struct _Ecore_Con_Info
|
|
|
|
{
|
2008-10-13 04:24:52 -07:00
|
|
|
unsigned int size;
|
2008-10-09 05:30:19 -07:00
|
|
|
struct addrinfo info;
|
|
|
|
char ip[NI_MAXHOST];
|
|
|
|
char service[NI_MAXSERV];
|
|
|
|
};
|
|
|
|
|
2005-08-16 02:25:02 -07:00
|
|
|
/* from ecore_con_dns.c */
|
|
|
|
int ecore_con_dns_init(void);
|
2005-09-07 01:30:51 -07:00
|
|
|
int ecore_con_dns_shutdown(void);
|
2008-10-09 05:30:19 -07:00
|
|
|
/* from ecore_con_info.c */
|
|
|
|
int ecore_con_info_init(void);
|
|
|
|
int ecore_con_info_shutdown(void);
|
|
|
|
int ecore_con_info_tcp_connect(Ecore_Con_Server *svr, Ecore_Con_Info_Cb done_cb, void *data);
|
|
|
|
int ecore_con_info_tcp_listen(Ecore_Con_Server *svr, Ecore_Con_Info_Cb done_cb, void *data);
|
|
|
|
int ecore_con_info_udp_connect(Ecore_Con_Server *svr, Ecore_Con_Info_Cb done_cb, void *data);
|
2008-10-26 09:32:45 -07:00
|
|
|
int ecore_con_info_udp_listen(Ecore_Con_Server *svr, Ecore_Con_Info_Cb done_cb, void *data);
|
2008-10-09 05:30:19 -07:00
|
|
|
int ecore_con_info_mcast_listen(Ecore_Con_Server *svr, Ecore_Con_Info_Cb done_cb, void *data);
|
2008-10-30 08:26:11 -07:00
|
|
|
/* from ecore_con_ssl.c */
|
|
|
|
Ecore_Con_Ssl_Error ecore_con_ssl_init(void);
|
|
|
|
Ecore_Con_Ssl_Error ecore_con_ssl_shutdown(void);
|
2008-12-15 09:59:19 -08:00
|
|
|
void ecore_con_ssl_server_prepare(Ecore_Con_Server *svr);
|
|
|
|
Ecore_Con_Ssl_Error ecore_con_ssl_server_init(Ecore_Con_Server *svr);
|
|
|
|
Ecore_Con_Ssl_Error ecore_con_ssl_server_shutdown(Ecore_Con_Server *svr);
|
|
|
|
Ecore_Con_State ecore_con_ssl_server_try(Ecore_Con_Server *svr);
|
|
|
|
int ecore_con_ssl_server_read(Ecore_Con_Server *svr, unsigned char *buf, int size);
|
|
|
|
int ecore_con_ssl_server_write(Ecore_Con_Server *svr, unsigned char *buf, int size);
|
|
|
|
Ecore_Con_Ssl_Error ecore_con_ssl_client_init(Ecore_Con_Client *svr);
|
|
|
|
Ecore_Con_Ssl_Error ecore_con_ssl_client_shutdown(Ecore_Con_Client *svr);
|
|
|
|
Ecore_Con_State ecore_con_ssl_client_try(Ecore_Con_Client *svr);
|
|
|
|
int ecore_con_ssl_client_read(Ecore_Con_Client *svr, unsigned char *buf, int size);
|
|
|
|
int ecore_con_ssl_client_write(Ecore_Con_Client *svr, unsigned char *buf, int size);
|
|
|
|
|
2008-10-09 05:30:19 -07:00
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
#endif
|