aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/ipaccess
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@gnumonks.org>2011-04-11 16:33:17 +0200
committerHarald Welte <laforge@gnumonks.org>2011-04-12 21:50:47 +0200
commit7e737007d9b401adec3f5c9b93ca12c99d419999 (patch)
tree22218902c3947ac58b3ccf859286172c45d0bea8 /openbsc/src/ipaccess
parent4c80a516f8c025a44c99800333af52612eeb4471 (diff)
ipaccess-proxy: get rid of make_gprs_sock()
It is similar to make_sock() available in openbsc/libcommon.
Diffstat (limited to 'openbsc/src/ipaccess')
-rw-r--r--openbsc/src/ipaccess/ipaccess-proxy.c40
1 files changed, 7 insertions, 33 deletions
diff --git a/openbsc/src/ipaccess/ipaccess-proxy.c b/openbsc/src/ipaccess/ipaccess-proxy.c
index 4dd6ee56b..5254959d4 100644
--- a/openbsc/src/ipaccess/ipaccess-proxy.c
+++ b/openbsc/src/ipaccess/ipaccess-proxy.c
@@ -126,7 +126,6 @@ static char *listen_ipaddr;
static char *bsc_ipaddr;
static char *gprs_ns_ipaddr;
-static int make_gprs_sock(struct bsc_fd *bfd, int (*cb)(struct bsc_fd*,unsigned int), void *);
static int gprs_ns_cb(struct bsc_fd *bfd, unsigned int what);
#define PROXY_ALLOC_SIZE 1200
@@ -389,7 +388,13 @@ static int ipbc_alloc_connect(struct ipa_proxy_conn *ipc, struct bsc_fd *bfd,
if (gprs_ns_ipaddr) {
struct sockaddr_in sock;
socklen_t len = sizeof(sock);
- ret = make_gprs_sock(&ipbc->gprs_ns_fd, gprs_ns_cb, ipbc);
+ struct in_addr addr;
+ uint32_t ip;
+
+ inet_aton(listen_ipaddr, &addr);
+ ip = ntohl(addr.s_addr); /* make_sock() needs host byte order */
+ ret = make_sock(&ipbc->gprs_ns_fd, IPPROTO_UDP, ip, 0, 0,
+ gprs_ns_cb, ipbc);
if (ret < 0) {
LOGP(DINP, LOGL_ERROR, "Creating the GPRS socket failed.\n");
goto err_udp_bsc;
@@ -982,37 +987,6 @@ static int gprs_ns_cb(struct bsc_fd *bfd, unsigned int what)
return 0;
}
-static int make_gprs_sock(struct bsc_fd *bfd, int (*cb)(struct bsc_fd*,unsigned int), void *data)
-{
- struct sockaddr_in addr;
- int ret;
-
- bfd->fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
- bfd->cb = cb;
- bfd->data = data;
- bfd->when = BSC_FD_READ;
-
- memset(&addr, 0, sizeof(addr));
- addr.sin_family = AF_INET;
- addr.sin_port = 0;
- inet_aton(listen_ipaddr, &addr.sin_addr);
-
- ret = bind(bfd->fd, (struct sockaddr *) &addr, sizeof(addr));
- if (ret < 0) {
- LOGP(DINP, LOGL_ERROR,
- "Could not bind n socket for IP %s with error: %s.\n",
- listen_ipaddr, strerror(errno));
- return -EIO;
- }
-
- ret = bsc_register_fd(bfd);
- if (ret < 0) {
- perror("register_listen_fd");
- return ret;
- }
- return 0;
-}
-
/* Actively connect to a BSC. */
static struct ipa_proxy_conn *connect_bsc(struct sockaddr_in *sa, int priv_nr, void *data)
{