Pau Espin Pedrol | 05190c3 | 2023-01-05 20:13:13 +0100 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <stdint.h> |
| 4 | #include <netinet/in.h> |
| 5 | #include <inttypes.h> |
| 6 | |
| 7 | #include <osmocom/core/timer.h> |
| 8 | #include <osmocom/core/rate_ctr.h> |
| 9 | |
| 10 | #include <osmocom/gsm/gsm48.h> |
| 11 | |
| 12 | #include <osmocom/crypt/gprs_cipher.h> |
| 13 | #include <osmocom/gsm/protocol/gsm_23_003.h> |
| 14 | #include <osmocom/crypt/auth.h> |
| 15 | |
| 16 | #include <osmocom/sgsn/apn.h> |
| 17 | #include <osmocom/sgsn/gprs_subscriber.h> |
| 18 | |
| 19 | struct sgsn_mm_ctx; |
| 20 | struct sgsn_ggsn_ctx; |
| 21 | |
| 22 | enum gprs_pdp_ctx { |
| 23 | PDP_CTR_PKTS_UDATA_IN, |
| 24 | PDP_CTR_PKTS_UDATA_OUT, |
| 25 | PDP_CTR_BYTES_UDATA_IN, |
| 26 | PDP_CTR_BYTES_UDATA_OUT, |
| 27 | }; |
| 28 | |
| 29 | enum pdp_ctx_state { |
| 30 | PDP_STATE_NONE, |
| 31 | PDP_STATE_CR_REQ, |
| 32 | PDP_STATE_CR_CONF, |
| 33 | |
| 34 | /* 04.08 / Figure 6.2 / 6.1.2.2 */ |
| 35 | PDP_STATE_INACT_PEND, |
| 36 | PDP_STATE_INACTIVE = PDP_STATE_NONE, |
| 37 | }; |
| 38 | |
| 39 | enum pdp_type { |
| 40 | PDP_TYPE_NONE, |
| 41 | PDP_TYPE_ETSI_PPP, |
| 42 | PDP_TYPE_IANA_IPv4, |
| 43 | PDP_TYPE_IANA_IPv6, |
| 44 | }; |
| 45 | |
| 46 | struct sgsn_pdp_ctx { |
| 47 | struct llist_head list; /* list_head for mmctx->pdp_list */ |
| 48 | struct llist_head g_list; /* list_head for global list */ |
| 49 | struct sgsn_mm_ctx *mm; /* back pointer to MM CTX */ |
| 50 | int destroy_ggsn; /* destroy it on destruction */ |
| 51 | struct sgsn_ggsn_ctx *ggsn; /* which GGSN serves this PDP */ |
| 52 | struct llist_head ggsn_list; /* list_head for ggsn->pdp_list */ |
| 53 | struct rate_ctr_group *ctrg; |
| 54 | |
| 55 | //unsigned int id; |
| 56 | struct pdp_t *lib; /* pointer to libgtp PDP ctx */ |
| 57 | enum pdp_ctx_state state; |
| 58 | enum pdp_type type; |
| 59 | uint32_t address; |
| 60 | char *apn_subscribed; |
| 61 | //char *apn_used; |
| 62 | uint16_t nsapi; /* SNDCP */ |
| 63 | uint16_t sapi; /* LLC */ |
| 64 | uint8_t ti; /* transaction identifier */ |
| 65 | int vplmn_allowed; |
| 66 | uint32_t qos_profile_subscr; |
| 67 | //uint32_t qos_profile_req; |
| 68 | //uint32_t qos_profile_neg; |
| 69 | uint8_t radio_prio; |
| 70 | //uint32_t charging_id; |
| 71 | |
| 72 | struct osmo_timer_list timer; |
| 73 | unsigned int T; /* Txxxx number */ |
| 74 | unsigned int num_T_exp; /* number of consecutive T expirations */ |
| 75 | |
| 76 | struct osmo_timer_list cdr_timer; /* CDR record wird timer */ |
| 77 | struct timespec cdr_start; /* The start of the CDR */ |
| 78 | uint64_t cdr_bytes_in; |
| 79 | uint64_t cdr_bytes_out; |
| 80 | uint32_t cdr_charging_id; |
| 81 | }; |
| 82 | |
| 83 | #define LOGPDPCTXP(level, pdp, fmt, args...) \ |
| 84 | LOGP(DGPRS, level, "PDP(%s/%u) " \ |
| 85 | fmt, (pdp)->mm ? (pdp)->mm->imsi : "---", (pdp)->ti, ## args) |
| 86 | |
| 87 | struct sgsn_pdp_ctx *sgsn_pdp_ctx_alloc(struct sgsn_mm_ctx *mm, |
| 88 | struct sgsn_ggsn_ctx *ggsn, |
| 89 | uint8_t nsapi); |
| 90 | void sgsn_pdp_ctx_terminate(struct sgsn_pdp_ctx *pdp); |
| 91 | void sgsn_pdp_ctx_free(struct sgsn_pdp_ctx *pdp); |
| 92 | |
Pau Espin Pedrol | 05190c3 | 2023-01-05 20:13:13 +0100 | [diff] [blame] | 93 | char *gprs_pdpaddr2str(uint8_t *pdpa, uint8_t len, bool return_ipv6); |
| 94 | |