blob: 78064dddcb0b83ca86b78941982e2b50d93c7182 [file] [log] [blame]
Harald Welte288be162010-05-01 16:48:27 +02001#ifndef _SGSN_H
2#define _SGSN_H
3
Harald Welte288be162010-05-01 16:48:27 +02004
Pablo Neira Ayuso136f4532011-03-22 16:47:59 +01005#include <osmocom/core/msgb.h>
Harald Welte288be162010-05-01 16:48:27 +02006
Harald Welteea34a4e2012-06-16 14:59:56 +08007#include <osmocom/gprs/gprs_ns.h>
Harald Welte6abf94e2010-05-18 10:35:06 +02008#include <openbsc/gprs_sgsn.h>
Harald Welte288be162010-05-01 16:48:27 +02009
Jacob Erlbeck39f040d2014-12-18 12:46:47 +010010struct gprs_gsup_client;
11
Jacob Erlbeck106f5472014-11-04 10:08:37 +010012enum sgsn_auth_policy {
13 SGSN_AUTH_POLICY_OPEN,
14 SGSN_AUTH_POLICY_CLOSED,
Jacob Erlbeckbe2c8d92014-11-12 10:18:09 +010015 SGSN_AUTH_POLICY_ACL_ONLY,
16 SGSN_AUTH_POLICY_REMOTE
Jacob Erlbeck106f5472014-11-04 10:08:37 +010017};
18
Harald Welte288be162010-05-01 16:48:27 +020019struct sgsn_config {
20 /* parsed from config file */
Harald Welte288be162010-05-01 16:48:27 +020021
Harald Welte2720e732010-05-17 00:44:57 +020022 char *gtp_statedir;
23 struct sockaddr_in gtp_listenaddr;
24
Harald Welte288be162010-05-01 16:48:27 +020025 /* misc */
26 struct gprs_ns_inst *nsi;
Harald Welte7f6da482013-03-19 11:00:13 +010027
Jacob Erlbeck106f5472014-11-04 10:08:37 +010028 enum sgsn_auth_policy auth_policy;
Harald Welte7f6da482013-03-19 11:00:13 +010029 struct llist_head imsi_acl;
Jacob Erlbeck39f040d2014-12-18 12:46:47 +010030
31 struct sockaddr_in gsup_server_addr;
32 int gsup_server_port;
Jacob Erlbeck9d4f46c2014-12-17 13:20:08 +010033
34 int require_authentication;
Jacob Erlbeck771573c2014-12-19 18:08:48 +010035 int require_update_location;
Harald Welte288be162010-05-01 16:48:27 +020036};
37
Harald Welte2720e732010-05-17 00:44:57 +020038struct sgsn_instance {
39 char *config_file;
40 struct sgsn_config cfg;
41 /* File descriptor wrappers for LibGTP */
Pablo Neira Ayuso4db92992011-05-06 12:11:23 +020042 struct osmo_fd gtp_fd0;
43 struct osmo_fd gtp_fd1c;
44 struct osmo_fd gtp_fd1u;
Harald Welte2720e732010-05-17 00:44:57 +020045 /* Timer for libGTP */
Pablo Neira Ayusobf540cb2011-05-06 12:11:06 +020046 struct osmo_timer_list gtp_timer;
Harald Welte2720e732010-05-17 00:44:57 +020047 /* GSN instance for libgtp */
48 struct gsn_t *gsn;
Jacob Erlbeck39f040d2014-12-18 12:46:47 +010049 /* Subscriber */
50 struct gprs_gsup_client *gsup_client;
Harald Welte2720e732010-05-17 00:44:57 +020051};
52
Harald Welte8fc1a462010-05-17 00:53:10 +020053extern struct sgsn_instance *sgsn;
Harald Welte288be162010-05-01 16:48:27 +020054
55/* sgsn_vty.c */
56
57int sgsn_vty_init(void);
58int sgsn_parse_config(const char *config_file, struct sgsn_config *cfg);
59
60/* sgsn.c */
61
62/* Main input function for Gb proxy */
63int sgsn_rcvmsg(struct msgb *msg, struct gprs_nsvc *nsvc, uint16_t ns_bvci);
64
Harald Welte6abf94e2010-05-18 10:35:06 +020065
Harald Welte77289c22010-05-18 14:32:29 +020066struct sgsn_pdp_ctx *sgsn_create_pdp_ctx(struct sgsn_ggsn_ctx *ggsn,
Harald Welte6abf94e2010-05-18 10:35:06 +020067 struct sgsn_mm_ctx *mmctx,
68 uint16_t nsapi,
69 struct tlv_parsed *tp);
Harald Welte77289c22010-05-18 14:32:29 +020070int sgsn_delete_pdp_ctx(struct sgsn_pdp_ctx *pctx);
71
Harald Welteebabdea2010-06-01 18:28:10 +020072/* gprs_sndcp.c */
73
74/* Entry point for the SNSM-ACTIVATE.indication */
75int sndcp_sm_activate_ind(struct gprs_llc_lle *lle, uint8_t nsapi);
Harald Weltece22f922010-06-03 21:21:21 +020076/* Entry point for the SNSM-DEACTIVATE.indication */
77int sndcp_sm_deactivate_ind(struct gprs_llc_lle *lle, uint8_t nsapi);
Harald Welteebabdea2010-06-01 18:28:10 +020078/* Called by SNDCP when it has received/re-assembled a N-PDU */
Harald Welte8911cef2010-07-01 19:56:19 +020079int 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 Weltebb1c8052010-06-03 06:38:38 +020081int sndcp_unitdata_req(struct msgb *msg, struct gprs_llc_lle *lle, uint8_t nsapi,
82 void *mmcontext);
Holger Hans Peter Freyther3dccda52011-10-14 23:42:13 +020083int sndcp_llunitdata_ind(struct msgb *msg, struct gprs_llc_lle *lle,
84 uint8_t *hdr, uint16_t len);
Harald Welteebabdea2010-06-01 18:28:10 +020085
Harald Welte288be162010-05-01 16:48:27 +020086#endif