blob: 4d472b556f951b45afe7d2e025cb613bbf571c87 [file] [log] [blame]
Holger Hans Peter Freyther97602d92012-11-11 14:21:26 +01001/*
2 * (C) 2012 by Holger Hans Peter Freyther <zecke@selfish.org>
3 * All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
Holger Hans Peter Freyther53aa0f52017-12-09 13:03:29 +00006 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
Holger Hans Peter Freyther97602d92012-11-11 14:21:26 +01008 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
Holger Hans Peter Freyther53aa0f52017-12-09 13:03:29 +000015 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Holger Hans Peter Freyther97602d92012-11-11 14:21:26 +010018 *
19 */
20
21#define _GNU_SOURCE
22#include <osmocom/core/application.h>
23
24#include <osmocom/gprs/gprs_ns.h>
25
Holger Hans Peter Freyther49f4e5b2013-01-15 21:18:02 +010026#include <sys/types.h>
27#include <sys/socket.h>
28
Holger Hans Peter Freyther97602d92012-11-11 14:21:26 +010029#include <stdio.h>
30#include <stdlib.h>
31
32#include <dlfcn.h>
33
34int (*real_socket)(int, int, int);
35
36static int GR_SOCKET = -1;
37
38static void resolve_real(void)
39{
40 if (real_socket)
41 return;
42 real_socket = dlsym(RTLD_NEXT, "socket");
43}
44
45int socket(int domain, int type, int protocol)
46{
47 int fd;
48
49 resolve_real();
50 if (domain != AF_INET || type != SOCK_RAW || protocol != IPPROTO_GRE)
51 return (*real_socket)(domain, type, protocol);
52
53 /* Now call socket with a normal UDP/IP socket and assign to GR_SOCKET */
54 fd = (*real_socket)(domain, SOCK_DGRAM, IPPROTO_UDP);
55 GR_SOCKET = fd;
56 return fd;
57}
58
59void bssgp_prim_cb()
60{
61}
62
63static const struct log_info log_info = {};
64
65int main(int argc, char **argv)
66{
67 int rc;
68 struct gprs_ns_inst *nsi;
69
70 log_init(&log_info, NULL);
71
72 nsi = gprs_ns_instantiate(NULL, NULL);
73 nsi->frgre.enabled = 1;
74
75 rc = gprs_ns_frgre_listen(nsi);
76 printf("Result: %s\n", rc == GR_SOCKET ? "PASSED" : "FAILED");
77 return rc == GR_SOCKET ? EXIT_SUCCESS : EXIT_FAILURE;
78}
79
80