]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/netapi.git/commitdiff
SDOCM00112355: Need multi-instance support of IPSecMgr library
authorTinku Mannan <tmannan@ti.com>
Tue, 21 Oct 2014 16:35:40 +0000 (12:35 -0400)
committerTinku Mannan <tmannan@ti.com>
Tue, 21 Oct 2014 16:35:40 +0000 (12:35 -0400)
ti/runtime/netapi/applications/ipsec_offload/config-app/src/cmd_shell_main.c
ti/runtime/netapi/applications/ipsec_offload/ipsecmgr/src/netapi_ipsecmgr.c
ti/runtime/netapi/applications/ipsec_offload/ipsecmgr/src/netapilib_interface.h

index d610a639767eab2a9bb2b84c2bdcf641829ebb49..22f34e6d7372142c484338c41993333654c15beb 100755 (executable)
@@ -38,6 +38,8 @@
 #include <time.h>
 #include <pthread.h>
 #include <string.h>
+#include <stdarg.h>
+#include <unistd.h>
 
 #include <ipsecmgr_ipc.h>
 #include <ipsecmgr_syslog.h>
@@ -150,14 +152,35 @@ int main(int argc, char **argv)
     ipsecmgr_ipc_user_recv_if_t recv_if;
     task_handle cmd_th, ipc_th;
     int status;
+    int c;
+    static char usage[] = "usage: %s -s <daemon id>\n";
 
+    memset(&ipc_cfg, 0, sizeof(ipc_cfg));
+    while ((c = getopt (argc, argv, "i:")) != -1)
+    {
+        switch (c)
+        {
+            case 'i':
+                ipc_cfg.ipc_id = (uint32_t)strtol(optarg, NULL,0);
+                if(!ipc_cfg.ipc_id)
+                {
+                    printf(usage, argv[0]);
+                    exit(EXIT_FAILURE);
+                }
+                break;
+        case '?':
+            printf(usage, argv[0]);
+            exit(EXIT_FAILURE);
+        default:
+            break;
+        }
+    }
     /* Start logging module */
     if (ipsecmgr_syslog_init()) {
         printf ("Failed to initialize syslog\n");
         return -1;
     }
 
-    memset(&ipc_cfg, 0, sizeof(ipc_cfg));
     ipc_cfg.mode = IPC_MODE_USER_APP;
 
     if (ipsecmgr_ipc_init(&ipc_cfg)) {
index 6b500da3c28c6cd82dc96d18daac0c1457b24339..0fb26c1e057085b6f1130d06abaa8fdc2a431f9a 100755 (executable)
@@ -493,6 +493,7 @@ static int32_t init_ipsecmgr (void)
 
     /* Initialize IPC library */
     ipc_cfg.mode = IPC_MODE_SNOOP_DAEMON;
+    ipc_cfg.ipc_id = globalDB.ipc_id;
     if (ipsecmgr_ipc_init(&ipc_cfg)) {
         ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
             "init_ipsecmgr: ipc_init failed\n");
@@ -783,15 +784,19 @@ int32_t main (int argc, char* argv[])
     struct sockaddr_in6 ipv6_addr;
     cpu_set_t cpu_set;
     int c;
-    static char usage[] = "usage: %s -r < use Resource manager: no/yes> -s <outbound sequence number> -f <SA transmit flow Id>\n";
+    static char usage[] = "usage: %s -s <outbound sequence number>\n \
+               -f <SA transmit flow Id>\n \
+               -i<daemon id>\n \
+               -m <master Type ,sysMaster or procMaster >\n";
 
     ipsecmgr_syslog_init();
 
 
     memset(&globalDB, 0, sizeof(globalDB));
     globalDB.sa_tx_flow = -1;
+    globalDB.masterType = NETAPI_SYS_MASTER;
     int temp;
-    while ((c = getopt (argc, argv, "s:f:")) != -1)
+    while ((c = getopt (argc, argv, "s:f:i:m:")) != -1)
     {
        switch (c)
        {
@@ -827,6 +832,37 @@ int32_t main (int argc, char* argv[])
                     }
                 }
                 break;
+            case 'i':
+                /* check is user input 0 for daemon id, valid */
+                 if(strncmp("0", optarg,1) == 0)
+                 {
+                     globalDB.ipc_id= 0;
+                 }
+                 else
+                 {
+                     globalDB.ipc_id = (uint32_t)strtol(optarg, NULL,0);
+                     if(!globalDB.ipc_id)
+                     {
+                         printf(usage, argv[0]);
+                         exit(EXIT_FAILURE);
+                     }
+                 }
+                 break;
+            case 'm':
+                if(strcmp("sysMaster", optarg) == 0)
+                {
+                    globalDB.masterType = NETAPI_SYS_MASTER;
+                }
+                else if (strcmp("procMaster", optarg) == 0)
+                {
+                    globalDB.masterType = NETAPI_PROC_MASTER;
+                }
+                else
+                {
+                    printf(usage, argv[0]);
+                    exit(EXIT_FAILURE);
+                }
+                break;
             case '?':
                 printf(usage, argv[0]);
                 exit(EXIT_FAILURE);
@@ -851,7 +887,7 @@ int32_t main (int argc, char* argv[])
     CPU_SET( 0, &cpu_set);
     hplib_utilSetupThread(0, &cpu_set, hplib_spinLock_Type_LOL);
     /* create netapi */
-    netapi_handle = netapi_init(NETAPI_SYS_MASTER,
+    netapi_handle = netapi_init(globalDB.masterType,
                                 &our_netapi_default_cfg);
     if(netapi_handle == NULL)
     {
index b515a2570fe140c1696d17f1d5966e5d71a0cef1..45337b40c5486e5a8dea6eed0835a6f9bf28e1ea 100755 (executable)
@@ -57,6 +57,10 @@ typedef struct {
     ipsecMgrAppId_T tx_sa[64];
     uint32_t        oseq_offset; /* offset to outbound/egress sequence number */
     int             sa_tx_flow;  /* flow SA to use to transmit packet */
+    int             ipc_id;      /* ipc_id to give name uniqueness to socket
+                                    connection with command shell */
+    int             masterType;  /* Specifies to run the daemon as NETAPI_SYS_MASTER or
+                                    NETAPI_PROC_MASTER */
 } ipsecMgrMcb_t;
 
 int netapilib_ifAddSA