From 3535263cc37d8ed13f2a55eeac81ab86d7f53538 Mon Sep 17 00:00:00 2001
From: frtabu <francois.taburet@nokia-bell-labs.com>
Date: Mon, 8 Apr 2019 18:21:03 +0200
Subject: [PATCH] Add a LOG in nas_config.c, apply astyle for the 6 files CI
 mentioned as not well formatted

---
 openair2/ENB_APP/enb_config.c          |  2 +-
 openair2/NETWORK_DRIVER/UE_IP/device.c | 67 ++++++++------------------
 openair2/RRC/NAS/nas_config.c          | 16 ++++--
 3 files changed, 33 insertions(+), 52 deletions(-)

diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c
index 55c08079c71..341981fcf02 100644
--- a/openair2/ENB_APP/enb_config.c
+++ b/openair2/ENB_APP/enb_config.c
@@ -1921,7 +1921,7 @@ int RCconfig_S1(
 
               default: {
                 LOG_E(S1AP, "Default I-DRX value in conf file is invalid (%i). Should be 32, 64, 128 or 256. \
-                           Default DRX set to 32 in MME configuration\n",
+                         Default DRX set to 32 in MME configuration\n",
                       ccparams_lte.pcch_defaultPagingCycle);
                 S1AP_REGISTER_ENB_REQ(msg_p).default_drx = 0;
               }
diff --git a/openair2/NETWORK_DRIVER/UE_IP/device.c b/openair2/NETWORK_DRIVER/UE_IP/device.c
index 7fd183bca56..32f9442747d 100644
--- a/openair2/NETWORK_DRIVER/UE_IP/device.c
+++ b/openair2/NETWORK_DRIVER/UE_IP/device.c
@@ -51,13 +51,12 @@
 struct net_device *ue_ip_dev[UE_IP_NB_INSTANCES_MAX];
 
 #ifdef OAI_NW_DRIVER_USE_NETLINK
-extern void ue_ip_netlink_release(void);
-extern int ue_ip_netlink_init(void);
+  extern void ue_ip_netlink_release(void);
+  extern int ue_ip_netlink_init(void);
 #endif
 
 //---------------------------------------------------------------------------
-int ue_ip_find_inst(struct net_device *dev_pP)
-{
+int ue_ip_find_inst(struct net_device *dev_pP) {
   //---------------------------------------------------------------------------
   int i;
 
@@ -72,15 +71,12 @@ int ue_ip_find_inst(struct net_device *dev_pP)
 //---------------------------------------------------------------------------
 
 #ifndef OAI_NW_DRIVER_USE_NETLINK
-void *ue_ip_interrupt(void)
-{
+void *ue_ip_interrupt(void) {
   //---------------------------------------------------------------------------
   uint8_t cxi;
-
   //  ue_ip_priv_t *priv_p=netdev_priv(dev_id);
   //  unsigned int flags;
   //  priv_p->lock = SPIN_LOCK_UNLOCKED;
-
 #ifdef OAI_DRV_DEBUG_INTERRUPT
   printk("INTERRUPT - begin\n");
 #endif
@@ -100,9 +96,9 @@ void *ue_ip_interrupt(void)
 #endif //NETLINK
 //---------------------------------------------------------------------------
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
-void ue_ip_timer(struct timer_list *t)
+  void ue_ip_timer(struct timer_list *t)
 #else
-void ue_ip_timer(unsigned long dataP)
+  void ue_ip_timer(unsigned long dataP)
 #endif
 {
   //---------------------------------------------------------------------------
@@ -111,7 +107,6 @@ void ue_ip_timer(unsigned long dataP)
 #else
   ue_ip_priv_t *priv_p = (ue_ip_priv_t *)dataP;
 #endif
-
   spin_lock(&priv_p->lock);
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
   mod_timer(&priv_p->timer, jiffies + UE_IP_TIMER_TICK);
@@ -121,7 +116,6 @@ void ue_ip_timer(unsigned long dataP)
   (priv_p->timer).data = dataP;
   add_timer(&priv_p->timer);
 #endif
-
   spin_unlock(&priv_p->lock);
   return;
   //  add_timer(&gpriv->timer);
@@ -130,11 +124,9 @@ void ue_ip_timer(unsigned long dataP)
 
 //---------------------------------------------------------------------------
 // Called by ifconfig when the device is activated by ifconfig
-int ue_ip_open(struct net_device *dev_pP)
-{
+int ue_ip_open(struct net_device *dev_pP) {
   //---------------------------------------------------------------------------
   ue_ip_priv_t *priv_p=netdev_priv(dev_pP);
-
   // Address has already been set at init
 #ifndef OAI_NW_DRIVER_USE_NETLINK
 
@@ -161,18 +153,15 @@ int ue_ip_open(struct net_device *dev_pP)
   (priv_p->timer).function  = ue_ip_timer;
 #endif
   //add_timer(&priv_p->timer);
-
   printk("[UE_IP_DRV][%s] name = %s\n", __FUNCTION__, dev_pP->name);
   return 0;
 }
 
 //---------------------------------------------------------------------------
 // Called by ifconfig when the device is desactivated
-int ue_ip_stop(struct net_device *dev_pP)
-{
+int ue_ip_stop(struct net_device *dev_pP) {
   //---------------------------------------------------------------------------
   ue_ip_priv_t *priv_p = netdev_priv(dev_pP);
-
   printk("[UE_IP_DRV][%s] Begin\n", __FUNCTION__);
   del_timer(&(priv_p->timer));
   netif_stop_queue(dev_pP);
@@ -182,12 +171,10 @@ int ue_ip_stop(struct net_device *dev_pP)
 }
 
 //---------------------------------------------------------------------------
-void ue_ip_teardown(struct net_device *dev_pP)
-{
+void ue_ip_teardown(struct net_device *dev_pP) {
   //---------------------------------------------------------------------------
   ue_ip_priv_t    *priv_p;
   int              inst;
-
   printk("[UE_IP_DRV][%s] Begin\n", __FUNCTION__);
 
   if (dev_pP) {
@@ -199,7 +186,6 @@ void ue_ip_teardown(struct net_device *dev_pP)
       return;
     }
 
-
     printk("[UE_IP_DRV][%s] End\n", __FUNCTION__);
   } // check dev_pP
   else {
@@ -207,8 +193,7 @@ void ue_ip_teardown(struct net_device *dev_pP)
   }
 }
 //---------------------------------------------------------------------------
-int ue_ip_set_config(struct net_device *dev_pP, struct ifmap *map_pP)
-{
+int ue_ip_set_config(struct net_device *dev_pP, struct ifmap *map_pP) {
   //---------------------------------------------------------------------------
   printk("[UE_IP_DRV][%s] Begin\n", __FUNCTION__);
 
@@ -231,8 +216,7 @@ int ue_ip_set_config(struct net_device *dev_pP, struct ifmap *map_pP)
 
 //---------------------------------------------------------------------------
 //
-int ue_ip_hard_start_xmit(struct sk_buff *skb_pP, struct net_device *dev_pP)
-{
+int ue_ip_hard_start_xmit(struct sk_buff *skb_pP, struct net_device *dev_pP) {
   //---------------------------------------------------------------------------
   int inst;
 
@@ -284,15 +268,13 @@ int ue_ip_hard_start_xmit(struct sk_buff *skb_pP, struct net_device *dev_pP)
 }
 
 //---------------------------------------------------------------------------
-struct net_device_stats *ue_ip_get_stats(struct net_device *dev_pP)
-{
+struct net_device_stats *ue_ip_get_stats(struct net_device *dev_pP) {
   //---------------------------------------------------------------------------
   ue_ip_priv_t *priv_p = netdev_priv(dev_pP);
   return &priv_p->stats;
 }
 //---------------------------------------------------------------------------
-int ue_ip_set_mac_address(struct net_device *dev_pP, void *mac_pP)
-{
+int ue_ip_set_mac_address(struct net_device *dev_pP, void *mac_pP) {
   //---------------------------------------------------------------------------
   //struct sockaddr *addr = mac_pP;
   printk("[UE_IP_DRV][%s] CHANGE MAC ADDRESS UNSUPPORTED\n", __FUNCTION__);
@@ -300,8 +282,7 @@ int ue_ip_set_mac_address(struct net_device *dev_pP, void *mac_pP)
   return 0;
 }
 //---------------------------------------------------------------------------
-int ue_ip_change_mtu(struct net_device *dev_pP, int mtuP)
-{
+int ue_ip_change_mtu(struct net_device *dev_pP, int mtuP) {
   //---------------------------------------------------------------------------
   printk("[UE_IP_DRV][%s] CHANGE MTU %d bytes\n", __FUNCTION__, mtuP);
 
@@ -313,8 +294,7 @@ int ue_ip_change_mtu(struct net_device *dev_pP, int mtuP)
   return 0;
 }
 //---------------------------------------------------------------------------
-void ue_ip_change_rx_flags(struct net_device *dev_pP, int flagsP)
-{
+void ue_ip_change_rx_flags(struct net_device *dev_pP, int flagsP) {
   //---------------------------------------------------------------------------
   ue_ip_priv_t *priv_p =  netdev_priv(dev_pP);
   printk("[UE_IP_DRV][%s] CHANGE RX FLAGS %08X\n", __FUNCTION__, flagsP);
@@ -322,12 +302,10 @@ void ue_ip_change_rx_flags(struct net_device *dev_pP, int flagsP)
 }
 
 //---------------------------------------------------------------------------
-void ue_ip_tx_timeout(struct net_device *dev_pP)
-{
+void ue_ip_tx_timeout(struct net_device *dev_pP) {
   //---------------------------------------------------------------------------
   // Transmitter timeout, serious problems.
   ue_ip_priv_t *priv_p =  netdev_priv(dev_pP);
-
   printk("[UE_IP_DRV][%s] begin\n", __FUNCTION__);
   //  (ue_ip_priv_t *)(dev_pP->priv_p)->stats.tx_errors++;
   (priv_p->stats).tx_errors++;
@@ -361,8 +339,7 @@ static const struct net_device_ops ue_ip_netdev_ops = {
 
 //---------------------------------------------------------------------------
 // Initialisation of the network device
-void ue_ip_init(struct net_device *dev_pP)
-{
+void ue_ip_init(struct net_device *dev_pP) {
   //---------------------------------------------------------------------------
   ue_ip_priv_t *priv_p = NULL;
 
@@ -382,13 +359,10 @@ void ue_ip_init(struct net_device *dev_pP)
   }
 }
 //---------------------------------------------------------------------------
-int init_module (void)
-{
+int init_module (void) {
   //---------------------------------------------------------------------------
   int err,inst;
   char devicename[100];
-
-
   // Initialize parameters shared with RRC
   printk("[UE_IP_DRV][%s] Starting OAI IP driver", __FUNCTION__);
 
@@ -423,15 +397,12 @@ int init_module (void)
   }
 
   return err;
-
 }
 
 //---------------------------------------------------------------------------
-void cleanup_module(void)
-{
+void cleanup_module(void) {
   //---------------------------------------------------------------------------
   int inst;
-
   printk("[UE_IP_DRV][CLEANUP] begin\n");
 
   for (inst=0; inst<UE_IP_NB_INSTANCES_MAX; inst++) {
diff --git a/openair2/RRC/NAS/nas_config.c b/openair2/RRC/NAS/nas_config.c
index 240ea06f473..aa6696c864a 100644
--- a/openair2/RRC/NAS/nas_config.c
+++ b/openair2/RRC/NAS/nas_config.c
@@ -168,7 +168,6 @@ int setInterfaceParameter(char *interfaceName, char *settingAddress, int operati
   }
 
   close(sock_fd);
-  //    printf("Set OK!\n");
   return 0;
 }
 
@@ -225,7 +224,9 @@ int NAS_config(char *interfaceName, char *ipAddress, char *networkMask, char *br
 
   //  if(!returnValue)
   //  returnValue=set_gateway(interfaceName, broadcastAddress);
-  bringInterfaceUp(interfaceName, 1);
+  if(!returnValue)
+    returnValue = bringInterfaceUp(interfaceName, 1);
+
   return returnValue;
 }
 
@@ -252,7 +253,16 @@ int nas_config(int interface_id, int thirdOctet, int fourthOctet, char *ifname)
   if(!returnValue)
     returnValue= setInterfaceParameter(interfaceName, broadcastAddress,SIOCSIFBRDADDR);
 
-  bringInterfaceUp(interfaceName, 1);
+  if(!returnValue)
+    bringInterfaceUp(interfaceName, 1);
+
+  if(!returnValue)
+    LOG_I(OIP,"Interface %s successfuly configured, ip address %s, mask %s broadcast address %s\n",
+          interfaceName, ipAddress, netMask, broadcastAddress);
+  else
+    LOG_E(OIP,"Interface %s couldn't be configured (ip address %s, mask %s broadcast address %s)\n",
+          interfaceName, ipAddress, netMask, broadcastAddress);
+
   return returnValue;
 }
 
-- 
GitLab