blob: 980259be4b15e5702aead3a95abe053e60074b45 [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
Holger Hans Peter Freyther49f4e5b2013-01-15 21:18:02 +010025#include <sys/types.h>
26#include <sys/socket.h>
27
Holger Hans Peter Freyther97602d92012-11-11 14:21:26 +010028#include <stdio.h>
29#include <stdlib.h>
30
31#include <dlfcn.h>
32
33int (*real_socket)(int, int, int);
34
35static int GR_SOCKET = -1;
36
37static void resolve_real(void)
38{
39 if (real_socket)
40 return;
41 real_socket = dlsym(RTLD_NEXT, "socket");
42}
43
44int socket(int domain, int type, int protocol)
45{
46 int fd;
47
48 resolve_real();
49 if (domain != AF_INET || type != SOCK_RAW || protocol != IPPROTO_GRE)
50 return (*real_socket)(domain, type, protocol);
51
52 /* Now call socket with a normal UDP/IP socket and assign to GR_SOCKET */
53 fd = (*real_socket)(domain, SOCK_DGRAM, IPPROTO_UDP);
54 GR_SOCKET = fd;
55 return fd;
56}
57
58void bssgp_prim_cb()
59{
60}
61
62static const struct log_info log_info = {};
63
64int main(int argc, char **argv)
65{
66 int rc;
67 struct gprs_ns_inst *nsi;
68
69 log_init(&log_info, NULL);
70
71 nsi = gprs_ns_instantiate(NULL, NULL);
72 nsi->frgre.enabled = 1;
73
74 rc = gprs_ns_frgre_listen(nsi);
75 printf("Result: %s\n", rc == GR_SOCKET ? "PASSED" : "FAILED");
76 return rc == GR_SOCKET ? EXIT_SUCCESS : EXIT_FAILURE;
77}
78
79