blob: b4f9986b3d93bfc3e03f0dd0cd6eb08f9fa247bd [file] [log] [blame]
jjako52c24142002-12-16 13:33:51 +00001/*
2 * OpenGGSN - Gateway GPRS Support Node
jjakoa7cd2492003-04-11 09:40:12 +00003 * Copyright (C) 2002, 2003 Mondru AB.
jjako52c24142002-12-16 13:33:51 +00004 *
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 _PDP_H
18#define _PDP_H
19
20#define PDP_MAX 1024 /* Max number of PDP contexts */
21
22#define PDP_DEBUG 0 /* Print debug information */
23
24/* GTP Information elements from 29.060 v3.9.0 7.7 Information Elements */
25/* Also covers version 0. Note that version 0 6: QOS Profile was superceded *
26 * by 135: QOS Profile in version 1 */
27
28
29struct sl_t {
30int l;
31char *v;
32};
33
34struct ul_t {
35int l;
36unsigned char *v;
37};
38
39struct ul16_t {
40int l;
41unsigned char v[16];
42};
43
44struct ul66_t {
45int l;
46unsigned char v[66];
47};
48
49struct ul255_t {
50int l;
51unsigned char v[255];
52};
53
54
55/* ***********************************************************
56 * Information storage for each PDP context
57 *
58 * Information storage for each PDP context is defined in
59 * 23.060 section 13.3 and 03.60. Includes IMSI, MSISDN, APN,
60 * PDP-type, PDP-address (IP address), sequence numbers, charging ID.
61 * For the SGSN it also includes radio related mobility
62 * information.
63 * The following structure is a combination of the storage
64 * requirements for each PDP context for the GGSN and SGSN.
65 * It contains both 23.060 as well as 03.60 parameters.
66 * Information is stored in the format for information elements
67 * described in 29.060 and 09.60.
68 * 31 * 4 + 15 structs + = 120 + 15 structs ~ 2k / context
69 * Structs: IP address 16+4 bytes (6), APN 255 bytes (2)
70 * QOS: 255 bytes (3), msisdn 16 bytes (1),
71 *
72 * TODO: We need to consider who manages the pdp_t hash tables
73 * Is it gtp_lib, or is it the application?
74 * I suppose that it will be gtp_lib.
75 * SGSN will ask gtplib for new pdp_t. Fill out the fields,
76 * and pass it on to gtp_create_pdp_req.
77 * GGSN will receive gtp_create_pdp_ind, create new pdp_t and
78 * send responce to SGSN.
79 * SGSN will receive response and gtplib will find the
80 * original pdp_t corresponding to the request. This will be
81 * passed on to the application.
82 * Eventually the SGSN will close the connection, and the
83 * pdp_t will be freed by gtplib in SGSN and GGSN
84 * This means that gtplib need to have functions to
85 * allocate, free, sort and find pdp_t
86 * (newpdp, freepdp, getpdp)
87 * Hash tables: TID, IMSI, IP etc.)
88 *************************************************************/
89
90struct pdp_t {
91 /* Parameter determining if this PDP is in use. */
92 uint8_t inuse; /* 0=free. 1=used by somebody */
93
94 /* Pointers related to hash tables */
95 struct pdp_t *tidnext;
96 struct pdp_t *ipnext;
97
98 /* Parameters shared by all PDP context belonging to the same MS */
99
100 void *ipif; /* IP network interface */
jjakoa7cd2492003-04-11 09:40:12 +0000101 void *peer; /* Pointer to peer protocol */
jjako52c24142002-12-16 13:33:51 +0000102 void *asap; /* Application specific service access point */
103
104 uint64_t imsi; /* International Mobile Subscriber Identity.*/
105 struct ul16_t msisdn; /* The basic MSISDN of the MS. */
106 uint8_t mnrg; /* Indicates whether the MS is marked as not reachable for PS at the HLR. (1 bit, not transmitted) */
107 uint8_t cch_sub; /* The charging characteristics for the MS, e.g. normal, prepaid, flat-rate, and/or hot billing subscription. (not transmitted) */
108 uint16_t traceref; /* Identifies a record or a collection of records for a particular trace. */
109 uint16_t tracetype;/* Indicates the type of trace. */
110 struct ul_t triggerid;/* Identifies the entity that initiated the trace. */
111 struct ul_t omcid; /* Identifies the OMC that shall receive the trace record(s). */
112 uint8_t rec_hlr; /* Indicates if HLR or VLR is performing database recovery. (1 bit, not transmitted) */
113
114 /* Parameters specific to each individual PDP context */
115
116 uint8_t pdp_id; /* Index of the PDP context. (PDP context identifier) */
117 uint8_t pdp_state;/* PDP State Packet data protocol state, INACTIVE or ACTIVE. (1 bit, not transmitted) */
118 /* struct ul_t pdp_type; * PDP type; e.g. PPP or IP. */
119 /* struct ul_t pdp_addr; * PDP address; e.g. an IP address. */
120 struct ul66_t eua; /* End user address. PDP type and address combined */
121 uint8_t pdp_dyn; /* Indicates whether PDP Address is static or dynamic. (1 bit, not transmitted) */
122 struct ul255_t apn_req;/* The APN requested. */
123 struct ul255_t apn_sub;/* The APN received from the HLR. */
124 struct ul255_t apn_use;/* The APN Network Identifier currently used. */
125 uint8_t nsapi; /* Network layer Service Access Point Identifier. (4 bit) */
126 uint16_t ti; /* Transaction Identifier. (4 or 12 bit) */
127
128 uint32_t teic_own; /* (Own Tunnel Endpoint Identifier Control) */
129 uint32_t teid_own; /* (Own Tunnel Endpoint Identifier Data I) */
130 uint32_t teic_gn; /* Tunnel Endpoint Identifier for the Gn and Gp interfaces. (Control plane) */
131 uint32_t teid_gn; /* Tunnel Endpoint Identifier for the Gn and Gp interfaces. (Data I) */
132 uint32_t tei_iu; /* Tunnel Endpoint Identifier for the Iu interface. */
133
134 uint16_t fllc; /* (Local Flow Label Control, gtp0) */
135 uint16_t fllu; /* (Local Flow Label Data I, gtp0) */
136 uint16_t flrc; /* (Remote gn/gp Flow Label Control, gtp0) */
137 uint16_t flru; /* (Remote gn/gp Flow Label Data I, gtp0) */
138
139 struct ul_t tft; /* Traffic flow template. */
140 /*struct ul16_t sgsnc; * The IP address of the SGSN currently serving this MS. (Control plane) */
141 /*struct ul16_t sgsnu; * The IP address of the SGSN currently serving this MS. (User plane) */
142 /*struct ul16_t ggsnc; * The IP address of the GGSN currently used. (Control plane) */
143 /*struct ul16_t ggsnu; * The IP address of the GGSN currently used. (User plane) */
144
145 struct ul16_t gsnlc; /* The IP address of the local GSN. (Control plane) */
146 struct ul16_t gsnlu; /* The IP address of the local GSN. (User plane) */
147 struct ul16_t gsnrc; /* The IP address of the remote GSN. (Control plane) */
148 struct ul16_t gsnru; /* The IP address of the remote GSN. (User plane) */
149
150 uint8_t vplmn_allow; /* Specifies whether the MS is allowed to use the APN in the domain of the HPLMN only, or additionally the APN in the domain of the VPLMN. (1 bit) */
151 uint8_t qos_sub0[3]; /* The quality of service profile subscribed. */
152 uint8_t qos_req0[3]; /* The quality of service profile requested. */
153 uint8_t qos_neg0[3]; /* The quality of service profile negotiated. */
154 struct ul255_t qos_sub; /* The quality of service profile subscribed. */
155 struct ul255_t qos_req; /* The quality of service profile requested. */
156 struct ul255_t qos_neg; /* The quality of service profile negotiated. */
157 uint8_t radio_pri;/* The RLC/MAC radio priority level for uplink user data transmission. (4 bit) */
158 uint16_t flow_id; /* Packet flow identifier. */
159 /* struct ul_t bssqos_neg; * The aggregate BSS quality of service profile negotiated for the packet flow that this PDP context belongs to. (NOT GTP)*/
160 uint8_t sndcpd; /* SNDCP sequence number of the next downlink N-PDU to be sent to the MS. */
161 uint8_t sndcpu; /* SNDCP sequence number of the next uplink N-PDU expected from the MS. */
162 uint8_t rec_sgsn; /* Indicates if the SGSN is performing database recovery. (1 bit, not transmitted) */
163/* uint16_t gtpsnd; GTP-U sequence number of the next downlink N-PDU to be sent to the SGSN / received from the GGSN. */
164/* uint16_t gtpsnu; GTP-U sequence number of the next uplink N-PDU to be received from the SGSN / sent to the GGSN */
165 uint16_t gtpsntx; /* GTP-U sequence number of the next downlink N-PDU to be sent (09.60 section 8.1.1.1) */
166 uint16_t gtpsnrx; /* GTP-U sequence number of the next uplink N-PDU to be received (09.60 section 8.1.1.1) */
167 uint8_t pdcpsndd; /* Sequence number of the next downlink in-sequence PDCP-PDU to be sent to the MS. */
168 uint8_t pdcpsndu; /* Sequence number of the next uplink in-sequence PDCP-PDU expected from the MS. */
169 uint32_t cid; /* Charging identifier, identifies charging records generated by SGSN and GGSN. */
170 uint16_t cch_pdp; /* The charging characteristics for this PDP context, e.g. normal, prepaid, flat-rate, and/or hot billing. */
171 struct ul16_t rnc_addr;/* The IP address of the RNC currently used. */
172 uint8_t reorder; /* Specifies whether the GGSN shall reorder N-PDUs received from the SGSN / Specifies whether the SGSN shall reorder N-PDUs before delivering the N-PSUs to the MS. (1 bit) */
173 struct ul255_t pco_req; /* Requested packet control options. */
174 struct ul255_t pco_neg; /* Negotiated packet control options. */
175 uint32_t selmode; /* Selection mode. */
176 uint64_t tid; /* (Combination of imsi and nsapi) */
177};
178
179
180/* functions related to pdp_t management */
181int pdp_init();
182int pdp_newpdp(struct pdp_t **pdp, uint64_t imsi, uint8_t nsapi,
183 struct pdp_t *pdp_old);
184int pdp_freepdp(struct pdp_t *pdp);
185int pdp_getpdp(struct pdp_t **pdp);
186
187int pdp_getgtp0(struct pdp_t **pdp, uint16_t fl);
188int pdp_getgtp1(struct pdp_t **pdp, uint32_t teid);
189
190int pdp_tidhash(uint64_t tid);
191int pdp_tidset(struct pdp_t *pdp, uint64_t tid);
192int pdp_tiddel(struct pdp_t *pdp);
193int pdp_tidget(struct pdp_t **pdp, uint64_t tid);
194
jjakoa7cd2492003-04-11 09:40:12 +0000195/*
jjako52c24142002-12-16 13:33:51 +0000196int pdp_iphash(void* ipif, struct ul66_t *eua);
197int pdp_ipset(struct pdp_t *pdp, void* ipif, struct ul66_t *eua);
198int pdp_ipdel(struct pdp_t *pdp);
199int pdp_ipget(struct pdp_t **pdp, void* ipif, struct ul66_t *eua);
jjakoa7cd2492003-04-11 09:40:12 +0000200*/
jjako52c24142002-12-16 13:33:51 +0000201
202int pdp_ntoeua(struct in_addr *src, struct ul66_t *eua);
jjakoa7cd2492003-04-11 09:40:12 +0000203int pdp_euaton(struct ul66_t *eua, struct in_addr *dst);
jjako52c24142002-12-16 13:33:51 +0000204uint64_t pdp_gettid(uint64_t imsi, uint8_t nsapi);
205int ulcpy(void* dst, void* src, size_t size);
206
207#endif /* !_PDP_H */