aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/socket.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2010-05-19 14:11:05 +0200
committerHarald Welte <laforge@gnumonks.org>2010-05-19 14:11:38 +0200
commit3a318ab9716718a39a6907d012b6f616fe46823d (patch)
tree951b93a4c0f7f248ae5888adc8dff4e54f746662 /openbsc/src/socket.c
parent7af4962e071a69a48231abede1701ca65cb620fe (diff)
socket: Add support for GRE sockets
Diffstat (limited to 'openbsc/src/socket.c')
-rw-r--r--openbsc/src/socket.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/openbsc/src/socket.c b/openbsc/src/socket.c
index 3ed4d425a..c72f6bc27 100644
--- a/openbsc/src/socket.c
+++ b/openbsc/src/socket.c
@@ -48,8 +48,19 @@ int make_sock(struct bsc_fd *bfd, int proto, u_int16_t port,
int ret, on = 1;
int type = SOCK_STREAM;
- if (proto == IPPROTO_UDP)
+ 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;
@@ -57,7 +68,7 @@ int make_sock(struct bsc_fd *bfd, int proto, u_int16_t port,
//bfd->data = line;
if (bfd->fd < 0) {
- LOGP(DINP, LOGL_ERROR, "could not create TCP socket.\n");
+ LOGP(DINP, LOGL_ERROR, "could not create socket.\n");
return -EIO;
}
@@ -70,13 +81,13 @@ int make_sock(struct bsc_fd *bfd, int proto, u_int16_t port,
ret = bind(bfd->fd, (struct sockaddr *) &addr, sizeof(addr));
if (ret < 0) {
- LOGP(DINP, LOGL_ERROR, "could not bind l2 socket %s\n",
+ LOGP(DINP, LOGL_ERROR, "could not bind socket %s\n",
strerror(errno));
close(bfd->fd);
return -EIO;
}
- if (proto != IPPROTO_UDP) {
+ if (proto == IPPROTO_TCP) {
ret = listen(bfd->fd, 1);
if (ret < 0) {
perror("listen");