MME2 changes - Propped commits from openmme/paging branch. Added scripts
for code gen
Change-Id: Ie55032217232214ac8544ca76ea34335205329e4
diff --git a/include/s11/gtpv2c.h b/include/s11/gtpv2c.h
new file mode 100644
index 0000000..6177146
--- /dev/null
+++ b/include/s11/gtpv2c.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2003-2018, Great Software Laboratory Pvt. Ltd.
+ * Copyright (c) 2017 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __GTPV2C_H_
+#define __GTPV2C_H_
+
+#include <stdint.h>
+
+#include "s11_structs.h"
+
+#define MAX_GTPV2C_UDP_LEN 4096
+
+#define GTP_VERSION_GTPV2C 2
+
+/* GTP Message Type */
+#define GTP_CREATE_SESSION_REQ 32
+#define GTP_CREATE_SESSION_RSP 33
+#define GTP_MODIFY_BEARER_REQ 34
+#define GTP_MODIFY_BEARER_RSP 35
+#define GTP_DELETE_SESSION_REQ 36
+#define GTP_DELETE_SESSION_RSP 37
+//S1 Release
+#define GTP_RELEASE_BEARER_REQ 170
+
+enum gtpv2c_interfaces {
+ GTPV2C_IFTYPE_S1U_ENODEB_GTPU = 0,
+};
+
+
+void
+set_gtpv2c_header(struct gtpv2c_header *gtpv2c_tx, uint8_t type,
+ uint32_t teid, uint32_t seq);
+
+#endif /* __GTPV2C_H_ */
diff --git a/include/s11/gtpv2c_ie.h b/include/s11/gtpv2c_ie.h
new file mode 100644
index 0000000..05f409f
--- /dev/null
+++ b/include/s11/gtpv2c_ie.h
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2003-2018, Great Software Laboratory Pvt. Ltd.
+ * Copyright (c) 2017 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __GTPV2C_IE_H_
+#define __GTPV2C_IE_H_
+
+
+#include <inttypes.h>
+#include <stdlib.h>
+#include <netinet/in.h>
+
+#define IPV4_IE_LENGTH 4
+#define IPV6_IE_LENGTH 16
+
+/* TODO: Check size */
+#define GTPV2C_MAX_LEN 4096
+
+#define AMBR_UPLINK 100000000
+#define AMBR_DOWNLINK 50000000
+
+#define MBR_UPLINK 245018193L//245018193976L
+#define MBR_DOWNLINK 245018193L//245018193976L
+
+enum gtpv2c_ie_type {
+ IE_RESERVED = 0,
+ IE_IMSI = 1,
+ IE_APN = 71,
+ IE_AMBR = 72,
+ IE_EBI = 73,
+ IE_INDICATION = 77,
+ IE_MSISDN = 76,
+ IE_PAA = 79,
+ IE_BEARER_QOS = 80,
+ IE_RAT_TYPE = 82,
+ IE_SERVING_NETWORK = 83,
+ IE_ULI = 86,
+ IE_FTEID = 87,
+ IE_BEARER_CONTEXT = 93,
+ IE_PDN_TYPE = 99,
+ IE_APN_RESTRICTION = 127,
+ IE_SELECTION_MODE = 128,
+};
+
+enum cause_value {
+ GTPV2C_CAUSE_REQUEST_ACCEPTED = 16,
+ GTPV2C_CAUSE_REQUEST_ACCEPTED_PARTIALLY = 17,
+ GTPV2C_CAUSE_NEW_PDN_TYPE_NETWORK_PREFERENCE = 18,
+ GTPV2C_CAUSE_NEW_PDN_TYPE_SINGLE_ADDR_BEARER = 19,
+ GTPV2C_CAUSE_CONTEXT_NOT_FOUND = 64,
+ GTPV2C_CAUSE_INVALID_MESSAGE_FORMAT = 65,
+ GTPV2C_CAUSE_INVALID_LENGTH = 67,
+ GTPV2C_CAUSE_SERVICE_NOT_SUPPORTED = 68,
+ GTPV2C_CAUSE_MANDATORY_IE_INCORRECT = 69,
+ GTPV2C_CAUSE_MANDATORY_IE_MISSING = 70,
+ GTPV2C_CAUSE_SYSTEM_FAILURE = 72,
+ GTPV2C_CAUSE_NO_RESOURCES_AVAILABLE = 73,
+ GTPV2C_CAUSE_MISSING_UNKNOWN_APN = 78,
+ GTPV2C_CAUSE_PREFERRED_PDN_TYPE_UNSUPPORTED = 83,
+ GTPV2C_CAUSE_ALL_DYNAMIC_ADDRESSES_OCCUPIED = 84,
+ GTPV2C_CAUSE_REQUEST_REJECTED = 94,
+ GTPV2C_CAUSE_REMOTE_PEER_NOT_RESPONDING = 100,
+ GTPV2C_CAUSE_CONDITIONAL_IE_MISSING = 103,
+};
+
+#define PDN_IP_TYPE_IPV4 1
+#define PDN_IP_TYPE_IPV6 2
+#define PDN_IP_TYPE_IPV4V6 3
+
+
+enum gtpv2c_ie_instance {
+ INSTANCE_ZERO = 0,
+ INSTANCE_ONE = 1,
+ INSTANCE_TWO = 2,
+};
+
+#pragma pack(1)
+
+
+typedef struct gtpv2c_ie_t {
+ uint8_t type;
+ uint16_t length;
+ uint8_t instance;
+ uint8_t value[GTPV2C_MAX_LEN];
+} gtpv2c_ie;
+
+
+typedef struct fteid_ie_t {
+ uint8_t iface_type :6;
+ uint8_t ipv6 :1;
+ uint8_t ipv4 :1;
+ uint32_t teid;
+ union ip_t {
+ uint32_t ipv4;
+ uint8_t ipv6[INET6_ADDRSTRLEN];
+ struct ipv4v6_t_x {
+ uint32_t ipv4;
+ uint8_t ipv6[INET6_ADDRSTRLEN];
+ } ipv4v6;
+ } ipaddr;
+} fteid_ie;
+
+
+#pragma pack()
+
+#endif /* __GTPV2C_IE_H_ */
diff --git a/include/s11/s11.h b/include/s11/s11.h
new file mode 100644
index 0000000..cdc6536
--- /dev/null
+++ b/include/s11/s11.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2019, Infosys Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __UE_S11_H_
+#define __UE_S11_H_
+
+#include <stdint.h>
+#include "log.h"
+#include "s11_structs.h"
+
+/*No of threads handling S11 GTPv2 messages coming in*/
+#define S11_THREADPOOL_SIZE 5
+
+#define S11_GTPV2C_BUF_LEN 4096
+
+/*GTPv2c message types*/
+#define S11_GTP_CREATE_SESSION_REQ 32
+#define S11_GTP_CREATE_SESSION_RESP 33
+#define S11_GTP_MODIFY_BEARER_RESP 35
+#define S11_GTP_DELETE_SESSION_RESP 37
+#define S11_GTP_RELEASE_BEARER_REQ 170
+#define S11_GTP_RELEASE_BEARER_RESP 171
+#define S11_GTP_DDN 176
+
+/*GTPv2c IE message types*/
+#define S11_IE_CAUSE 2
+#define S11_IE_FTEID_C 87
+#define S11_IE_PAA 79
+#define S11_IE_APN_RESTRICTION 127
+#define S11_IE_BEARER_CTX 93
+#define S11_IE_EPS_BEARER_ID 73
+
+int
+init_s11();
+
+void
+handle_s11_message(void *message);
+
+int
+init_s11();
+
+void
+handle_s11_message(void *message);
+
+int
+s11_transation(char * buf, unsigned int len);
+
+void* create_session_handler(void *);
+void* modify_bearer_handler(void *);
+void* release_bearer_handler(void *);
+void* delete_session_handler(void *);
+void* ddn_ack_handler(void *);
+/*int s11_CS_resp_handler(char *message);
+int s11_MB_resp_handler(char *message);
+int s11_DS_resp_handler(char *message);
+int s11_RB_resp_handler(char *message);
+int s11_DDN_handler(char *message);
+*/
+
+
+void
+bswap8_array(uint8_t *src, uint8_t *dest, uint32_t len);
+
+int parse_gtpv2c_IEs(char *msg, int len, struct s11_proto_IE *proto_ies);
+
+#endif /*S11_H*/
diff --git a/include/s11/s11_config.h b/include/s11/s11_config.h
new file mode 100644
index 0000000..98de079
--- /dev/null
+++ b/include/s11/s11_config.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2003-2018, Great Software Laboratory Pvt. Ltd.
+ * Copyright (c) 2017 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __S11_CONFIG_H_
+#define __S11_CONFIG_H_
+
+#include <stdbool.h>
+
+typedef struct s11_config
+{
+ unsigned int sgw_ip;
+ unsigned int pgw_ip;
+ unsigned int egtp_def_port;
+ unsigned int local_egtp_ip;
+} s11_config;
+
+void
+init_parser(char *path);
+
+int
+parse_s11_conf();
+
+#endif /*__S11_CONFIG_H*/