diff freeDiameter/cnxctx.c @ 21:bef197f6826f

Backup before week-end, cnxctx and server in progress
author Sebastien Decugis <sdecugis@nict.go.jp>
date Thu, 08 Oct 2009 20:05:16 +0900
parents 277ec00d793e
children 0b3b46da2c12
line wrap: on
line diff
--- a/freeDiameter/cnxctx.c	Wed Oct 07 19:31:39 2009 +0900
+++ b/freeDiameter/cnxctx.c	Thu Oct 08 20:05:16 2009 +0900
@@ -35,7 +35,44 @@
 
 #include "fD.h"
 
-/* Initialize a connection context */
+/* The connection context structure */
+struct cnxctx {
+	int 		cc_socket;	/* The socket object of the connection -- <=0 if no socket is created */
+	
+	int 		cc_proto;	/* IPPROTO_TCP or IPPROTO_SCTP */
+	int		cc_tls;		/* Is TLS already started ? */
+	
+	struct fifo *	cc_events;	/* Events occuring on the connection */
+	pthread_t	cc_mgr;		/* manager thread for the connection */
+	struct fifo *	cc_incoming;	/* FIFO queue of messages received on the connection */
+	
+	uint16_t	cc_port;	/* Remote port of the connection, when we are client */
+	struct fd_list	cc_ep_remote;	/* The remote address(es) of the connection */
+	struct fd_list	cc_ep_local;	/* The local address(es) of the connection */
+	
+	/* If cc_proto == SCTP */
+	struct	{
+		int		str_out;/* Out streams */
+		int		str_in;	/* In streams */
+		int		pairs;	/* max number of pairs ( = min(in, out)) */
+		int		next;	/* # of stream the next message will be sent to */
+	} 		cc_sctp_para;
+	
+	/* If cc_tls == true */
+	struct {
+		int				 mode; 		/* GNUTLS_CLIENT / GNUTLS_SERVER */
+		gnutls_session_t 		 session;	/* Session object (stream #0 in case of SCTP) */
+	}		cc_tls_para;
+	
+	/* If both conditions */
+	struct {
+		gnutls_session_t 		*res_sessions;	/* Sessions of other pairs of streams, resumed from the first */
+		/* Buffers, threads, ... */
+	}		cc_sctp_tls_para;
+};
+
+
+/* Initialize a context structure from a socket */
 struct cnxctx * fd_cnx_init(int sock, int proto)
 {
 	struct cnxctx * conn = NULL;
@@ -65,7 +102,15 @@
 	return conn;
 }
 
-/* TLS handshake the connection */
+/* Start receving messages in clear (no TLS) on the connection */
+int fd_cnx_start_clear(struct cnxctx * conn)
+{
+	
+	TODO("...");
+	return ENOTSUP;
+}
+
+/* TLS handshake a connection; no need to have called start_clear before. Reception is active if handhsake is successful */
 int fd_cnx_handshake(struct cnxctx * conn, int mode)
 {
 	TRACE_ENTRY( "%p %d", conn, mode);
@@ -141,3 +186,59 @@
 	
 	return 0;
 }
+
+/* Retrieve TLS credentials of the remote peer, after handshake */
+int fd_cnx_getcred(struct cnxctx * conn, const gnutls_datum_t **cert_list, unsigned int *cert_list_size)
+{
+	
+	TODO("...");
+	return ENOTSUP;
+}
+
+/* Get the list of endpoints (IP addresses) of the remote peer on this object */
+int fd_cnx_getendpoints(struct cnxctx * conn, struct fd_list * senti)
+{
+	
+	TODO("...");
+	return ENOTSUP;
+}
+
+
+/* Get a string describing the remote peer address (ip address or fqdn) */
+char * fd_cnx_getremoteid(struct cnxctx * conn)
+{
+	
+	TODO("...");
+	return NULL;
+}
+
+
+/* Receive next message. if timeout is not NULL, wait only until timeout */
+int fd_cnx_receive(struct cnxctx * conn, struct timespec * timeout, unsigned char **buf, size_t * len)
+{
+	
+	TODO("...");
+	return ENOTSUP;
+}
+
+
+/* Send a message */
+int fd_cnx_send(struct cnxctx * conn, unsigned char * buf, size_t len)
+{
+	
+	TODO("...");
+	return ENOTSUP;
+}
+
+
+/* Destroy a conn structure, and shutdown the socket */
+void fd_cnx_destroy(struct cnxctx * conn)
+{
+	
+	TODO("...");
+	return;
+}
+
+
+
+
"Welcome to our mercurial repository"