From 2f7f2fe39a1c1a5ad9307254d0610c962c39ded4 Mon Sep 17 00:00:00 2001 From: hadaq Date: Mon, 14 Sep 2009 20:21:06 +0000 Subject: [PATCH] update --- libtrbnet/trbdhcp.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/libtrbnet/trbdhcp.c b/libtrbnet/trbdhcp.c index 4bffaf6..8f626d2 100644 --- a/libtrbnet/trbdhcp.c +++ b/libtrbnet/trbdhcp.c @@ -10,7 +10,7 @@ #include #include -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); -- 2.43.0