]> jspc29.x-matter.uni-frankfurt.de Git - trbnettools.git/commitdiff
update
authorhadaq <hadaq>
Mon, 14 Sep 2009 20:21:06 +0000 (20:21 +0000)
committerhadaq <hadaq>
Mon, 14 Sep 2009 20:21:06 +0000 (20:21 +0000)
libtrbnet/trbdhcp.c

index 4bffaf631f231b9b4021774142f2e4ea823d005d..8f626d217c1dbdd0f5a998ccac768af0c7b1adf7 100644 (file)
@@ -10,7 +10,7 @@
 #include <trbnet.h>
 #include <trberror.h>
 
-static const char trbdhcp_version[] = "$Revision: 1.1 $";
+static const char trbdhcp_version[] = "$Revision: 1.2 $";
 
 typedef struct {
   uint16_t address;
@@ -69,13 +69,17 @@ static int readConfigFile(const char* fileName)
     if ((c = strchr(line, '#')) != NULL) {
       *c = '\0';
     }
-   
+    
     if (sscanf(line, "%x %llx %x", &address, &uid, &endPoint) != 3) {
       continue;
     }
-    endPointList[counter].address = address;
-    endPointList[counter].uid = uid;
-    endPointList[counter].endPoint = endPoint;
+    if (counter < NUM_ENDPOINTS) {
+      endPointList[counter].address = address;
+      endPointList[counter].uid = uid;
+      endPointList[counter].endPoint = endPoint;
+    } else {
+      abort();
+    }
     
     counter++;
   }
@@ -102,11 +106,11 @@ static void dumpList()
 
 void usage(const char *progName)
 {
-  printf("Usage: %s [-h] [-f configFile] [-V]\n", progName);
+  printf("Usage: %s [-h] [-f configFile] [-a trb-address] [-V]\n", progName);
   printf("Options:\n");
   printf("  -h    give this help\n");
   printf("  -f    name of configFile (default: trbdhcp.conf)\n");
-  printf("  -a    trb-address (default: 0xffff)\n");
+  printf("  -a    use trb-address as broadcast (default: 0xffff)\n");
   printf("  -V    Version number\n");
   printf("\nConfigFile Format:\n");
   printf("# New-Address    UID    EndPoint\n\n");
@@ -118,13 +122,12 @@ int main(int argc, char ** argv)
   uint16_t trbAddress = 0xffff;
   int status;
   unsigned int i;
-  int resetAll = 0;
   int opt;
   
   trb_debug = 0;
 
   /* Parse Arguments */
-  while ((opt = getopt(argc, argv, "+hd:f:a:rV")) != -1) {
+  while ((opt = getopt(argc, argv, "+hd:f:a:V")) != -1) {
     switch (opt) {
     case '?':
       usage(basename(argv[0]));
@@ -141,9 +144,6 @@ int main(int argc, char ** argv)
     case 'a':
       trbAddress = strtoul(optarg, NULL, 0);
       break;
-    case 'r':
-      resetAll = 1;
-      break;
     case 'V':
       printf("%s %s, using libtrbnet %s\n",
              basename(argv[0]), trbdhcp_version, trbnet_version);
@@ -197,10 +197,7 @@ int main(int argc, char ** argv)
       if ((uid == endPointList[j].uid) && 
           (endPoint == endPointList[j].endPoint)) {
         
-        if ((currentAddress != endPointList[j].address) && 
-            (((currentAddress & 0xf000) == 0xf000) || (resetAll == 1))
-            ) {
-          
+        if (currentAddress != endPointList[j].address) {
           if (trb_debug > 0) {
             fprintf(stderr, "set address: 0x%04x  0x%08llx 0x%02x\n",
                     currentAddress, uid, endPoint);