aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libcommon/socket.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@gnumonks.org>2011-04-05 18:33:24 +0200
committerPablo Neira Ayuso <pablo@gnumonks.org>2011-04-05 18:33:24 +0200
commit165fe562608cc9691b9f4da449b4977c68dc32a4 (patch)
treecd32c841fdcb15a00c4e933768cfd034d921f943 /openbsc/src/libcommon/socket.c
parentf22e348287409d2ec63b0f21e2baa88a248be678 (diff)
libcommon: socket: extend make_sock() prototype
This patch extends the make_sock() prototype so you can fully set the fields priv_nr and data of the bsc_fd structure. This is the first step to get rid of the internal make_sock() implementation that ipaccess-proxy uses. This patch includes a minor cleanup to pass INADDR_ANY instead of zero, if you do not want to bind the socket to one specific address.
Diffstat (limited to 'openbsc/src/libcommon/socket.c')
-rw-r--r--openbsc/src/libcommon/socket.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/openbsc/src/libcommon/socket.c b/openbsc/src/libcommon/socket.c
index 42d7b48d9..5ca7ec90f 100644
--- a/openbsc/src/libcommon/socket.c
+++ b/openbsc/src/libcommon/socket.c
@@ -40,8 +40,9 @@
#include <openbsc/gsm_data.h>
#include <osmocom/core/talloc.h>
-int make_sock(struct bsc_fd *bfd, int proto, u_int32_t ip, u_int16_t port,
- int (*cb)(struct bsc_fd *fd, unsigned int what))
+int make_sock(struct bsc_fd *bfd, int proto,
+ u_int32_t ip, u_int16_t port, int priv_nr,
+ int (*cb)(struct bsc_fd *fd, unsigned int what), void *data)
{
struct sockaddr_in addr;
int ret, on = 1;
@@ -64,7 +65,8 @@ int make_sock(struct bsc_fd *bfd, int proto, u_int32_t ip, u_int16_t port,
bfd->fd = socket(AF_INET, type, proto);
bfd->cb = cb;
bfd->when = BSC_FD_READ;
- //bfd->data = line;
+ bfd->data = data;
+ bfd->priv_nr = priv_nr;
if (bfd->fd < 0) {
LOGP(DINP, LOGL_ERROR, "could not create socket.\n");
@@ -74,7 +76,7 @@ int make_sock(struct bsc_fd *bfd, int proto, u_int32_t ip, u_int16_t port,
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
- if (ip)
+ if (ip != INADDR_ANY)
addr.sin_addr.s_addr = htonl(ip);
else
addr.sin_addr.s_addr = INADDR_ANY;