blob: bb5eaaf297704e24998151c40c29fd6c97e734b7 [file] [log] [blame]
Harald Welte51b00a62014-04-03 09:37:38 -04001/* External interface functions of the library */
2
3/* (C) 2014 by sysmocom - s.f.m.c. GmbH
4 * Author: Pablo Neira Ayuso <pablo@gnumonks.org>
5 *
6 * All Rights Reserved
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
Pablo Neira Ayuso18532952014-02-22 22:09:59 +010023#include <stdlib.h>
24#include <netinet/in.h>
25
26#include <libgtpnl/gtp.h>
27
28#include "internal.h"
29
30struct gtp_tunnel *gtp_tunnel_alloc(void)
31{
32 return calloc(1, sizeof(struct gtp_tunnel));
33}
34EXPORT_SYMBOL(gtp_tunnel_alloc);
35
36void gtp_tunnel_free(struct gtp_tunnel *t)
37{
38 free(t);
39}
40EXPORT_SYMBOL(gtp_tunnel_free);
41
Andreas Schultz49773302016-04-11 16:09:56 +020042void gtp_tunnel_set_ifns(struct gtp_tunnel *t, int ifns)
43{
44 t->ifns = ifns;
45}
46EXPORT_SYMBOL(gtp_tunnel_set_ifns);
47
Pablo Neira Ayuso18532952014-02-22 22:09:59 +010048void gtp_tunnel_set_ifidx(struct gtp_tunnel *t, uint32_t ifidx)
49{
50 t->ifidx = ifidx;
51}
52EXPORT_SYMBOL(gtp_tunnel_set_ifidx);
53
54void gtp_tunnel_set_ms_ip4(struct gtp_tunnel *t, struct in_addr *ms_addr)
55{
56 t->ms_addr = *ms_addr;
57}
58EXPORT_SYMBOL(gtp_tunnel_set_ms_ip4);
59
60void gtp_tunnel_set_sgsn_ip4(struct gtp_tunnel *t, struct in_addr *sgsn_addr)
61{
62 t->sgsn_addr = *sgsn_addr;
63}
64EXPORT_SYMBOL(gtp_tunnel_set_sgsn_ip4);
65
66void gtp_tunnel_set_version(struct gtp_tunnel *t, uint32_t version)
67{
68 t->gtp_version = version;
69}
70EXPORT_SYMBOL(gtp_tunnel_set_version);
71
72void gtp_tunnel_set_tid(struct gtp_tunnel *t, uint64_t tid)
73{
Andreas Schultz17c816f2016-04-11 16:10:03 +020074 t->u.v0.tid = tid;
Pablo Neira Ayuso18532952014-02-22 22:09:59 +010075}
76EXPORT_SYMBOL(gtp_tunnel_set_tid);
77
Pablo Neira Ayusob976ffa2014-03-20 13:56:55 +010078void gtp_tunnel_set_flowid(struct gtp_tunnel *t, uint16_t flowid)
79{
Andreas Schultz17c816f2016-04-11 16:10:03 +020080 t->u.v0.flowid = flowid;
Pablo Neira Ayusob976ffa2014-03-20 13:56:55 +010081}
82EXPORT_SYMBOL(gtp_tunnel_set_flowid);
83
Andreas Schultz17c816f2016-04-11 16:10:03 +020084void gtp_tunnel_set_i_tei(struct gtp_tunnel *t, uint32_t i_tei)
85{
86 t->u.v1.i_tei = i_tei;
87}
88EXPORT_SYMBOL(gtp_tunnel_set_i_tei);
89
90void gtp_tunnel_set_o_tei(struct gtp_tunnel *t, uint32_t o_tei)
91{
92 t->u.v1.o_tei = o_tei;
93}
94EXPORT_SYMBOL(gtp_tunnel_set_o_tei);
95
Andreas Schultz49773302016-04-11 16:09:56 +020096const int gtp_tunnel_get_ifns(struct gtp_tunnel *t)
97{
98 return t->ifns;
99}
100EXPORT_SYMBOL(gtp_tunnel_get_ifns);
101
Pablo Neira Ayuso18532952014-02-22 22:09:59 +0100102const uint32_t gtp_tunnel_get_ifidx(struct gtp_tunnel *t)
103{
104 return t->ifidx;
105}
106EXPORT_SYMBOL(gtp_tunnel_get_ifidx);
107
108const struct in_addr *gtp_tunnel_get_ms_ip4(struct gtp_tunnel *t)
109{
110 return &t->ms_addr;
111}
112EXPORT_SYMBOL(gtp_tunnel_get_ms_ip4);
113
114const struct in_addr *gtp_tunnel_get_sgsn_ip4(struct gtp_tunnel *t)
115{
116 return &t->sgsn_addr;
117}
118EXPORT_SYMBOL(gtp_tunnel_get_sgsn_ip4);
119
120int gtp_tunnel_get_version(struct gtp_tunnel *t)
121{
122 return t->gtp_version;
123}
124EXPORT_SYMBOL(gtp_tunnel_get_version);
125
126uint64_t gtp_tunnel_get_tid(struct gtp_tunnel *t)
127{
Andreas Schultz17c816f2016-04-11 16:10:03 +0200128 return t->u.v0.tid;
Pablo Neira Ayuso18532952014-02-22 22:09:59 +0100129}
130EXPORT_SYMBOL(gtp_tunnel_get_tid);
Pablo Neira Ayusob976ffa2014-03-20 13:56:55 +0100131
132uint16_t gtp_tunnel_get_flowid(struct gtp_tunnel *t)
133{
Andreas Schultz17c816f2016-04-11 16:10:03 +0200134 return t->u.v0.flowid;
Pablo Neira Ayusob976ffa2014-03-20 13:56:55 +0100135}
136EXPORT_SYMBOL(gtp_tunnel_get_flowid);
Andreas Schultz17c816f2016-04-11 16:10:03 +0200137
138uint32_t gtp_tunnel_get_i_tei(struct gtp_tunnel *t)
139{
140 return t->u.v1.i_tei;
141}
142EXPORT_SYMBOL(gtp_tunnel_get_i_tei);
143
144uint32_t gtp_tunnel_get_o_tei(struct gtp_tunnel *t)
145{
146 return t->u.v1.o_tei;
147}
148EXPORT_SYMBOL(gtp_tunnel_get_o_tei);