Move struct apn_ctx and APN related definitions to its own file

This allows further shrinking of gprs_sgsn.{c,h} and also being able to
use GSM_APN_LENGTH on different headers easily (needed by follow-up
patch).

Change-Id: Id225ed8b84e1376f4a30f17dd4b153b6b1a6efa8
diff --git a/include/osmocom/sgsn/Makefile.am b/include/osmocom/sgsn/Makefile.am
index fc4f597..4d43c6d 100644
--- a/include/osmocom/sgsn/Makefile.am
+++ b/include/osmocom/sgsn/Makefile.am
@@ -1,4 +1,5 @@
 noinst_HEADERS = \
+	apn.h \
 	common.h \
 	crc24.h \
 	debug.h \
diff --git a/include/osmocom/sgsn/apn.h b/include/osmocom/sgsn/apn.h
new file mode 100644
index 0000000..adf62e2
--- /dev/null
+++ b/include/osmocom/sgsn/apn.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include <osmocom/core/linuxlist.h>
+
+struct sgsn_ggsn_ctx;
+
+#define GSM_APN_LENGTH 102
+
+extern struct llist_head sgsn_apn_ctxts;
+
+struct apn_ctx {
+	struct llist_head list;
+	struct sgsn_ggsn_ctx *ggsn;
+	char *name;
+	char *imsi_prefix;
+	char *description;
+};
+
+struct apn_ctx *sgsn_apn_ctx_find_alloc(const char *name, const char *imsi_prefix);
+void sgsn_apn_ctx_free(struct apn_ctx *actx);
+struct apn_ctx *sgsn_apn_ctx_by_name(const char *name, const char *imsi_prefix);
+struct apn_ctx *sgsn_apn_ctx_match(const char *name, const char *imsi_prefix);
diff --git a/include/osmocom/sgsn/gprs_sgsn.h b/include/osmocom/sgsn/gprs_sgsn.h
index 541d854..6d51b30 100644
--- a/include/osmocom/sgsn/gprs_sgsn.h
+++ b/include/osmocom/sgsn/gprs_sgsn.h
@@ -14,10 +14,10 @@
 #include <osmocom/gsm/protocol/gsm_23_003.h>
 #include <osmocom/crypt/auth.h>
 
+#include <osmocom/sgsn/apn.h>
 #include <osmocom/sgsn/gprs_subscriber.h>
 
 #define GSM_EXTENSION_LENGTH 15
-#define GSM_APN_LENGTH 102
 
 struct gprs_llc_lle;
 struct ctrl_handle;
@@ -362,21 +362,7 @@
 void sgsn_pdp_ctx_terminate(struct sgsn_pdp_ctx *pdp);
 void sgsn_pdp_ctx_free(struct sgsn_pdp_ctx *pdp);
 
-struct apn_ctx {
-	struct llist_head list;
-	struct sgsn_ggsn_ctx *ggsn;
-	char *name;
-	char *imsi_prefix;
-	char *description;
-};
-
-struct apn_ctx *sgsn_apn_ctx_find_alloc(const char *name, const char *imsi_prefix);
-void sgsn_apn_ctx_free(struct apn_ctx *actx);
-struct apn_ctx *sgsn_apn_ctx_by_name(const char *name, const char *imsi_prefix);
-struct apn_ctx *sgsn_apn_ctx_match(const char *name, const char *imsi_prefix);
-
 extern struct llist_head sgsn_mm_ctxts;
-extern struct llist_head sgsn_apn_ctxts;
 extern struct llist_head sgsn_pdp_ctxts;
 
 uint32_t sgsn_alloc_ptmsi(void);
diff --git a/include/osmocom/sgsn/gprs_subscriber.h b/include/osmocom/sgsn/gprs_subscriber.h
index a961c45..2e53bdf 100644
--- a/include/osmocom/sgsn/gprs_subscriber.h
+++ b/include/osmocom/sgsn/gprs_subscriber.h
@@ -6,6 +6,8 @@
 #include <osmocom/core/linuxlist.h>
 #include <osmocom/gsm/protocol/gsm_23_003.h>
 
+#include <osmocom/sgsn/apn.h>
+
 struct sgsn_instance;
 struct sgsn_mm_ctx;