Harald Welte | 51b00a6 | 2014-04-03 09:37:38 -0400 | [diff] [blame] | 1 | /* 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 Ayuso | 1853295 | 2014-02-22 22:09:59 +0100 | [diff] [blame] | 23 | #include <stdlib.h> |
| 24 | #include <netinet/in.h> |
| 25 | |
| 26 | #include <libgtpnl/gtp.h> |
| 27 | |
| 28 | #include "internal.h" |
| 29 | |
| 30 | struct gtp_tunnel *gtp_tunnel_alloc(void) |
| 31 | { |
| 32 | return calloc(1, sizeof(struct gtp_tunnel)); |
| 33 | } |
| 34 | EXPORT_SYMBOL(gtp_tunnel_alloc); |
| 35 | |
| 36 | void gtp_tunnel_free(struct gtp_tunnel *t) |
| 37 | { |
| 38 | free(t); |
| 39 | } |
| 40 | EXPORT_SYMBOL(gtp_tunnel_free); |
| 41 | |
Andreas Schultz | 4977330 | 2016-04-11 16:09:56 +0200 | [diff] [blame] | 42 | void gtp_tunnel_set_ifns(struct gtp_tunnel *t, int ifns) |
| 43 | { |
| 44 | t->ifns = ifns; |
| 45 | } |
| 46 | EXPORT_SYMBOL(gtp_tunnel_set_ifns); |
| 47 | |
Pablo Neira Ayuso | 1853295 | 2014-02-22 22:09:59 +0100 | [diff] [blame] | 48 | void gtp_tunnel_set_ifidx(struct gtp_tunnel *t, uint32_t ifidx) |
| 49 | { |
| 50 | t->ifidx = ifidx; |
| 51 | } |
| 52 | EXPORT_SYMBOL(gtp_tunnel_set_ifidx); |
| 53 | |
| 54 | void gtp_tunnel_set_ms_ip4(struct gtp_tunnel *t, struct in_addr *ms_addr) |
| 55 | { |
| 56 | t->ms_addr = *ms_addr; |
| 57 | } |
| 58 | EXPORT_SYMBOL(gtp_tunnel_set_ms_ip4); |
| 59 | |
| 60 | void gtp_tunnel_set_sgsn_ip4(struct gtp_tunnel *t, struct in_addr *sgsn_addr) |
| 61 | { |
| 62 | t->sgsn_addr = *sgsn_addr; |
| 63 | } |
| 64 | EXPORT_SYMBOL(gtp_tunnel_set_sgsn_ip4); |
| 65 | |
| 66 | void gtp_tunnel_set_version(struct gtp_tunnel *t, uint32_t version) |
| 67 | { |
| 68 | t->gtp_version = version; |
| 69 | } |
| 70 | EXPORT_SYMBOL(gtp_tunnel_set_version); |
| 71 | |
| 72 | void gtp_tunnel_set_tid(struct gtp_tunnel *t, uint64_t tid) |
| 73 | { |
| 74 | t->tid = tid; |
| 75 | } |
| 76 | EXPORT_SYMBOL(gtp_tunnel_set_tid); |
| 77 | |
Pablo Neira Ayuso | b976ffa | 2014-03-20 13:56:55 +0100 | [diff] [blame] | 78 | void gtp_tunnel_set_flowid(struct gtp_tunnel *t, uint16_t flowid) |
| 79 | { |
| 80 | t->flowid = flowid; |
| 81 | } |
| 82 | EXPORT_SYMBOL(gtp_tunnel_set_flowid); |
| 83 | |
Andreas Schultz | 4977330 | 2016-04-11 16:09:56 +0200 | [diff] [blame] | 84 | const int gtp_tunnel_get_ifns(struct gtp_tunnel *t) |
| 85 | { |
| 86 | return t->ifns; |
| 87 | } |
| 88 | EXPORT_SYMBOL(gtp_tunnel_get_ifns); |
| 89 | |
Pablo Neira Ayuso | 1853295 | 2014-02-22 22:09:59 +0100 | [diff] [blame] | 90 | const uint32_t gtp_tunnel_get_ifidx(struct gtp_tunnel *t) |
| 91 | { |
| 92 | return t->ifidx; |
| 93 | } |
| 94 | EXPORT_SYMBOL(gtp_tunnel_get_ifidx); |
| 95 | |
| 96 | const struct in_addr *gtp_tunnel_get_ms_ip4(struct gtp_tunnel *t) |
| 97 | { |
| 98 | return &t->ms_addr; |
| 99 | } |
| 100 | EXPORT_SYMBOL(gtp_tunnel_get_ms_ip4); |
| 101 | |
| 102 | const struct in_addr *gtp_tunnel_get_sgsn_ip4(struct gtp_tunnel *t) |
| 103 | { |
| 104 | return &t->sgsn_addr; |
| 105 | } |
| 106 | EXPORT_SYMBOL(gtp_tunnel_get_sgsn_ip4); |
| 107 | |
| 108 | int gtp_tunnel_get_version(struct gtp_tunnel *t) |
| 109 | { |
| 110 | return t->gtp_version; |
| 111 | } |
| 112 | EXPORT_SYMBOL(gtp_tunnel_get_version); |
| 113 | |
| 114 | uint64_t gtp_tunnel_get_tid(struct gtp_tunnel *t) |
| 115 | { |
| 116 | return t->tid; |
| 117 | } |
| 118 | EXPORT_SYMBOL(gtp_tunnel_get_tid); |
Pablo Neira Ayuso | b976ffa | 2014-03-20 13:56:55 +0100 | [diff] [blame] | 119 | |
| 120 | uint16_t gtp_tunnel_get_flowid(struct gtp_tunnel *t) |
| 121 | { |
| 122 | return t->flowid; |
| 123 | } |
| 124 | EXPORT_SYMBOL(gtp_tunnel_get_flowid); |