From 9eaa72d86bc29a1238bb73a39d1fc937af5a71e1 Mon Sep 17 00:00:00 2001
From: Chun-Yeow Yeoh <yeohchunyeow@gmail.com>
Date: Tue, 14 Jul 2015 18:21:03 +0800
Subject: [PATCH] UE: add PCO in PDN Connectivity Request message

Add the PCO so that MME allocates the IP address
accordingly. The protocol ID known as "IP address
allocation via NAS signalling" is assigned.

Otherwise, the OAI UE will always has IP address
set to 0.0.0.0

This has tested with OAI eNB with S1 interface using
OAI EPC.

Reference:
http://www.sharetechnote.com/html/Handbook_LTE_ProtocolConfigurationOption.html

This patch is merged with Cedric's patch and tested.

Signed-off-by: Chun-Yeow Yeoh <yeow@tmrnd.com.my>
Signed-off-by: Cedric Roux <Cedric.Roux@eurecom.fr>
---
 openair3/NAS/UE/ESM/SAP/esm_send.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/openair3/NAS/UE/ESM/SAP/esm_send.c b/openair3/NAS/UE/ESM/SAP/esm_send.c
index ab5341062a..51cd96fdc8 100755
--- a/openair3/NAS/UE/ESM/SAP/esm_send.c
+++ b/openair3/NAS/UE/ESM/SAP/esm_send.c
@@ -181,6 +181,35 @@ int esm_send_pdn_connectivity_request(int pti, int is_emergency, int pdn_type,
     }
   }
 
+  /* Add PCO */
+# define CONFIGURATION_PROTOCOL_PPP          0
+# define PROTOCOL_ID_IPCP                    0x8021
+# define PROTOCOL_ID_DNS_SERVER_IPV4_ADDRESS 0x000D
+# define PROTOCOL_ID_IP_ADDR_NAS_SIGNALING   0x000A
+
+  msg->presencemask |= PDN_CONNECTIVITY_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
+  msg->protocolconfigurationoptions.configurationprotol = CONFIGURATION_PROTOCOL_PPP;
+  msg->protocolconfigurationoptions.num_protocol_id_or_container_id = 3;
+  msg->protocolconfigurationoptions.protocolid[0] = PROTOCOL_ID_IPCP;
+  msg->protocolconfigurationoptions.lengthofprotocolid[0] = 16; /* Size of PROTOCOL_ID_IPCP */
+  msg->protocolconfigurationoptions.protocolidcontents[0].value = (uint8_t *)
+  /* PROTOCOL_ID_IPCP data */
+  /* the format is as of RFC 1331 (see page 27) */
+  "\x01"                  /* Configure-Request                    */
+  "\x00"                  /* Indentifier (set to 0)               */
+  "\x00\x10"              /* Length (16 bytes)                    */
+    "\x81"                /* Type = Primary DNS - see RFC 1877    */
+    "\x06"                /* length                               */
+    "\x00\x00\x00\x00"    /* IP address set to 0                  */
+    "\x83"                /* Type = Secondary DNS - see RFC 1877  */
+    "\x06"                /* length                               */
+    "\x00\x00\x00\x00";   /* IP address set to 0                  */
+  msg->protocolconfigurationoptions.protocolidcontents[0].length = 16;
+  msg->protocolconfigurationoptions.protocolid[1] = PROTOCOL_ID_DNS_SERVER_IPV4_ADDRESS;
+  msg->protocolconfigurationoptions.lengthofprotocolid[1] = 0x00;
+  msg->protocolconfigurationoptions.protocolid[2] = PROTOCOL_ID_IP_ADDR_NAS_SIGNALING;
+  msg->protocolconfigurationoptions.lengthofprotocolid[2] = 0x00;
+
   LOG_TRACE(INFO, "ESM-SAP   - Send PDN Connectivity Request message "
             "(pti=%d, ebi=%d)",
             msg->proceduretransactionidentity, msg->epsbeareridentity);
-- 
GitLab