aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/nat/bsc_nat.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-05-05 20:33:34 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-06-15 20:24:17 +0800
commit872d7683d348f6f0bc682214f6b75004d67fc583 (patch)
tree7318031343c0d17db4a027d178e5a851e57ffc57 /openbsc/src/nat/bsc_nat.c
parent9e938c680f0f46b92692ad787dcc355768f0b2e9 (diff)
nat: Fix bad bug, make sure the fd is not overwritten..
The adding of the innocent looking code was actually overwrote the fd and then stupid things happened. Rename variables to avoid that. rc,ret should be scratch variables...
Diffstat (limited to 'openbsc/src/nat/bsc_nat.c')
-rw-r--r--openbsc/src/nat/bsc_nat.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/openbsc/src/nat/bsc_nat.c b/openbsc/src/nat/bsc_nat.c
index b9a158424..90df41fae 100644
--- a/openbsc/src/nat/bsc_nat.c
+++ b/openbsc/src/nat/bsc_nat.c
@@ -717,17 +717,17 @@ static int ipaccess_bsc_write_cb(struct bsc_fd *bfd, struct msgb *msg)
static int ipaccess_listen_bsc_cb(struct bsc_fd *bfd, unsigned int what)
{
struct bsc_connection *bsc;
- int ret, on;
+ int fd, rc, on;
struct sockaddr_in sa;
socklen_t sa_len = sizeof(sa);
if (!(what & BSC_FD_READ))
return 0;
- ret = accept(bfd->fd, (struct sockaddr *) &sa, &sa_len);
- if (ret < 0) {
+ fd = accept(bfd->fd, (struct sockaddr *) &sa, &sa_len);
+ if (fd < 0) {
perror("accept");
- return ret;
+ return fd;
}
/* count the reconnect */
@@ -738,13 +738,13 @@ static int ipaccess_listen_bsc_cb(struct bsc_fd *bfd, unsigned int what)
*/
if (!msc_con->is_connected) {
LOGP(DNAT, LOGL_NOTICE, "Disconnecting BSC due lack of MSC connection.\n");
- close(ret);
+ close(fd);
return 0;
}
on = 1;
- ret = setsockopt(bfd->fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on));
- if (ret != 0)
+ rc = setsockopt(bfd->fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on));
+ if (rc != 0)
LOGP(DNAT, LOGL_ERROR, "Failed to set TCP_NODELAY: %s\n", strerror(errno));
/* todo... do something with the connection */
@@ -756,24 +756,24 @@ static int ipaccess_listen_bsc_cb(struct bsc_fd *bfd, unsigned int what)
bsc = bsc_connection_alloc(nat);
if (!bsc) {
LOGP(DNAT, LOGL_ERROR, "Failed to allocate BSC struct.\n");
- close(ret);
+ close(fd);
return -1;
}
bsc->write_queue.bfd.data = bsc;
- bsc->write_queue.bfd.fd = ret;
+ bsc->write_queue.bfd.fd = fd;
bsc->write_queue.read_cb = ipaccess_bsc_read_cb;
bsc->write_queue.write_cb = ipaccess_bsc_write_cb;
bsc->write_queue.bfd.when = BSC_FD_READ;
if (bsc_register_fd(&bsc->write_queue.bfd) < 0) {
LOGP(DNAT, LOGL_ERROR, "Failed to register BSC fd.\n");
- close(ret);
+ close(fd);
talloc_free(bsc);
return -2;
}
LOGP(DNAT, LOGL_NOTICE, "BSC connection on %d with IP: %s\n",
- ret, inet_ntoa(sa.sin_addr));
+ fd, inet_ntoa(sa.sin_addr));
llist_add(&bsc->list_entry, &nat->bsc_connections);
send_id_ack(bsc);
send_id_req(bsc);