blob: c09ce7b42814314f95adedc256be5542597e94cb [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
6 * it under the terms of the GNU Affero General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (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 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 */
19
20#define _GNU_SOURCE
21#include <osmocom/core/application.h>
22
23#include <osmocom/gprs/gprs_ns.h>
24
25#include <stdio.h>
26#include <stdlib.h>
27
28#include <dlfcn.h>
29
30int (*real_socket)(int, int, int);
31
32static int GR_SOCKET = -1;
33
34static void resolve_real(void)
35{
36 if (real_socket)
37 return;
38 real_socket = dlsym(RTLD_NEXT, "socket");
39}
40
41int socket(int domain, int type, int protocol)
42{
43 int fd;
44
45 resolve_real();
46 if (domain != AF_INET || type != SOCK_RAW || protocol != IPPROTO_GRE)
47 return (*real_socket)(domain, type, protocol);
48
49 /* Now call socket with a normal UDP/IP socket and assign to GR_SOCKET */
50 fd = (*real_socket)(domain, SOCK_DGRAM, IPPROTO_UDP);
51 GR_SOCKET = fd;
52 return fd;
53}
54
55void bssgp_prim_cb()
56{
57}
58
59static const struct log_info log_info = {};
60
61int main(int argc, char **argv)
62{
63 int rc;
64 struct gprs_ns_inst *nsi;
65
66 log_init(&log_info, NULL);
67
68 nsi = gprs_ns_instantiate(NULL, NULL);
69 nsi->frgre.enabled = 1;
70
71 rc = gprs_ns_frgre_listen(nsi);
72 printf("Result: %s\n", rc == GR_SOCKET ? "PASSED" : "FAILED");
73 return rc == GR_SOCKET ? EXIT_SUCCESS : EXIT_FAILURE;
74}
75
76