correct simulator
authorMazet Laurent <laurent.mazet@thalesgroup.com>
Wed, 7 May 2025 13:12:53 +0000 (15:12 +0200)
committerMazet Laurent <laurent.mazet@thalesgroup.com>
Wed, 7 May 2025 13:12:53 +0000 (15:12 +0200)
morep_simulator.c
simulator/script-simulator.sh

index d6c43437b6812771e182e22990be6555b6fa14de..fa9eabd54ae423a5802488a0353c4a4f8f7497b2 100644 (file)
@@ -264,7 +264,7 @@ int main (int argc, char **argv)
                     for (int i = 0; (service_list + i)->service_id != noserv_e; i++) {
                         service_t *s = service_list + i;
                         if (s && servname && (strcmp (s->name, servname) == 0)) {
-                            memcpy (mode ? &(s->rx) : &(s->tx), comm_list + nbcomms, sizeof (comm_t));
+                            memcpy ((mode == 0) ? &(s->rx) : &(s->tx), comm_list + nbcomms, sizeof (comm_t));
                             break;
                         }
                     }
@@ -367,7 +367,7 @@ int main (int argc, char **argv)
             service_t *s = service_list + i;
             VERBOSE (simul, TRACE, PRINTF ("test %c[%s]\n", *line, s->name));
             if (strncmp (line + offset, s->name, strlen (s->name)) == 0) {
-                comm = mode ? &(s->rx) : &(s->tx);
+                comm = (mode == 0) ? &(s->rx) : &(s->tx);
                 serv = s;
                 offset += strlen (s->name);
             }
@@ -375,12 +375,12 @@ int main (int argc, char **argv)
         /* find MOREP by ethertype */
         for (int j = 0; (j < nbcomms) && (comm == NULL); j++) {
             comm_t *c = comm_list + j;
-            VERBOSE (simul, TRACE, PRINTF ("test %c[%s]\n", c->mode ? 'T' : 'R', c->etype));
+            VERBOSE (simul, TRACE, PRINTF ("test %c[%s]\n", (c->mode == 0) ? 'R' : 'T', c->etype));
             if ((strncmp (line + offset, c->etype, strlen (c->etype)) == 0) && (c->mode == mode)) {
                 comm = c;
                 for (int i = 0; ((service_list + i)->service_id != noserv_e) && (serv == NULL); i++) {
                     service_t *s = service_list + i;
-                    c = mode ? &(s->rx) : &(s->tx);
+                    c = (mode == 0) ? &(s->rx) : &(s->tx);
                     if (strncmp (c->etype, comm->etype, strlen (comm->etype)) == 0) {
                         serv = s;
                     }
@@ -393,7 +393,7 @@ int main (int argc, char **argv)
             VERBOSE (simul, TRACE, PRINTF ("no morep found '%s'\n", line));
             continue;
         }
-        VERBOSE (simul, DEBUG, PRINTF ("select %c[%s]\n", comm->mode ? 'T' : 'R', serv->name));
+        VERBOSE (simul, DEBUG, PRINTF ("select %c[%s]\n", (comm->mode == 0) ? 'R' : 'T', serv->name));
 
         /* skip space */
         tmp = line + offset;
@@ -444,7 +444,7 @@ int main (int argc, char **argv)
             VERBOSE (simul, WARNING, PRINTF ("message %s is not allowed for service %s (line '%s')\n", msg->name, serv->name, line));
             continue;
         }
-        VERBOSE (simul, DEBUG, PRINTF ("%s message %s\n", comm->mode ? "sending" : "waiting", msg->name));
+        VERBOSE (simul, DEBUG, PRINTF ("%s message %s\n", (comm->mode == 0) ? "waiting" : "sending", msg->name));
 
         CHANNEL_t pdu_channel = {0};
         CLEAR_DATA_t pdu_clear_data = {0};
@@ -613,7 +613,7 @@ int main (int argc, char **argv)
 
         /* log message */
         if (log) {
-            fprintf (log, "%c:%s[%s] [SEG=%d MSG=%d LEN=%d PDU=%d] %s", mode ? 'T' : 'R',
+            fprintf (log, "%c:%s[%s] [SEG=%d MSG=%d LEN=%d PDU=%d] %s", (mode == 0) ? 'R' : 'T',
                      serv->name, comm->etype, seqnum, msg->msgtype, len, pdu, msg->name);
             char buffer[MOREP_PAYLOAD * 3 + 256] = {0};
             switch (pdu) {
index 28c5895260e684d3420227c28a6e010a526ed069..b8ede404f720ace5f8582384a89bd10afbbe2566 100755 (executable)
@@ -9,6 +9,7 @@ ETH_RADIOBLACK=enp0s4://52:54:00:12:34:57
 
 case "$1" in
 red)
+    #gdb $SIMULATOR --args \
     $SIMULATOR -l script-red.log \
         -s BYPASS -t $ETH_SECRED/080D -r $ETH_RADIORED/080D \
         -s CONTROL -t $ETH_SECRED/080E -r $ETH_RADIORED/080E \
@@ -17,6 +18,7 @@ red)
         script-red.eth -v 3 -V 3
     ;;
 secu)
+    #gdb $SIMULATOR --args \
     $SIMULATOR -l script-secu.log \
         -s BYPASS_BLACK -t $ETH_RADIOBLACK/081D -r $ETH_SECBLACK/081D \
         -s BYPASS_RED -t $ETH_RADIORED/080D -r $ETH_SECRED/080D \
@@ -27,6 +29,7 @@ secu)
         script-secu.eth -v 3 -V 3
     ;;
 black)
+    #gdb $SIMULATOR --args \
     $SIMULATOR -l script-black.log \
         -s BYPASS -t $ETH_SECBLACK/081D -r $ETH_RADIOBLACK/081D \
         -s CROSS_CRYPTO -t $ETH_SECBLACK/0819 -r $ETH_RADIOBLACK/0819 \