#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;
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++;
}
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");
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]));
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);
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);