[Asterisk-cvs] asterisk/include/asterisk netsock.h, NONE, 1.1 acl.h, 1.13, 1.14 utils.h, 1.39, 1.40

kpfleming at lists.digium.com kpfleming at lists.digium.com
Tue Jul 19 19:09:42 CDT 2005


Update of /usr/cvsroot/asterisk/include/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv19368/include/asterisk

Modified Files:
	acl.h utils.h 
Added Files:
	netsock.h 
Log Message:
split acl and netsock code into separate files, in preparation for new netsock implementation
various minor cleanups


--- NEW FILE: netsock.h ---
/*
 * Asterisk -- A telephony toolkit for Linux.
 *
 * Network socket handling
 * 
 * Copyright (C) 2004-2005, Digium, Inc.
 *
 * Mark Spencer <markster at digium.com>
 * Kevin P. Fleming <kpfleming at digium.com>
 *
 * This program is free software, distributed under the terms of
 * the GNU General Public License
 */

#ifndef _ASTERISK_NETSOCK_H
#define _ASTERISK_NETSOCK_H

#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif

#include <netinet/in.h>
#include "asterisk/io.h"
#include "asterisk/astobj.h"

struct ast_netsock;

struct ast_netsock_list;

struct ast_netsock_list *ast_netsock_list_alloc(void);

int ast_netsock_init(struct ast_netsock_list *list);

struct ast_netsock *ast_netsock_bind(struct ast_netsock_list *list, struct io_context *ioc,
				     const char *bindinfo, int defaultport, int tos, ast_io_cb callback, void *data);

struct ast_netsock *ast_netsock_bindaddr(struct ast_netsock_list *list, struct io_context *ioc,
					 struct sockaddr_in *bindaddr, int tos, ast_io_cb callback, void *data);

int ast_netsock_free(struct ast_netsock_list *list, struct ast_netsock *netsock);

int ast_netsock_release(struct ast_netsock_list *list);

struct ast_netsock *ast_netsock_find(struct ast_netsock_list *list,
				     struct sockaddr_in *sa);

int ast_netsock_sockfd(const struct ast_netsock *ns);

const struct sockaddr_in *ast_netsock_boundaddr(const struct ast_netsock *ns);

void *ast_netsock_data(const struct ast_netsock *ns);

#if defined(__cplusplus) || defined(c_plusplus)
}
#endif

#endif

Index: acl.h
===================================================================
RCS file: /usr/cvsroot/asterisk/include/asterisk/acl.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- acl.h	12 Jul 2005 02:19:41 -0000	1.13
+++ acl.h	19 Jul 2005 23:17:02 -0000	1.14
@@ -3,9 +3,9 @@
  *
  * Access Control of various sorts
  * 
- * Copyright (C) 1999, Mark Spencer
+ * Copyright (C) 1999-2005, Digium, Inc.
  *
- * Mark Spencer <markster at linux-support.net>
+ * Mark Spencer <markster at digium.com>
  *
  * This program is free software, distributed under the terms of
  * the GNU General Public License
@@ -21,7 +21,6 @@
 
 #include <netinet/in.h>
 #include "asterisk/io.h"
-#include "asterisk/astobj.h"
 
 #define AST_SENSE_DENY                  0
 #define AST_SENSE_ALLOW                 1
@@ -29,12 +28,6 @@
 /* Host based access control */
 
 struct ast_ha;
-struct ast_netsock;
-
-struct ast_netsock_list {
-	ASTOBJ_CONTAINER_COMPONENTS(struct ast_netsock);
-	struct io_context *ioc;
-};
 
 extern void ast_free_ha(struct ast_ha *ha);
 extern struct ast_ha *ast_append_ha(char *sense, char *stuff, struct ast_ha *path);
@@ -44,25 +37,8 @@
 extern int ast_ouraddrfor(struct in_addr *them, struct in_addr *us);
 extern int ast_lookup_iface(char *iface, struct in_addr *address);
 extern struct ast_ha *ast_duplicate_ha_list(struct ast_ha *original);
-extern int ast_netsock_init(struct ast_netsock_list *list);
-extern struct ast_netsock *ast_netsock_bind(struct ast_netsock_list *list, struct io_context *ioc, const char *bindinfo, int defaultport, int tos, ast_io_cb callback, void *data);
-extern struct ast_netsock *ast_netsock_bindaddr(struct ast_netsock_list *list, struct io_context *ioc, struct sockaddr_in *bindaddr, int tos, ast_io_cb callback, void *data);
-extern int ast_netsock_free(struct ast_netsock_list *list, struct ast_netsock *netsock);
-extern int ast_netsock_release(struct ast_netsock_list *list);
-extern struct ast_netsock *ast_netsock_find(struct ast_netsock_list *list,
-					    struct sockaddr_in *sa);
-extern int ast_netsock_sockfd(struct ast_netsock *ns);
-extern const struct sockaddr_in *ast_netsock_boundaddr(struct ast_netsock *ns);
-extern void *ast_netsock_data(struct ast_netsock *ns);
 extern int ast_find_ourip(struct in_addr *ourip, struct sockaddr_in bindaddr);
 
-/*! Compares the source address and port of two sockaddr_in */
-static inline int inaddrcmp(struct sockaddr_in *sin1, struct sockaddr_in *sin2)
-{
-	return ((sin1->sin_addr.s_addr != sin2->sin_addr.s_addr ) 
-		|| (sin1->sin_port != sin2->sin_port));
-}
-
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif

Index: utils.h
===================================================================
RCS file: /usr/cvsroot/asterisk/include/asterisk/utils.h,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- utils.h	11 Jul 2005 23:25:31 -0000	1.39
+++ utils.h	19 Jul 2005 23:17:02 -0000	1.40
@@ -136,14 +136,22 @@
 extern int test_for_thread_safety(void);
 
 extern const char *ast_inet_ntoa(char *buf, int bufsiz, struct in_addr ia);
-extern int ast_utils_init(void);
-extern int ast_wait_for_input(int fd, int ms);
 
 #ifdef inet_ntoa
 #undef inet_ntoa
 #endif
 #define inet_ntoa __dont__use__inet_ntoa__use__ast_inet_ntoa__instead__
 
+extern int ast_utils_init(void);
+extern int ast_wait_for_input(int fd, int ms);
+
+/*! Compares the source address and port of two sockaddr_in */
+static inline int inaddrcmp(const struct sockaddr_in *sin1, const struct sockaddr_in *sin2)
+{
+	return ((sin1->sin_addr.s_addr != sin2->sin_addr.s_addr) 
+		|| (sin1->sin_port != sin2->sin_port));
+}
+
 #define AST_STACKSIZE 256 * 1024
 #define ast_pthread_create(a,b,c,d) ast_pthread_create_stack(a,b,c,d,0)
 extern int ast_pthread_create_stack(pthread_t *thread, pthread_attr_t *attr, void *(*start_routine)(void *), void *data, size_t stacksize);




More information about the svn-commits mailing list