[Asterisk-cvs] asterisk acl.c,1.38,1.39

markster at lists.digium.com markster at lists.digium.com
Tue Mar 8 23:51:41 CST 2005


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

Modified Files:
	acl.c 
Log Message:
Make ACL be what SIP is going to need (bug #2358, just first part)


Index: acl.c
===================================================================
RCS file: /usr/cvsroot/asterisk/acl.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- acl.c	13 Feb 2005 19:55:28 -0000	1.38
+++ acl.c	9 Mar 2005 05:48:11 -0000	1.39
@@ -49,6 +49,7 @@
 	int sockfd;
 	int *ioref;
 	struct io_context *ioc;
+	void *data;
 };
 
 
@@ -317,25 +318,25 @@
 	if (setsockopt(netsocket, IPPROTO_IP, IP_TOS, &tos, sizeof(tos))) 
 		ast_log(LOG_WARNING, "Unable to set TOS to %d\n", tos);
 
-	/* Establish I/O callback for socket read */
-	ioref = ast_io_add(ioc, netsocket, callback, AST_IO_IN, data);
-	if (!ioref) {
-		ast_log(LOG_WARNING, "Out of memory!\n");
-		close(netsocket);
-		return NULL;
-	}
-	
 	ns = malloc(sizeof(struct ast_netsock));
 	if (ns) {
+		/* Establish I/O callback for socket read */
+		ioref = ast_io_add(ioc, netsocket, callback, AST_IO_IN, ns);
+		if (!ioref) {
+			ast_log(LOG_WARNING, "Out of memory!\n");
+			close(netsocket);
+			free(ns);
+			return NULL;
+		}	
 		ASTOBJ_INIT(ns);
 		ns->ioref = ioref;
 		ns->ioc = ioc;
 		ns->sockfd = netsocket;
+		ns->data = data;
 		memcpy(&ns->bindaddr, bindaddr, sizeof(ns->bindaddr));
 		ASTOBJ_CONTAINER_LINK(list, ns);
 	} else {
 		ast_log(LOG_WARNING, "Out of memory!\n");
-		ast_io_remove(ioc, ioref);
 		close(netsocket);
 	}
 	return ns;
@@ -362,6 +363,16 @@
 	return 0;
 }
 
+const struct sockaddr_in *ast_netsock_boundaddr(struct ast_netsock *ns)
+{
+	return &(ns->bindaddr);
+}
+
+void *ast_netsock_data(struct ast_netsock *ns)
+{
+	return ns->data;
+}
+
 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 sockaddr_in sin;




More information about the svn-commits mailing list