aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/socket.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2011-03-03 23:29:05 +0100
committerHarald Welte <laforge@gnumonks.org>2011-03-03 23:29:05 +0100
commit31c00f7d6fa63937f2c973157d196a427f6eef95 (patch)
tree6b7c81d92b6a8b83d0588b2b59d47fd0cca7a052 /openbsc/src/socket.c
parent9349d7ff7c5866110a1f2421ccc68a487e4030be (diff)
re-structure the OpenBSC directory layout
The new structure divides the code into a number of libraries for the BSC core functionality, MSC core functionality, Abis transport, TRAU and other bits. This doesn't introduce any functional code change but simply moves around files and alters Makefile.am accordingly. Next step would be to disentangle a lot of the inter-library dependencies and make the individual bits of code more independent.
Diffstat (limited to 'openbsc/src/socket.c')
-rw-r--r--openbsc/src/socket.c108
1 files changed, 0 insertions, 108 deletions
diff --git a/openbsc/src/socket.c b/openbsc/src/socket.c
deleted file mode 100644
index 47778e746..000000000
--- a/openbsc/src/socket.c
+++ /dev/null
@@ -1,108 +0,0 @@
-/* OpenBSC sokcet code, taken from Abis input driver for ip.access */
-
-/* (C) 2009 by Harald Welte <laforge@gnumonks.org>
- * (C) 2010 by Holger Hans Peter Freyther
- * (C) 2010 by On-Waves
- *
- * All Rights Reserved
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#include <time.h>
-#include <sys/fcntl.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <arpa/inet.h>
-
-#include <osmocore/select.h>
-#include <osmocore/tlv.h>
-#include <osmocore/msgb.h>
-#include <openbsc/debug.h>
-#include <openbsc/gsm_data.h>
-#include <osmocore/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))
-{
- struct sockaddr_in addr;
- int ret, on = 1;
- int type = SOCK_STREAM;
-
- switch (proto) {
- case IPPROTO_TCP:
- type = SOCK_STREAM;
- break;
- case IPPROTO_UDP:
- type = SOCK_DGRAM;
- break;
- case IPPROTO_GRE:
- type = SOCK_RAW;
- break;
- default:
- return -EINVAL;
- }
-
- bfd->fd = socket(AF_INET, type, proto);
- bfd->cb = cb;
- bfd->when = BSC_FD_READ;
- //bfd->data = line;
-
- if (bfd->fd < 0) {
- LOGP(DINP, LOGL_ERROR, "could not create socket.\n");
- return -EIO;
- }
-
- memset(&addr, 0, sizeof(addr));
- addr.sin_family = AF_INET;
- addr.sin_port = htons(port);
- if (ip)
- addr.sin_addr.s_addr = htonl(ip);
- else
- addr.sin_addr.s_addr = INADDR_ANY;
-
- setsockopt(bfd->fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
-
- ret = bind(bfd->fd, (struct sockaddr *) &addr, sizeof(addr));
- if (ret < 0) {
- LOGP(DINP, LOGL_ERROR, "could not bind socket %s\n",
- strerror(errno));
- close(bfd->fd);
- return -EIO;
- }
-
- if (proto == IPPROTO_TCP) {
- ret = listen(bfd->fd, 1);
- if (ret < 0) {
- perror("listen");
- close(bfd->fd);
- return ret;
- }
- }
-
- ret = bsc_register_fd(bfd);
- if (ret < 0) {
- perror("register_listen_fd");
- close(bfd->fd);
- return ret;
- }
- return 0;
-}