blob: 48a7b3474c75f5e4d79eee47c3555ef7535b180d [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
10struct sgsn_config {
11 /* parsed from config file */
Harald Welte288be162010-05-01 16:48:27 +020012
Harald Welte2720e732010-05-17 00:44:57 +020013 char *gtp_statedir;
14 struct sockaddr_in gtp_listenaddr;
15
Harald Welte288be162010-05-01 16:48:27 +020016 /* misc */
17 struct gprs_ns_inst *nsi;
18};
19
Harald Welte2720e732010-05-17 00:44:57 +020020struct sgsn_instance {
21 char *config_file;
22 struct sgsn_config cfg;
23 /* File descriptor wrappers for LibGTP */
Pablo Neira Ayuso4db92992011-05-06 12:11:23 +020024 struct osmo_fd gtp_fd0;
25 struct osmo_fd gtp_fd1c;
26 struct osmo_fd gtp_fd1u;
Harald Welte2720e732010-05-17 00:44:57 +020027 /* Timer for libGTP */
Pablo Neira Ayusobf540cb2011-05-06 12:11:06 +020028 struct osmo_timer_list gtp_timer;
Harald Welte2720e732010-05-17 00:44:57 +020029 /* GSN instance for libgtp */
30 struct gsn_t *gsn;
31};
32
Harald Welte8fc1a462010-05-17 00:53:10 +020033extern struct sgsn_instance *sgsn;
Harald Welte288be162010-05-01 16:48:27 +020034
35/* sgsn_vty.c */
36
37int sgsn_vty_init(void);
38int sgsn_parse_config(const char *config_file, struct sgsn_config *cfg);
39
40/* sgsn.c */
41
42/* Main input function for Gb proxy */
43int sgsn_rcvmsg(struct msgb *msg, struct gprs_nsvc *nsvc, uint16_t ns_bvci);
44
Harald Welte6abf94e2010-05-18 10:35:06 +020045
Harald Welte77289c22010-05-18 14:32:29 +020046struct sgsn_pdp_ctx *sgsn_create_pdp_ctx(struct sgsn_ggsn_ctx *ggsn,
Harald Welte6abf94e2010-05-18 10:35:06 +020047 struct sgsn_mm_ctx *mmctx,
48 uint16_t nsapi,
49 struct tlv_parsed *tp);
Harald Welte77289c22010-05-18 14:32:29 +020050int sgsn_delete_pdp_ctx(struct sgsn_pdp_ctx *pctx);
51
Harald Welteebabdea2010-06-01 18:28:10 +020052/* gprs_sndcp.c */
53
54/* Entry point for the SNSM-ACTIVATE.indication */
55int sndcp_sm_activate_ind(struct gprs_llc_lle *lle, uint8_t nsapi);
Harald Weltece22f922010-06-03 21:21:21 +020056/* Entry point for the SNSM-DEACTIVATE.indication */
57int sndcp_sm_deactivate_ind(struct gprs_llc_lle *lle, uint8_t nsapi);
Harald Welteebabdea2010-06-01 18:28:10 +020058/* Called by SNDCP when it has received/re-assembled a N-PDU */
Harald Welte8911cef2010-07-01 19:56:19 +020059int sgsn_rx_sndcp_ud_ind(struct gprs_ra_id *ra_id, int32_t tlli, uint8_t nsapi,
60 struct msgb *msg, uint32_t npdu_len, uint8_t *npdu);
Harald Weltebb1c8052010-06-03 06:38:38 +020061int sndcp_unitdata_req(struct msgb *msg, struct gprs_llc_lle *lle, uint8_t nsapi,
62 void *mmcontext);
Holger Hans Peter Freyther3dccda52011-10-14 23:42:13 +020063int sndcp_llunitdata_ind(struct msgb *msg, struct gprs_llc_lle *lle,
64 uint8_t *hdr, uint16_t len);
Harald Welteebabdea2010-06-01 18:28:10 +020065
Harald Welte288be162010-05-01 16:48:27 +020066#endif