Harald Welte | 288be16 | 2010-05-01 16:48:27 +0200 | [diff] [blame] | 1 | #ifndef _SGSN_H |
| 2 | #define _SGSN_H |
| 3 | |
Harald Welte | 288be16 | 2010-05-01 16:48:27 +0200 | [diff] [blame] | 4 | |
Pablo Neira Ayuso | 136f453 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 5 | #include <osmocom/core/msgb.h> |
Harald Welte | 288be16 | 2010-05-01 16:48:27 +0200 | [diff] [blame] | 6 | |
Harald Welte | ea34a4e | 2012-06-16 14:59:56 +0800 | [diff] [blame] | 7 | #include <osmocom/gprs/gprs_ns.h> |
Harald Welte | 6abf94e | 2010-05-18 10:35:06 +0200 | [diff] [blame] | 8 | #include <openbsc/gprs_sgsn.h> |
Harald Welte | 288be16 | 2010-05-01 16:48:27 +0200 | [diff] [blame] | 9 | |
Jacob Erlbeck | 39f040d | 2014-12-18 12:46:47 +0100 | [diff] [blame] | 10 | struct gprs_gsup_client; |
| 11 | |
Jacob Erlbeck | 106f547 | 2014-11-04 10:08:37 +0100 | [diff] [blame] | 12 | enum sgsn_auth_policy { |
| 13 | SGSN_AUTH_POLICY_OPEN, |
| 14 | SGSN_AUTH_POLICY_CLOSED, |
Jacob Erlbeck | be2c8d9 | 2014-11-12 10:18:09 +0100 | [diff] [blame] | 15 | SGSN_AUTH_POLICY_ACL_ONLY, |
| 16 | SGSN_AUTH_POLICY_REMOTE |
Jacob Erlbeck | 106f547 | 2014-11-04 10:08:37 +0100 | [diff] [blame] | 17 | }; |
| 18 | |
Harald Welte | 288be16 | 2010-05-01 16:48:27 +0200 | [diff] [blame] | 19 | struct sgsn_config { |
| 20 | /* parsed from config file */ |
Harald Welte | 288be16 | 2010-05-01 16:48:27 +0200 | [diff] [blame] | 21 | |
Harald Welte | 2720e73 | 2010-05-17 00:44:57 +0200 | [diff] [blame] | 22 | char *gtp_statedir; |
| 23 | struct sockaddr_in gtp_listenaddr; |
| 24 | |
Harald Welte | 288be16 | 2010-05-01 16:48:27 +0200 | [diff] [blame] | 25 | /* misc */ |
| 26 | struct gprs_ns_inst *nsi; |
Harald Welte | 7f6da48 | 2013-03-19 11:00:13 +0100 | [diff] [blame] | 27 | |
Jacob Erlbeck | 106f547 | 2014-11-04 10:08:37 +0100 | [diff] [blame] | 28 | enum sgsn_auth_policy auth_policy; |
Harald Welte | 7f6da48 | 2013-03-19 11:00:13 +0100 | [diff] [blame] | 29 | struct llist_head imsi_acl; |
Jacob Erlbeck | 39f040d | 2014-12-18 12:46:47 +0100 | [diff] [blame] | 30 | |
| 31 | struct sockaddr_in gsup_server_addr; |
| 32 | int gsup_server_port; |
Jacob Erlbeck | 9d4f46c | 2014-12-17 13:20:08 +0100 | [diff] [blame] | 33 | |
| 34 | int require_authentication; |
Jacob Erlbeck | 771573c | 2014-12-19 18:08:48 +0100 | [diff] [blame^] | 35 | int require_update_location; |
Harald Welte | 288be16 | 2010-05-01 16:48:27 +0200 | [diff] [blame] | 36 | }; |
| 37 | |
Harald Welte | 2720e73 | 2010-05-17 00:44:57 +0200 | [diff] [blame] | 38 | struct sgsn_instance { |
| 39 | char *config_file; |
| 40 | struct sgsn_config cfg; |
| 41 | /* File descriptor wrappers for LibGTP */ |
Pablo Neira Ayuso | 4db9299 | 2011-05-06 12:11:23 +0200 | [diff] [blame] | 42 | struct osmo_fd gtp_fd0; |
| 43 | struct osmo_fd gtp_fd1c; |
| 44 | struct osmo_fd gtp_fd1u; |
Harald Welte | 2720e73 | 2010-05-17 00:44:57 +0200 | [diff] [blame] | 45 | /* Timer for libGTP */ |
Pablo Neira Ayuso | bf540cb | 2011-05-06 12:11:06 +0200 | [diff] [blame] | 46 | struct osmo_timer_list gtp_timer; |
Harald Welte | 2720e73 | 2010-05-17 00:44:57 +0200 | [diff] [blame] | 47 | /* GSN instance for libgtp */ |
| 48 | struct gsn_t *gsn; |
Jacob Erlbeck | 39f040d | 2014-12-18 12:46:47 +0100 | [diff] [blame] | 49 | /* Subscriber */ |
| 50 | struct gprs_gsup_client *gsup_client; |
Harald Welte | 2720e73 | 2010-05-17 00:44:57 +0200 | [diff] [blame] | 51 | }; |
| 52 | |
Harald Welte | 8fc1a46 | 2010-05-17 00:53:10 +0200 | [diff] [blame] | 53 | extern struct sgsn_instance *sgsn; |
Harald Welte | 288be16 | 2010-05-01 16:48:27 +0200 | [diff] [blame] | 54 | |
| 55 | /* sgsn_vty.c */ |
| 56 | |
| 57 | int sgsn_vty_init(void); |
| 58 | int sgsn_parse_config(const char *config_file, struct sgsn_config *cfg); |
| 59 | |
| 60 | /* sgsn.c */ |
| 61 | |
| 62 | /* Main input function for Gb proxy */ |
| 63 | int sgsn_rcvmsg(struct msgb *msg, struct gprs_nsvc *nsvc, uint16_t ns_bvci); |
| 64 | |
Harald Welte | 6abf94e | 2010-05-18 10:35:06 +0200 | [diff] [blame] | 65 | |
Harald Welte | 77289c2 | 2010-05-18 14:32:29 +0200 | [diff] [blame] | 66 | struct sgsn_pdp_ctx *sgsn_create_pdp_ctx(struct sgsn_ggsn_ctx *ggsn, |
Harald Welte | 6abf94e | 2010-05-18 10:35:06 +0200 | [diff] [blame] | 67 | struct sgsn_mm_ctx *mmctx, |
| 68 | uint16_t nsapi, |
| 69 | struct tlv_parsed *tp); |
Harald Welte | 77289c2 | 2010-05-18 14:32:29 +0200 | [diff] [blame] | 70 | int sgsn_delete_pdp_ctx(struct sgsn_pdp_ctx *pctx); |
| 71 | |
Harald Welte | ebabdea | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 72 | /* gprs_sndcp.c */ |
| 73 | |
| 74 | /* Entry point for the SNSM-ACTIVATE.indication */ |
| 75 | int sndcp_sm_activate_ind(struct gprs_llc_lle *lle, uint8_t nsapi); |
Harald Welte | ce22f92 | 2010-06-03 21:21:21 +0200 | [diff] [blame] | 76 | /* Entry point for the SNSM-DEACTIVATE.indication */ |
| 77 | int sndcp_sm_deactivate_ind(struct gprs_llc_lle *lle, uint8_t nsapi); |
Harald Welte | ebabdea | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 78 | /* Called by SNDCP when it has received/re-assembled a N-PDU */ |
Harald Welte | 8911cef | 2010-07-01 19:56:19 +0200 | [diff] [blame] | 79 | int sgsn_rx_sndcp_ud_ind(struct gprs_ra_id *ra_id, int32_t tlli, uint8_t nsapi, |
| 80 | struct msgb *msg, uint32_t npdu_len, uint8_t *npdu); |
Harald Welte | bb1c805 | 2010-06-03 06:38:38 +0200 | [diff] [blame] | 81 | int sndcp_unitdata_req(struct msgb *msg, struct gprs_llc_lle *lle, uint8_t nsapi, |
| 82 | void *mmcontext); |
Holger Hans Peter Freyther | 3dccda5 | 2011-10-14 23:42:13 +0200 | [diff] [blame] | 83 | int sndcp_llunitdata_ind(struct msgb *msg, struct gprs_llc_lle *lle, |
| 84 | uint8_t *hdr, uint16_t len); |
Harald Welte | ebabdea | 2010-06-01 18:28:10 +0200 | [diff] [blame] | 85 | |
Harald Welte | 288be16 | 2010-05-01 16:48:27 +0200 | [diff] [blame] | 86 | #endif |