blob: cdcdb434d7d0ceec917f055e2add3e792ceacf49 [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 Freyther97602d92012-11-11 14:21:26 +010015 */
16
17#define _GNU_SOURCE
18#include <osmocom/core/application.h>
19
20#include <osmocom/gprs/gprs_ns.h>
21
Holger Hans Peter Freyther49f4e5b2013-01-15 21:18:02 +010022#include <sys/types.h>
23#include <sys/socket.h>
24
Holger Hans Peter Freyther97602d92012-11-11 14:21:26 +010025#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
Harald Weltee61d4592022-11-03 11:05:58 +010055void bssgp_prim_cb(void)
Holger Hans Peter Freyther97602d92012-11-11 14:21:26 +010056{
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