jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 1 | /* |
| 2 | * OpenGGSN - Gateway GPRS Support Node |
jjako | 0fe0df0 | 2004-09-17 11:30:40 +0000 | [diff] [blame] | 3 | * Copyright (C) 2002, 2003, 2004 Mondru AB. |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 4 | * |
| 5 | * The contents of this file may be used under the terms of the GNU |
| 6 | * General Public License Version 2, provided that the above copyright |
| 7 | * notice and this permission notice is included in all copies or |
| 8 | * substantial portions of the software. |
| 9 | * |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #ifndef _GTP_H |
| 13 | #define _GTP_H |
| 14 | |
jjako | 1db1c81 | 2003-07-06 20:53:57 +0000 | [diff] [blame] | 15 | #define GTP_MODE_GGSN 1 |
| 16 | #define GTP_MODE_SGSN 2 |
| 17 | |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 18 | #define GTP0_PORT 3386 |
| 19 | #define GTP1C_PORT 2123 |
| 20 | #define GTP1U_PORT 2152 |
| 21 | #define PACKET_MAX 8196 |
| 22 | |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 23 | #define GTP_MAX 0xffff /* TODO: Choose right number */ |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 24 | #define GTP0_HEADER_SIZE 20 |
| 25 | #define GTP1_HEADER_SIZE_SHORT 8 |
| 26 | #define GTP1_HEADER_SIZE_LONG 12 |
| 27 | |
| 28 | #define SYSLOG_PRINTSIZE 255 |
| 29 | #define ERRMSG_SIZE 255 |
| 30 | |
| 31 | #define RESTART_FILE "gsn_restart" |
| 32 | #define NAMESIZE 1024 |
| 33 | |
jjako | 2c38133 | 2003-10-21 19:09:53 +0000 | [diff] [blame] | 34 | /* GTP version 1 extension header type definitions. */ |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 35 | #define GTP_EXT_PDCP_PDU 0xC0 /* PDCP PDU Number */ |
jjako | 2c38133 | 2003-10-21 19:09:53 +0000 | [diff] [blame] | 36 | |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 37 | /* GTP version 1 message type definitions. Also covers version 0 except * |
| 38 | * for anonymous PDP context which was superceded in version 1 */ |
| 39 | |
| 40 | /* 0 For future use. */ |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 41 | #define GTP_ECHO_REQ 1 /* Echo Request */ |
| 42 | #define GTP_ECHO_RSP 2 /* Echo Response */ |
| 43 | #define GTP_NOT_SUPPORTED 3 /* Version Not Supported */ |
| 44 | #define GTP_ALIVE_REQ 4 /* Node Alive Request */ |
| 45 | #define GTP_ALIVE_RSP 5 /* Node Alive Response */ |
| 46 | #define GTP_REDIR_REQ 6 /* Redirection Request */ |
| 47 | #define GTP_REDIR_RSP 7 /* Redirection Response */ |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 48 | /* 8-15 For future use. */ |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 49 | #define GTP_CREATE_PDP_REQ 16 /* Create PDP Context Request */ |
| 50 | #define GTP_CREATE_PDP_RSP 17 /* Create PDP Context Response */ |
| 51 | #define GTP_UPDATE_PDP_REQ 18 /* Update PDP Context Request */ |
| 52 | #define GTP_UPDATE_PDP_RSP 19 /* Update PDP Context Response */ |
| 53 | #define GTP_DELETE_PDP_REQ 20 /* Delete PDP Context Request */ |
| 54 | #define GTP_DELETE_PDP_RSP 21 /* Delete PDP Context Response */ |
| 55 | /* 22-25 For future use. *//* In version GTP 1 anonomous PDP context */ |
| 56 | #define GTP_ERROR 26 /* Error Indication */ |
| 57 | #define GTP_PDU_NOT_REQ 27 /* PDU Notification Request */ |
| 58 | #define GTP_PDU_NOT_RSP 28 /* PDU Notification Response */ |
| 59 | #define GTP_PDU_NOT_REJ_REQ 29 /* PDU Notification Reject Request */ |
| 60 | #define GTP_PDU_NOT_REJ_RSP 30 /* PDU Notification Reject Response */ |
| 61 | #define GTP_SUPP_EXT_HEADER 31 /* Supported Extension Headers Notification */ |
| 62 | #define GTP_SND_ROUTE_REQ 32 /* Send Routeing Information for GPRS Request */ |
| 63 | #define GTP_SND_ROUTE_RSP 33 /* Send Routeing Information for GPRS Response */ |
| 64 | #define GTP_FAILURE_REQ 34 /* Failure Report Request */ |
| 65 | #define GTP_FAILURE_RSP 35 /* Failure Report Response */ |
| 66 | #define GTP_MS_PRESENT_REQ 36 /* Note MS GPRS Present Request */ |
| 67 | #define GTP_MS_PRESENT_RSP 37 /* Note MS GPRS Present Response */ |
| 68 | /* 38-47 For future use. */ |
| 69 | #define GTP_IDEN_REQ 48 /* Identification Request */ |
| 70 | #define GTP_IDEN_RSP 49 /* Identification Response */ |
| 71 | #define GTP_SGSN_CONTEXT_REQ 50 /* SGSN Context Request */ |
| 72 | #define GTP_SGSN_CONTEXT_RSP 51 /* SGSN Context Response */ |
| 73 | #define GTP_SGSN_CONTEXT_ACK 52 /* SGSN Context Acknowledge */ |
| 74 | #define GTP_FWD_RELOC_REQ 53 /* Forward Relocation Request */ |
| 75 | #define GTP_FWD_RELOC_RSP 54 /* Forward Relocation Response */ |
| 76 | #define GTP_FWD_RELOC_COMPL 55 /* Forward Relocation Complete */ |
| 77 | #define GTP_RELOC_CANCEL_REQ 56 /* Relocation Cancel Request */ |
| 78 | #define GTP_RELOC_CANCEL_RSP 57 /* Relocation Cancel Response */ |
| 79 | #define GTP_FWD_SRNS 58 /* Forward SRNS Context */ |
| 80 | #define GTP_FWD_RELOC_ACK 59 /* Forward Relocation Complete Acknowledge */ |
| 81 | #define GTP_FWD_SRNS_ACK 60 /* Forward SRNS Context Acknowledge */ |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 82 | /* 61-239 For future use. */ |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 83 | #define GTP_DATA_TRAN_REQ 240 /* Data Record Transfer Request */ |
| 84 | #define GTP_DATA_TRAN_RSP 241 /* Data Record Transfer Response */ |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 85 | /* 242-254 For future use. */ |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 86 | #define GTP_GPDU 255 /* G-PDU */ |
jjako | 08d331d | 2003-10-13 20:33:30 +0000 | [diff] [blame] | 87 | |
| 88 | /* GTP information element cause codes from 29.060 v3.9.0 7.7 */ |
| 89 | /* */ |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 90 | #define GTPCAUSE_REQ_IMSI 0 /* Request IMSI */ |
| 91 | #define GTPCAUSE_REQ_IMEI 1 /* Request IMEI */ |
| 92 | #define GTPCAUSE_REQ_IMSI_IMEI 2 /* Request IMSI and IMEI */ |
| 93 | #define GTPCAUSE_NO_ID_NEEDED 3 /* No identity needed */ |
| 94 | #define GTPCAUSE_MS_REFUSES_X 4 /* MS refuses */ |
| 95 | #define GTPCAUSE_MS_NOT_RESP_X 5 /* MS is not GPRS responding */ |
| 96 | #define GTPCAUSE_006 6 /* For future use 6-48 */ |
| 97 | #define GTPCAUSE_049 49 /* Cause values reserved for GPRS charging protocol use (See GTP' in GSM 12.15) 49-63 */ |
| 98 | #define GTPCAUSE_064 64 /* For future use 64-127 */ |
| 99 | #define GTPCAUSE_ACC_REQ 128 /* Request accepted */ |
| 100 | #define GTPCAUSE_129 129 /* For future use 129-176 */ |
| 101 | #define GTPCAUSE_177 177 /* Cause values reserved for GPRS charging protocol use (See GTP' In GSM 12.15) 177-191 */ |
| 102 | #define GTPCAUSE_NON_EXIST 192 /* Non-existent */ |
| 103 | #define GTPCAUSE_INVALID_MESSAGE 193 /* Invalid message format */ |
| 104 | #define GTPCAUSE_IMSI_NOT_KNOWN 194 /* IMSI not known */ |
| 105 | #define GTPCAUSE_MS_DETACHED 195 /* MS is GPRS detached */ |
| 106 | #define GTPCAUSE_MS_NOT_RESP 196 /* MS is not GPRS responding */ |
| 107 | #define GTPCAUSE_MS_REFUSES 197 /* MS refuses */ |
| 108 | #define GTPCAUSE_198 198 /* For future use */ |
| 109 | #define GTPCAUSE_NO_RESOURCES 199 /* No resources available */ |
| 110 | #define GTPCAUSE_NOT_SUPPORTED 200 /* Service not supported */ |
| 111 | #define GTPCAUSE_MAN_IE_INCORRECT 201 /* Mandatory IE incorrect */ |
| 112 | #define GTPCAUSE_MAN_IE_MISSING 202 /* Mandatory IE missing */ |
| 113 | #define GTPCAUSE_OPT_IE_INCORRECT 203 /* Optional IE incorrect */ |
| 114 | #define GTPCAUSE_SYS_FAIL 204 /* System failure */ |
| 115 | #define GTPCAUSE_ROAMING_REST 205 /* Roaming Restriction */ |
| 116 | #define GTPCAUSE_PTIMSI_MISMATCH 206 /* P-TMSI signature mismatch */ |
| 117 | #define GTPCAUSE_CONN_SUSP 207 /* GPRS connection suspended */ |
| 118 | #define GTPCAUSE_AUTH_FAIL 208 /* Authentication failure */ |
| 119 | #define GTPCAUSE_USER_AUTH_FAIL 209 /* User authentication failed */ |
| 120 | #define GTPCAUSE_CONTEXT_NOT_FOUND 210 /* Context not found */ |
| 121 | #define GTPCAUSE_ADDR_OCCUPIED 211 /* All dynamic PDP addresses are occupied */ |
| 122 | #define GTPCAUSE_NO_MEMORY 212 /* No memory is available */ |
| 123 | #define GTPCAUSE_RELOC_FAIL 213 /* Relocation failure */ |
| 124 | #define GTPCAUSE_UNKNOWN_MAN_EXTHEADER 214 /* Unknown mandatory extension header */ |
| 125 | #define GTPCAUSE_SEM_ERR_TFT 215 /* Semantic error in the TFT operation */ |
| 126 | #define GTPCAUSE_SYN_ERR_TFT 216 /* Syntactic error in the TFT operation */ |
| 127 | #define GTPCAUSE_SEM_ERR_FILTER 217 /* Semantic errors in packet filter(s) */ |
| 128 | #define GTPCAUSE_SYN_ERR_FILTER 218 /* Syntactic errors in packet filter(s) */ |
| 129 | #define GTPCAUSE_MISSING_APN 219 /* Missing or unknown APN */ |
| 130 | #define GTPCAUSE_UNKNOWN_PDP 220 /* Unknown PDP address or PDP type */ |
| 131 | #define GTPCAUSE_221 221 /* For Future Use 221-240 */ |
| 132 | #define GTPCAUSE_241 241 /* Cause Values Reserved For Gprs Charging Protocol Use (See Gtp' In Gsm 12.15) 241-255 */ |
jjako | 08d331d | 2003-10-13 20:33:30 +0000 | [diff] [blame] | 133 | |
Holger Hans Peter Freyther | 0382996 | 2013-07-27 20:01:15 +0200 | [diff] [blame] | 134 | struct ul66_t; |
| 135 | struct ul16_t; |
| 136 | |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 137 | /* GTP 0 header. |
| 138 | * Explanation to some of the fields: |
| 139 | * SNDCP NPDU Number flag = 0 except for inter SGSN handover situations |
| 140 | * SNDCP N-PDU LCC Number 0 = 0xff except for inter SGSN handover situations |
| 141 | * Sequence number. Used for reliable delivery of signalling messages, and |
| 142 | * to discard "illegal" data messages. |
| 143 | * Flow label. Is used to point a particular PDP context. Is used in data |
| 144 | * messages as well as signalling messages related to a particular context. |
| 145 | * Tunnel ID is IMSI+NSAPI. Unique identifier of PDP context. Is somewhat |
| 146 | * redundant because the header also includes flow. */ |
| 147 | |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 148 | struct gtp0_header { /* Descriptions from 3GPP 09.60 */ |
| 149 | uint8_t flags; /* 01 bitfield, with typical values */ |
| 150 | /* 000..... Version: 1 (0) */ |
| 151 | /* ...1111. Spare (7) */ |
| 152 | /* .......0 SNDCP N-PDU Number flag (0) */ |
| 153 | uint8_t type; /* 02 Message type. T-PDU = 0xff */ |
| 154 | uint16_t length; /* 03 Length (of G-PDU excluding header) */ |
| 155 | uint16_t seq; /* 05 Sequence Number */ |
| 156 | uint16_t flow; /* 07 Flow Label ( = 0 for signalling) */ |
| 157 | uint8_t number; /* 09 SNDCP N-PDU LCC Number ( 0 = 0xff) */ |
| 158 | uint8_t spare1; /* 10 Spare */ |
| 159 | uint8_t spare2; /* 11 Spare */ |
| 160 | uint8_t spare3; /* 12 Spare */ |
| 161 | uint64_t tid; /* 13 Tunnel ID */ |
Pablo Neira Ayuso | 0674f0b | 2014-03-19 22:55:29 +0100 | [diff] [blame] | 162 | } __attribute__((packed)); /* 20 */ |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 163 | |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 164 | struct gtp1_header_short { /* Descriptions from 3GPP 29060 */ |
| 165 | uint8_t flags; /* 01 bitfield, with typical values */ |
| 166 | /* 001..... Version: 1 */ |
| 167 | /* ...1.... Protocol Type: GTP=1, GTP'=0 */ |
| 168 | /* ....0... Spare = 0 */ |
| 169 | /* .....0.. Extension header flag: 0 */ |
| 170 | /* ......0. Sequence number flag: 0 */ |
| 171 | /* .......0 PN: N-PDU Number flag */ |
| 172 | uint8_t type; /* 02 Message type. T-PDU = 0xff */ |
| 173 | uint16_t length; /* 03 Length (of IP packet or signalling) */ |
| 174 | uint32_t tei; /* 05 - 08 Tunnel Endpoint ID */ |
Pablo Neira Ayuso | 0674f0b | 2014-03-19 22:55:29 +0100 | [diff] [blame] | 175 | } __attribute__((packed)); |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 176 | |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 177 | struct gtp1_header_long { /* Descriptions from 3GPP 29060 */ |
| 178 | uint8_t flags; /* 01 bitfield, with typical values */ |
| 179 | /* 001..... Version: 1 */ |
| 180 | /* ...1.... Protocol Type: GTP=1, GTP'=0 */ |
| 181 | /* ....0... Spare = 0 */ |
| 182 | /* .....0.. Extension header flag: 0 */ |
| 183 | /* ......1. Sequence number flag: 1 */ |
| 184 | /* .......0 PN: N-PDU Number flag */ |
| 185 | uint8_t type; /* 02 Message type. T-PDU = 0xff */ |
| 186 | uint16_t length; /* 03 Length (of IP packet or signalling) */ |
| 187 | uint32_t tei; /* 05 Tunnel Endpoint ID */ |
| 188 | uint16_t seq; /* 10 Sequence Number */ |
| 189 | uint8_t npdu; /* 11 N-PDU Number */ |
| 190 | uint8_t next; /* 12 Next extension header type. Empty = 0 */ |
Pablo Neira Ayuso | 0674f0b | 2014-03-19 22:55:29 +0100 | [diff] [blame] | 191 | } __attribute__((packed)); |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 192 | |
| 193 | struct gtp0_packet { |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 194 | struct gtp0_header h; |
| 195 | uint8_t p[GTP_MAX]; |
| 196 | } __attribute__ ((packed)); |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 197 | |
| 198 | struct gtp1_packet_short { |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 199 | struct gtp1_header_short h; |
| 200 | uint8_t p[GTP_MAX]; |
| 201 | } __attribute__ ((packed)); |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 202 | |
| 203 | struct gtp1_packet_long { |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 204 | struct gtp1_header_long h; |
| 205 | uint8_t p[GTP_MAX]; |
| 206 | } __attribute__ ((packed)); |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 207 | |
| 208 | union gtp_packet { |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 209 | uint8_t flags; |
| 210 | struct gtp0_packet gtp0; |
| 211 | struct gtp1_packet_short gtp1s; |
| 212 | struct gtp1_packet_long gtp1l; |
| 213 | } __attribute__ ((packed)); |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 214 | |
| 215 | /* *********************************************************** |
| 216 | * Information storage for each gsn instance |
| 217 | * |
| 218 | * Normally each instance of the application corresponds to |
| 219 | * one instance of a gsn. |
| 220 | * |
| 221 | * In order to avoid global variables in the application, and |
| 222 | * also in order to allow several instances of a gsn in the same |
| 223 | * application this struct is provided in order to store all |
| 224 | * relevant information related to the gsn. |
| 225 | * |
| 226 | * Note that this does not include information storage for ' |
| 227 | * each pdp context. This is stored in another struct. |
| 228 | *************************************************************/ |
| 229 | |
| 230 | struct gsn_t { |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 231 | /* Parameters related to the network interface */ |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 232 | |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 233 | int fd0; /* GTP0 file descriptor */ |
| 234 | int fd1c; /* GTP1 control plane file descriptor */ |
| 235 | int fd1u; /* GTP0 user plane file descriptor */ |
| 236 | int mode; /* Mode of operation: GGSN or SGSN */ |
| 237 | struct in_addr gsnc; /* IP address of this gsn for signalling */ |
| 238 | struct in_addr gsnu; /* IP address of this gsn for user traffic */ |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 239 | |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 240 | /* Parameters related to signalling messages */ |
| 241 | uint16_t seq_next; /* Next sequence number to use */ |
| 242 | int seq_first; /* First packet in queue (oldest timeout) */ |
| 243 | int seq_last; /* Last packet in queue (youngest timeout) */ |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 244 | |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 245 | unsigned char restart_counter; /* Increment on restart. Stored on disk */ |
| 246 | char *statedir; /* Disk location for permanent storage */ |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 247 | |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 248 | struct queue_t *queue_req; /* Request queue */ |
| 249 | struct queue_t *queue_resp; /* Response queue */ |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 250 | |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 251 | /* Call back functions */ |
| 252 | int (*cb_delete_context) (struct pdp_t *); |
| 253 | int (*cb_create_context_ind) (struct pdp_t *); |
| 254 | int (*cb_unsup_ind) (struct sockaddr_in * peer); |
| 255 | int (*cb_extheader_ind) (struct sockaddr_in * peer); |
| 256 | int (*cb_conf) (int type, int cause, struct pdp_t * pdp, void *cbp); |
| 257 | int (*cb_data_ind) (struct pdp_t * pdp, void *pack, unsigned len); |
| 258 | int (*cb_recovery) (struct sockaddr_in * peer, uint8_t recovery); |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 259 | |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 260 | /* Counters */ |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 261 | |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 262 | uint64_t err_socket; /* Number of socket errors */ |
| 263 | uint64_t err_readfrom; /* Number of readfrom errors */ |
| 264 | uint64_t err_sendto; /* Number of sendto errors */ |
| 265 | uint64_t err_memcpy; /* Number of memcpy */ |
| 266 | uint64_t err_queuefull; /* Number of times queue was full */ |
| 267 | uint64_t err_seq; /* Number of seq out of range */ |
| 268 | uint64_t err_address; /* GSN address conversion failed */ |
| 269 | uint64_t err_unknownpdp; /* GSN address conversion failed */ |
| 270 | uint64_t err_unknowntid; /* Application supplied unknown imsi+nsapi */ |
| 271 | uint64_t err_cause; /* Unexpected cause value received */ |
| 272 | uint64_t err_outofpdp; /* Out of storage for PDP contexts */ |
| 273 | |
| 274 | uint64_t empty; /* Number of empty packets */ |
| 275 | uint64_t unsup; /* Number of unsupported version 29.60 11.1.1 */ |
| 276 | uint64_t tooshort; /* Number of too short headers 29.60 11.1.2 */ |
| 277 | uint64_t unknown; /* Number of unknown messages 29.60 11.1.3 */ |
| 278 | uint64_t unexpect; /* Number of unexpected messages 29.60 11.1.4 */ |
Neels Hofmeyr | b18e811 | 2015-10-12 14:00:21 +0200 | [diff] [blame] | 279 | uint64_t duplicate; /* Number of duplicate or unsolicited replies */ |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 280 | uint64_t missing; /* Number of missing information field messages */ |
| 281 | uint64_t incorrect; /* Number of incorrect information field messages */ |
| 282 | uint64_t invalid; /* Number of invalid message format messages */ |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 283 | }; |
| 284 | |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 285 | /* External API functions */ |
| 286 | |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 287 | extern const char *gtp_version(); |
jjako | 1db1c81 | 2003-07-06 20:53:57 +0000 | [diff] [blame] | 288 | extern int gtp_new(struct gsn_t **gsn, char *statedir, struct in_addr *listen, |
| 289 | int mode); |
| 290 | |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 291 | extern int gtp_free(struct gsn_t *gsn); |
| 292 | |
| 293 | extern int gtp_newpdp(struct gsn_t *gsn, struct pdp_t **pdp, |
| 294 | uint64_t imsi, uint8_t nsapi); |
| 295 | extern int gtp_freepdp(struct gsn_t *gsn, struct pdp_t *pdp); |
| 296 | |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 297 | extern int gtp_create_context_req(struct gsn_t *gsn, struct pdp_t *pdp, |
jjako | 193e8b1 | 2003-11-10 12:31:41 +0000 | [diff] [blame] | 298 | void *cbp); |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 299 | |
jjako | 08d331d | 2003-10-13 20:33:30 +0000 | [diff] [blame] | 300 | extern int gtp_set_cb_create_context_ind(struct gsn_t *gsn, |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 301 | int (*cb_create_context_ind) (struct |
| 302 | pdp_t * |
| 303 | pdp)); |
jjako | 1db1c81 | 2003-07-06 20:53:57 +0000 | [diff] [blame] | 304 | |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 305 | extern int gtp_create_context_resp(struct gsn_t *gsn, struct pdp_t *pdp, |
jjako | 08d331d | 2003-10-13 20:33:30 +0000 | [diff] [blame] | 306 | int cause); |
| 307 | |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 308 | extern int gtp_update_context(struct gsn_t *gsn, struct pdp_t *pdp, |
| 309 | void *cbp, struct in_addr *inetaddr); |
jjako | 08d331d | 2003-10-13 20:33:30 +0000 | [diff] [blame] | 310 | |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 311 | extern int gtp_delete_context_req(struct gsn_t *gsn, struct pdp_t *pdp, |
jjako | 2c38133 | 2003-10-21 19:09:53 +0000 | [diff] [blame] | 312 | void *cbp, int teardown); |
jjako | 08d331d | 2003-10-13 20:33:30 +0000 | [diff] [blame] | 313 | |
| 314 | extern int gtp_data_req(struct gsn_t *gsn, struct pdp_t *pdp, |
| 315 | void *pack, unsigned len); |
| 316 | |
| 317 | extern int gtp_set_cb_data_ind(struct gsn_t *gsn, |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 318 | int (*cb_data_ind) (struct pdp_t * pdp, |
| 319 | void *pack, unsigned len)); |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 320 | |
| 321 | extern int gtp_fd(struct gsn_t *gsn); |
jjako | 08d331d | 2003-10-13 20:33:30 +0000 | [diff] [blame] | 322 | extern int gtp_decaps0(struct gsn_t *gsn); |
| 323 | extern int gtp_decaps1c(struct gsn_t *gsn); |
| 324 | extern int gtp_decaps1u(struct gsn_t *gsn); |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 325 | extern int gtp_retrans(struct gsn_t *gsn); |
| 326 | extern int gtp_retranstimeout(struct gsn_t *gsn, struct timeval *timeout); |
| 327 | |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 328 | extern int gtp_set_cb_delete_context(struct gsn_t *gsn, |
| 329 | int (*cb_delete_context) (struct pdp_t * |
| 330 | pdp)); |
jjako | 08d331d | 2003-10-13 20:33:30 +0000 | [diff] [blame] | 331 | /*extern int gtp_set_cb_create_context(struct gsn_t *gsn, |
| 332 | int (*cb_create_context) (struct pdp_t* pdp)); */ |
| 333 | |
| 334 | extern int gtp_set_cb_unsup_ind(struct gsn_t *gsn, |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 335 | int (*cb) (struct sockaddr_in * peer)); |
jjako | 08d331d | 2003-10-13 20:33:30 +0000 | [diff] [blame] | 336 | |
jjako | 2c38133 | 2003-10-21 19:09:53 +0000 | [diff] [blame] | 337 | extern int gtp_set_cb_extheader_ind(struct gsn_t *gsn, |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 338 | int (*cb) (struct sockaddr_in * peer)); |
jjako | 08d331d | 2003-10-13 20:33:30 +0000 | [diff] [blame] | 339 | |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 340 | extern int gtp_set_cb_conf(struct gsn_t *gsn, |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 341 | int (*cb) (int type, int cause, struct pdp_t * pdp, |
| 342 | void *cbp)); |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 343 | |
Harald Welte | 629e986 | 2010-12-24 20:58:09 +0100 | [diff] [blame] | 344 | int gtp_set_cb_recovery(struct gsn_t *gsn, |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 345 | int (*cb) (struct sockaddr_in * peer, |
| 346 | uint8_t recovery)); |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 347 | |
| 348 | /* Internal functions (not part of the API */ |
| 349 | |
jjako | 08d331d | 2003-10-13 20:33:30 +0000 | [diff] [blame] | 350 | extern int gtp_echo_req(struct gsn_t *gsn, int version, void *cbp, |
| 351 | struct in_addr *inetaddrs); |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 352 | extern int gtp_echo_resp(struct gsn_t *gsn, int version, |
jjako | 08d331d | 2003-10-13 20:33:30 +0000 | [diff] [blame] | 353 | struct sockaddr_in *peer, int fd, |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 354 | void *pack, unsigned len); |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 355 | extern int gtp_echo_ind(struct gsn_t *gsn, int version, |
| 356 | struct sockaddr_in *peer, int fd, |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 357 | void *pack, unsigned len); |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 358 | extern int gtp_echo_conf(struct gsn_t *gsn, int version, |
| 359 | struct sockaddr_in *peer, void *pack, unsigned len); |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 360 | |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 361 | extern int gtp_unsup_req(struct gsn_t *gsn, int version, |
jjako | 08d331d | 2003-10-13 20:33:30 +0000 | [diff] [blame] | 362 | struct sockaddr_in *peer, |
| 363 | int fd, void *pack, unsigned len); |
| 364 | extern int gtp_unsup_ind(struct gsn_t *gsn, struct sockaddr_in *peer, |
| 365 | void *pack, unsigned len); |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 366 | |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 367 | extern int gtp_create_pdp_resp(struct gsn_t *gsn, int version, |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 368 | struct pdp_t *pdp, uint8_t cause); |
| 369 | |
| 370 | extern int gtp_create_pdp_ind(struct gsn_t *gsn, int version, |
jjako | 08d331d | 2003-10-13 20:33:30 +0000 | [diff] [blame] | 371 | struct sockaddr_in *peer, int fd, |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 372 | void *pack, unsigned len); |
| 373 | |
| 374 | extern int gtp_create_pdp_conf(struct gsn_t *gsn, int version, |
| 375 | struct sockaddr_in *peer, |
| 376 | void *pack, unsigned len); |
| 377 | |
jjako | 08d331d | 2003-10-13 20:33:30 +0000 | [diff] [blame] | 378 | extern int gtp_update_pdp_req(struct gsn_t *gsn, int version, void *cbp, |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 379 | struct in_addr *inetaddr, struct pdp_t *pdp); |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 380 | |
jjako | 08d331d | 2003-10-13 20:33:30 +0000 | [diff] [blame] | 381 | extern int gtp_delete_pdp_req(struct gsn_t *gsn, int version, void *cbp, |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 382 | struct pdp_t *pdp); |
| 383 | |
| 384 | extern int gtp_delete_pdp_resp(struct gsn_t *gsn, int version, |
jjako | 08d331d | 2003-10-13 20:33:30 +0000 | [diff] [blame] | 385 | struct sockaddr_in *peer, int fd, |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 386 | void *pack, unsigned len, |
jjako | 2c38133 | 2003-10-21 19:09:53 +0000 | [diff] [blame] | 387 | struct pdp_t *pdp, struct pdp_t *linked_pdp, |
| 388 | uint8_t cause, int teardown); |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 389 | |
| 390 | extern int gtp_delete_pdp_ind(struct gsn_t *gsn, int version, |
jjako | 08d331d | 2003-10-13 20:33:30 +0000 | [diff] [blame] | 391 | struct sockaddr_in *peer, int fd, |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 392 | void *pack, unsigned len); |
| 393 | |
| 394 | extern int gtp_delete_pdp_conf(struct gsn_t *gsn, int version, |
| 395 | struct sockaddr_in *peer, |
| 396 | void *pack, unsigned len); |
| 397 | |
jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 398 | extern int ipv42eua(struct ul66_t *eua, struct in_addr *src); |
| 399 | extern int eua2ipv4(struct in_addr *dst, struct ul66_t *eua); |
| 400 | extern int gsna2in_addr(struct in_addr *dst, struct ul16_t *gsna); |
| 401 | extern int in_addr2gsna(struct ul16_t *gsna, struct in_addr *src); |
| 402 | |
Harald Welte | bed35df | 2011-11-02 13:06:18 +0100 | [diff] [blame] | 403 | #endif /* !_GTP_H */ |