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