Commit 25a0699a authored by Adam Wujek's avatar Adam Wujek 💬

userspace/tools: use wrs-msg for printing errors/debug information

remove --debug flag
support -v/-q flags for more/less verbose output
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent bfd4641f
...@@ -37,16 +37,14 @@ ...@@ -37,16 +37,14 @@
#include <libwr/shmem.h> #include <libwr/shmem.h>
#include <libwr/rtu_shmem.h> #include <libwr/rtu_shmem.h>
#include <libwr/config.h> #include <libwr/config.h>
#include <libwr/wrs-msg.h>
static int debug = 0;
static struct minipc_ch *rtud_ch; static struct minipc_ch *rtud_ch;
static struct rtu_vlans_t *rtu_vlans = NULL; static struct rtu_vlans_t *rtu_vlans = NULL;
static char *prgname;
/* runtime options */ /* runtime options */
static struct option ropts[] = { static struct option ropts[] = {
{"help", 0, NULL, OPT_HELP}, {"help", 0, NULL, OPT_HELP},
{"debug", optional_argument, NULL, OPT_DEBUG},
{"clear", 0, NULL, OPT_CLEAR}, {"clear", 0, NULL, OPT_CLEAR},
{"list", 0, NULL, OPT_LIST}, {"list", 0, NULL, OPT_LIST},
{"port", 1, NULL, OPT_P_PORT}, {"port", 1, NULL, OPT_P_PORT},
...@@ -139,10 +137,10 @@ static int parse_mask(char *arg, unsigned long *pmask) ...@@ -139,10 +137,10 @@ static int parse_mask(char *arg, unsigned long *pmask)
portmask |= (1 << p1); portmask |= (1 << p1);
} }
} }
if (!debug) if (wrs_msg_level < LOG_DEBUG)
return 0; return 0;
printf("%s: working on ports:\n", prgname); printf("working on ports:\n");
iterate_ports(p1, *pmask) iterate_ports(p1, *pmask)
printf(" %i", p1 + 1); printf(" %i", p1 + 1);
printf("\n"); printf("\n");
...@@ -156,7 +154,10 @@ int main(int argc, char *argv[]) ...@@ -156,7 +154,10 @@ int main(int argc, char *argv[])
struct rtu_shmem_header *rtu_hdr; struct rtu_shmem_header *rtu_hdr;
int n_wait = 0; int n_wait = 0;
int ret; int ret;
char *prgname;
wrs_msg_level = LOG_WARNING;
wrs_msg_init(argc, argv);
prgname = argv[0]; prgname = argv[0];
if (NPORTS > 8 * sizeof(portmask)) { if (NPORTS > 8 * sizeof(portmask)) {
...@@ -175,8 +176,7 @@ int main(int argc, char *argv[]) ...@@ -175,8 +176,7 @@ int main(int argc, char *argv[])
while((rtud_ch = minipc_client_create("rtud", 0)) == 0) { while((rtud_ch = minipc_client_create("rtud", 0)) == 0) {
n_wait++; n_wait++;
if (n_wait > 10) { if (n_wait > 10) {
fprintf(stderr, "%s: Can't connect to RTUd mini-rpc " pr_error("Can't connect to RTUd mini-rpc server\n");
"server\n", prgname);
exit(1); exit(1);
} }
sleep(1); sleep(1);
...@@ -188,12 +188,10 @@ int main(int argc, char *argv[]) ...@@ -188,12 +188,10 @@ int main(int argc, char *argv[])
n_wait++; n_wait++;
if (n_wait > 10) { if (n_wait > 10) {
if (ret == 1) { if (ret == 1) {
fprintf(stderr, "%s: Unable to open RTUd's " pr_error("Unable to open RTUd's shmem!\n");
"shmem!\n", prgname);
} }
if (ret == 2) { if (ret == 2) {
fprintf(stderr, "%s: Unable to read RTUd's " pr_error("Unable to read RTUd's version!\n");
"version!\n", prgname);
} }
exit(1); exit(1);
} }
...@@ -202,8 +200,8 @@ int main(int argc, char *argv[]) ...@@ -202,8 +200,8 @@ int main(int argc, char *argv[])
/* check rtu shm version */ /* check rtu shm version */
if (rtu_port_shmem->version != RTU_SHMEM_VERSION) { if (rtu_port_shmem->version != RTU_SHMEM_VERSION) {
fprintf(stderr, "%s: unknown version %i (known is %i)\n", pr_error("unknown version %i (known is %i)\n",
prgname, rtu_port_shmem->version, RTU_SHMEM_VERSION); rtu_port_shmem->version, RTU_SHMEM_VERSION);
exit(1); exit(1);
} }
...@@ -214,25 +212,23 @@ int main(int argc, char *argv[]) ...@@ -214,25 +212,23 @@ int main(int argc, char *argv[])
vlan_tab_shm = wrs_shm_follow(rtu_port_shmem, rtu_hdr->vlans); vlan_tab_shm = wrs_shm_follow(rtu_port_shmem, rtu_hdr->vlans);
if (!vlan_tab_shm) { if (!vlan_tab_shm) {
fprintf(stderr, "%s: cannot follow pointer to vlans in " pr_error("cannot follow pointer to vlans in RTU's shmem\n");
"RTU's shmem\n", prgname);
exit(1); exit(1);
} }
if (shw_fpga_mmap_init() < 0) { if (shw_fpga_mmap_init() < 0) {
fprintf(stderr, "%s: Can't access device memory\n", prgname); pr_error("Can't access device memory\n");
exit(1); exit(1);
} }
/*parse parameters*/ /*parse parameters*/
while ((c = getopt_long(argc, argv, "hf:", ropts, NULL)) != -1) { while ((c = getopt_long(argc, argv, "hf:vq", ropts, NULL)) != -1) {
switch(c) { switch(c) {
case OPT_P_PORT: case OPT_P_PORT:
/* port number */ /* port number */
conf_pmask = 0; conf_pmask = 0;
if (parse_mask(optarg, &conf_pmask) < 0) { if (parse_mask(optarg, &conf_pmask) < 0) {
fprintf(stderr, "%s: wrong port mask " pr_error("wrong port mask \"%s\"\n", optarg);
"\"%s\"\n", prgname, optarg);
exit(1); exit(1);
} }
break; break;
...@@ -241,9 +237,8 @@ int main(int argc, char *argv[]) ...@@ -241,9 +237,8 @@ int main(int argc, char *argv[])
/* qmode for port */ /* qmode for port */
arg = atoi(optarg); arg = atoi(optarg);
if (arg < 0 || arg > 3) { if (arg < 0 || arg > 3) {
fprintf(stderr, "%s: invalid qmode %i (\"%s\"" pr_error("invalid qmode %i (\"%s\")\n",
")\n", arg, optarg);
prgname, arg, optarg);
exit(1); exit(1);
} }
iterate_ports(i, conf_pmask) { iterate_ports(i, conf_pmask) {
...@@ -270,9 +265,8 @@ int main(int argc, char *argv[]) ...@@ -270,9 +265,8 @@ int main(int argc, char *argv[])
* set in QMODE above */ * set in QMODE above */
arg = atoi(optarg); arg = atoi(optarg);
if (arg < 0 || arg > 1) { if (arg < 0 || arg > 1) {
fprintf(stderr, "%s: invalid unmask bit %i " pr_error("invalid unmask bit %i (\"%s\")\n",
"(\"%s\")\n", arg, optarg);
prgname, arg, optarg);
exit(1); exit(1);
} }
iterate_ports(i, conf_pmask) { iterate_ports(i, conf_pmask) {
...@@ -328,31 +322,26 @@ int main(int argc, char *argv[]) ...@@ -328,31 +322,26 @@ int main(int argc, char *argv[])
if (clear_all()) if (clear_all())
exit(1); /* message already printed */ exit(1); /* message already printed */
break; break;
case OPT_DEBUG:
if (optarg)
debug = atoi(optarg);
else
debug = 1;
printf("Set debug to %d\n", debug);
break;
case 0: case 0:
break; break;
case OPT_LIST: case OPT_LIST:
if (debug) if (wrs_msg_level >= LOG_DEBUG)
minipc_set_logfile(rtud_ch, stderr); minipc_set_logfile(rtud_ch, stderr);
list_rtu_vlans(); list_rtu_vlans();
break; break;
case OPT_FILE_READ: case OPT_FILE_READ:
if (debug) if (wrs_msg_level >= LOG_DEBUG)
printf("Using file %s as dot-config\n", pr_info("Using file %s as dot-config\n",
optarg); optarg);
/* read dot-config */ /* read dot-config */
ret = read_dot_config(optarg); ret = read_dot_config(optarg);
if (ret < 0) if (ret < 0)
exit(-ret); exit(-ret);
break; break;
case 'q': break; /* done in wrs_msg_init() */
case 'v': break; /* done in wrs_msg_init() */
case '?': case '?':
case OPT_HELP: case OPT_HELP:
default: default:
...@@ -361,10 +350,10 @@ int main(int argc, char *argv[]) ...@@ -361,10 +350,10 @@ int main(int argc, char *argv[])
} }
} }
if (debug > 1) if (wrs_msg_level >= LOG_DEBUG)
minipc_set_logfile(rtud_ch, stderr); minipc_set_logfile(rtud_ch, stderr);
if (debug) { if (wrs_msg_level >= LOG_INFO) {
print_config_rtu(vlans); print_config_rtu(vlans);
print_config_vlan(); print_config_vlan();
} }
...@@ -390,8 +379,8 @@ static void set_p_vid(int ep, char *arg_vid) ...@@ -390,8 +379,8 @@ static void set_p_vid(int ep, char *arg_vid)
vid = atoi(arg_vid); vid = atoi(arg_vid);
if (vid < PORT_VID_MIN || vid > PORT_VID_MAX) { if (vid < PORT_VID_MIN || vid > PORT_VID_MAX) {
fprintf(stderr, "%s: invalid vid %i (\"%s\") for port %d\n", pr_error("invalid vid %i (\"%s\") for port %d\n",
prgname, vid, arg_vid, ep + 1); vid, arg_vid, ep + 1);
exit(1); exit(1);
} }
vlans[ep].vid = atoi(arg_vid); vlans[ep].vid = atoi(arg_vid);
...@@ -404,8 +393,8 @@ static void set_p_prio(int ep, char *arg_prio) ...@@ -404,8 +393,8 @@ static void set_p_prio(int ep, char *arg_prio)
prio = atoi(arg_prio); prio = atoi(arg_prio);
if (prio < PORT_PRIO_MIN || prio > PORT_PRIO_MAX) { if (prio < PORT_PRIO_MIN || prio > PORT_PRIO_MAX) {
fprintf(stderr, "%s: invalid priority %i (\"%s\") for port %d" pr_error("invalid priority %i (\"%s\") for port %d\n",
"\n", prgname, prio, arg_prio, ep + 1); prio, arg_prio, ep + 1);
exit(1); exit(1);
} }
vlans[ep].prio_val = prio; vlans[ep].prio_val = prio;
...@@ -425,8 +414,7 @@ static int check_rtu(char *name, char *arg_val, int min, int max) ...@@ -425,8 +414,7 @@ static int check_rtu(char *name, char *arg_val, int min, int max)
val = atoi(arg_val); val = atoi(arg_val);
if (val < min || val > max) { if (val < min || val > max) {
fprintf(stderr, "%s: invalid %s %i (\"%s\")" pr_error("invalid %s %i (\"%s\")\n", name, val, arg_val);
"\n", prgname, name, val, arg_val);
return -1; return -1;
} }
return val; return val;
...@@ -434,7 +422,7 @@ static int check_rtu(char *name, char *arg_val, int min, int max) ...@@ -434,7 +422,7 @@ static int check_rtu(char *name, char *arg_val, int min, int max)
static int print_help(char *prgname) static int print_help(char *prgname)
{ {
fprintf(stderr, "Use: %s [--debug|--debug=<level>] " fprintf(stderr, "Use: %s [-v] [-q]"
"[--port <port number 1..18> <port options> " "[--port <port number 1..18> <port options> "
"--port <port number> <port options> ...] " "--port <port number> <port options> ...] "
"[--rvid <vid> --rfid <fid> --rmask <mask> --rdrop " "[--rvid <vid> --rfid <fid> --rmask <mask> --rdrop "
...@@ -460,15 +448,12 @@ static int print_help(char *prgname) ...@@ -460,15 +448,12 @@ static int print_help(char *prgname)
"\t --rdrop <1/0> drop/don't drop frames on VLAN\n" "\t --rdrop <1/0> drop/don't drop frames on VLAN\n"
"\t --rprio <prio> force priority for VLAN (-1 cancels priority override)\n" "\t --rprio <prio> force priority for VLAN (-1 cancels priority override)\n"
"Other options:\n" "Other options:\n"
"\t --clear clears RTUd VLAN table\n" "\t --clear clears RTUd VLAN table\n"
"\t --list prints the content of RTUd VLAN table\n" "\t --list prints the content of RTUd VLAN table\n"
"\t -f|--file <file> reads configuration from the provided dot-config file\n" "\t -f|--file <file> reads configuration from the provided dot-config file\n"
"\t --debug|--debug=<level> set the debug level:\n" "\t -v be more verbose (can be used 1 or 2 times)\n"
"\t \t 0 - no debug output (default)\n" "\t -q be less verbose\n"
"\t \t 1 - prints config before applaying it (--debug)\n" "\t --help prints this help message\n");
"\t \t 2 - prints extra information about parameters read from the dot-config\n"
"\t \t note: --debug=2 should be placed before -f|--file parameter\n"
"\t --help prints this help message\n");
return 0; return 0;
} }
...@@ -626,9 +611,8 @@ static void list_rtu_vlans(void) ...@@ -626,9 +611,8 @@ static void list_rtu_vlans(void)
NUM_VLANS * sizeof(*vlan_tab_shm)); NUM_VLANS * sizeof(*vlan_tab_shm));
retries++; retries++;
if (retries > 100) { if (retries > 100) {
fprintf(stderr, "%s: couldn't read consistent data " pr_error("couldn't read consistent data from RTU's "
"from RTU's shmem. Use inconsistent\n", "shmem. Use inconsistent\n");
prgname);
break; /* use inconsistent data */ break; /* use inconsistent data */
} }
if (!wrs_shm_seqretry(rtu_port_shmem, ii)) if (!wrs_shm_seqretry(rtu_port_shmem, ii))
...@@ -728,15 +712,14 @@ static int set_rtu_vlan(int vid, int fid, int pmask, int drop, int prio, ...@@ -728,15 +712,14 @@ static int set_rtu_vlan(int vid, int fid, int pmask, int drop, int prio,
struct rtu_vlans_t *cur = rtu_vlans;; struct rtu_vlans_t *cur = rtu_vlans;;
if (!rtu_vlans && vid < 0) { if (!rtu_vlans && vid < 0) {
fprintf(stderr, "%s: missing \"--rvid <vid>\" before rtu cmd\n", pr_error("missing \"--rvid <vid>\" before rtu cmd\n");
prgname);
return -1; return -1;
} }
if (vid >= 0) { if (vid >= 0) {
cur = calloc(1, sizeof(*cur)); cur = calloc(1, sizeof(*cur));
if (!cur) { if (!cur) {
fprintf(stderr, "%s: %s\n", prgname, strerror(errno)); pr_error("%s\n", strerror(errno));
return -1; return -1;
} }
cur->vid = vid; cur->vid = vid;
...@@ -803,9 +786,8 @@ static int rtu_find_vlan(struct rtu_vlan_table_entry *rtu_vlan_entry, int vid, ...@@ -803,9 +786,8 @@ static int rtu_find_vlan(struct rtu_vlan_table_entry *rtu_vlan_entry, int vid,
sizeof(*rtu_vlan_entry)); sizeof(*rtu_vlan_entry));
retries++; retries++;
if (retries > 100) { if (retries > 100) {
fprintf(stderr, "%s: couldn't read consistent " pr_error("couldn't read consistent data from RTU's "
"data from RTU's shmem. " "shmem. Use inconsistent\n");
"Use inconsistent\n", prgname);
break; /* use inconsistent data */ break; /* use inconsistent data */
} }
if (!wrs_shm_seqretry(rtu_port_shmem, ii)) if (!wrs_shm_seqretry(rtu_port_shmem, ii))
...@@ -833,20 +815,19 @@ static int read_dot_config(char *dot_config_file) ...@@ -833,20 +815,19 @@ static int read_dot_config(char *dot_config_file)
int i; int i;
if (access(dot_config_file, R_OK)) { if (access(dot_config_file, R_OK)) {
fprintf(stderr, "Unable to read dot-config file %s\n", pr_error("Unable to read dot-config file %s\n",
dot_config_file); dot_config_file);
return -1; return -1;
} }
line = libwr_cfg_read_file(dot_config_file); line = libwr_cfg_read_file(dot_config_file);
if (line == -1) { if (line == -1) {
fprintf(stderr, "Unable to read dot-config file %s or error in" pr_error("Unable to read dot-config file %s or error in "
" line 1\n", dot_config_file); "line 1\n", dot_config_file);
return -1; return -1;
} else if (line) { } else if (line) {
fprintf(stderr, "Error in dot-config file %s, error in line " pr_error("Error in dot-config file %s, error in line %d\n",
"%d\n",
dot_config_file, -line); dot_config_file, -line);
return -1; return -1;
} }
...@@ -864,56 +845,56 @@ static int read_dot_config(char *dot_config_file) ...@@ -864,56 +845,56 @@ static int read_dot_config(char *dot_config_file)
sprintf(buff, "VLANS_PORT%02d_MODE_ACCESS", port); sprintf(buff, "VLANS_PORT%02d_MODE_ACCESS", port);
ret = libwr_cfg_get(buff); ret = libwr_cfg_get(buff);
if (ret && !strcmp(ret, "y")) { if (ret && !strcmp(ret, "y")) {
if (debug > 1) if (wrs_msg_level >= LOG_DEBUG)
printf("Found %s\n", buff); printf("Found %s\n", buff);
set_p_qmode(port - 1, 0); set_p_qmode(port - 1, 0);
} }
sprintf(buff, "VLANS_PORT%02d_MODE_TRUNK", port); sprintf(buff, "VLANS_PORT%02d_MODE_TRUNK", port);
ret = libwr_cfg_get(buff); ret = libwr_cfg_get(buff);
if (ret && !strcmp(ret, "y")) { if (ret && !strcmp(ret, "y")) {
if (debug > 1) if (wrs_msg_level >= LOG_DEBUG)
printf("Found %s\n", buff); printf("Found %s\n", buff);
set_p_qmode(port - 1, 1); set_p_qmode(port - 1, 1);
} }
sprintf(buff, "VLANS_PORT%02d_MODE_DISABLED", port); sprintf(buff, "VLANS_PORT%02d_MODE_DISABLED", port);
ret = libwr_cfg_get(buff); ret = libwr_cfg_get(buff);
if (ret && !strcmp(ret, "y")) { if (ret && !strcmp(ret, "y")) {
if (debug > 1) if (wrs_msg_level >= LOG_DEBUG)
printf("Found %s\n", buff); printf("Found %s\n", buff);
set_p_qmode(port - 1, 2); set_p_qmode(port - 1, 2);
} }
sprintf(buff, "VLANS_PORT%02d_MODE_UNQUALIFIED", port); sprintf(buff, "VLANS_PORT%02d_MODE_UNQUALIFIED", port);
ret = libwr_cfg_get(buff); ret = libwr_cfg_get(buff);
if (ret && !strcmp(ret, "y")) { if (ret && !strcmp(ret, "y")) {
if (debug > 1) if (wrs_msg_level >= LOG_DEBUG)
printf("Found %s\n", buff); printf("Found %s\n", buff);
set_p_qmode(port - 1, 3); set_p_qmode(port - 1, 3);
} }
sprintf(buff, "VLANS_PORT%02d_UMASK_ALL", port); sprintf(buff, "VLANS_PORT%02d_UMASK_ALL", port);
ret = libwr_cfg_get(buff); ret = libwr_cfg_get(buff);
if (ret && !strcmp(ret, "y")) { if (ret && !strcmp(ret, "y")) {
if (debug > 1) if (wrs_msg_level >= LOG_DEBUG)
printf("Found %s\n", buff); printf("Found %s\n", buff);
set_p_umask(port - 1, 1); set_p_umask(port - 1, 1);
} }
sprintf(buff, "VLANS_PORT%02d_UMASK_NONE", port); sprintf(buff, "VLANS_PORT%02d_UMASK_NONE", port);
ret = libwr_cfg_get(buff); ret = libwr_cfg_get(buff);
if (ret && !strcmp(ret, "y")) { if (ret && !strcmp(ret, "y")) {
if (debug > 1) if (wrs_msg_level >= LOG_DEBUG)
printf("Found %s\n", buff); printf("Found %s\n", buff);
set_p_umask(port - 1, 0); set_p_umask(port - 1, 0);
} }
sprintf(buff, "VLANS_PORT%02d_PRIO", port); sprintf(buff, "VLANS_PORT%02d_PRIO", port);
val_ch = libwr_cfg_get(buff); val_ch = libwr_cfg_get(buff);
if (val_ch) { if (val_ch) {
if (debug > 1) if (wrs_msg_level >= LOG_DEBUG)
printf("Found %s=%s\n", buff, val_ch); printf("Found %s=%s\n", buff, val_ch);
set_p_prio(port - 1, val_ch); set_p_prio(port - 1, val_ch);
} }
sprintf(buff, "VLANS_PORT%02d_VID", port); sprintf(buff, "VLANS_PORT%02d_VID", port);
val_ch = libwr_cfg_get(buff); val_ch = libwr_cfg_get(buff);
if (val_ch) { if (val_ch) {
if (debug > 1) if (wrs_msg_level >= LOG_DEBUG)
printf("Found %s=%s\n", buff, val_ch); printf("Found %s=%s\n", buff, val_ch);
set_p_vid(port - 1, val_ch); set_p_vid(port - 1, val_ch);
} }
...@@ -951,7 +932,7 @@ static void read_dot_config_vlans(int vlan_min, int vlan_max) ...@@ -951,7 +932,7 @@ static void read_dot_config_vlans(int vlan_min, int vlan_max)
RTU_FID_MAX); RTU_FID_MAX);
if (fid < 0) if (fid < 0)
exit(1); exit(1);
if (debug > 1) if (wrs_msg_level >= LOG_DEBUG)
printf("Vlan %4d: Found fid=%d\n", printf("Vlan %4d: Found fid=%d\n",
vlan, fid); vlan, fid);
vlan_flags |= VALID_FID; vlan_flags |= VALID_FID;
...@@ -964,7 +945,7 @@ static void read_dot_config_vlans(int vlan_min, int vlan_max) ...@@ -964,7 +945,7 @@ static void read_dot_config_vlans(int vlan_min, int vlan_max)
if (prio < 0) if (prio < 0)
exit(1); exit(1);
vlan_flags |= VALID_PRIO; vlan_flags |= VALID_PRIO;
if (debug > 1) if (wrs_msg_level >= LOG_DEBUG)
printf("Vlan %4d: Found prio=%d\n", printf("Vlan %4d: Found prio=%d\n",
vlan, prio); vlan, prio);
} }
...@@ -975,15 +956,14 @@ static void read_dot_config_vlans(int vlan_min, int vlan_max) ...@@ -975,15 +956,14 @@ static void read_dot_config_vlans(int vlan_min, int vlan_max)
else if (!strcmp(buff, "n")) else if (!strcmp(buff, "n"))
sprintf(buff, "0"); sprintf(buff, "0");
else { else {
fprintf(stderr, "%s: invalid drop parameter" pr_error("invalid drop parameter \"%s\" in "
"\"%s\" in VLANS_VLAN%04d\n", prgname, "VLANS_VLAN%04d\n", buff, vlan);
buff, vlan);
exit(1); exit(1);
} }
drop = check_rtu("rtu drop", buff, 0, 1); drop = check_rtu("rtu drop", buff, 0, 1);
if (drop < 0) if (drop < 0)
exit(1); exit(1);
if (debug > 1) if (wrs_msg_level >= LOG_DEBUG)
printf("Vlan %4d: Found drop=%d\n", printf("Vlan %4d: Found drop=%d\n",
vlan, drop); vlan, drop);
vlan_flags |= VALID_DROP; vlan_flags |= VALID_DROP;
...@@ -994,19 +974,18 @@ static void read_dot_config_vlans(int vlan_min, int vlan_max) ...@@ -994,19 +974,18 @@ static void read_dot_config_vlans(int vlan_min, int vlan_max)
while (1) { while (1) {
port = strtol(beg, &end, 0); port = strtol(beg, &end, 0);
if (end == beg) { if (end == beg) {
fprintf(stderr, "%s: invalid ports " pr_error("invalid ports parameter "
"parameter\"%s\" in " "\"%s\" in VLANS_VLAN%04d\n",
"VLANS_VLAN%04d\n", prgname, buff, vlan);
buff, vlan);
exit(1); exit(1);
} }
if (port < 1 || port > NPORTS) { if (port < 1 || port > NPORTS) {
fprintf(stderr, "%s: invalid port %d " pr_error("invalid port %d (\"%s\") for"
"(\"%s\") for vlan %4d\n", " vlan %4d\n",
prgname, port, buff, vlan); port, buff, vlan);
exit(1); exit(1);
} }
if (debug > 1) if (wrs_msg_level >= LOG_DEBUG)
printf("Vlan %4d: Found port %d\n", printf("Vlan %4d: Found port %d\n",
vlan, port); vlan, port);
pmask |= 1 << (port - 1); pmask |= 1 << (port - 1);
...@@ -1023,12 +1002,11 @@ static void read_dot_config_vlans(int vlan_min, int vlan_max) ...@@ -1023,12 +1002,11 @@ static void read_dot_config_vlans(int vlan_min, int vlan_max)
} }
if (pmask < RTU_PMASK_MIN || pmask > RTU_PMASK_MAX) { if (pmask < RTU_PMASK_MIN || pmask > RTU_PMASK_MAX) {
fprintf(stderr, "%s: invalid port mask 0x%x " pr_error("invalid port mask 0x%x (\"%s\") for "
"(\"%s\") for vlan %4d\n", prgname, "vlan %4d\n", pmask, buff, vlan);
pmask, buff, vlan);
exit(1); exit(1);
} }
if (debug > 1) if (wrs_msg_level >= LOG_DEBUG)
printf("Vlan %4d: Port mask 0x%05x\n", printf("Vlan %4d: Port mask 0x%05x\n",
vlan, pmask); vlan, pmask);
vlan_flags |= VALID_PMASK; vlan_flags |= VALID_PMASK;
......
...@@ -43,7 +43,6 @@ ...@@ -43,7 +43,6 @@
#define NOPTS 15 #define NOPTS 15
#define OPT_HELP 'h' #define OPT_HELP 'h'
#define OPT_DEBUG 'd'
#define OPT_CLEAR 3 #define OPT_CLEAR 3
#define OPT_LIST 4 #define OPT_LIST 4
#define OPT_P_PORT 10 #define OPT_P_PORT 10
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment