38 #define DEFAULT_VLAN 1
39 #define MAX_DIGITS_IN_CHOICE 5
105 int dnx_device =
FALSE;
117 printf(
"Failed to get port configuration. Error %s\n",
opennsl_errmsg(rv));
127 printf(
"Failed to set STP state for unit %d port %d, Error %s\n",
136 if(dnx_device ==
FALSE)
154 if(dnx_device ==
FALSE)
163 printf(
"Failed to set port config for unit %d, port %d, Error %s",
192 printf(
"Failed to get port configuration. Error %s\n",
opennsl_errmsg(rv));
198 printf(
"Failed to add ports to VLAN. Error %s\n",
opennsl_errmsg(rv));
207 printf(
"Failed to set port untagged VLAN for unit %d, port %d, Error %s",
229 if (fgets(buf, buflen, stdin) != 0)
231 size_t len = strlen(buf);
232 if (len > 0 && buf[len-1] ==
'\n')
238 while ((ch = getc(stdin)) != EOF && ch !=
'\n');
260 while((val = getchar()) !=
'\n')
271 if ((valid ==
TRUE) && idx != 0)
274 *choice = atoi(digits);
297 #define MAC_ADDR_LEN 17
299 macp[0] = macp[1] = macp[2] = 0;
300 macp[3] = macp[4] = macp[5] = 0;
307 if (buf[0] ==
'0' && (buf[1] ==
'x' || buf[1] ==
'X')) {
312 for (s = buf; *s; s++) {
315 for (i = 5; i >= 0 && s >= buf; i--) {
318 if (*s >=
'0' && *s <=
'9') {
320 }
else if (*s >=
'a' && *s <=
'f') {
322 }
else if (*s >=
'A' && *s <=
'F') {
324 }
else if (*s ==
':') {
330 if (*s !=
':' && --s >= buf) {
331 if (*s >=
'0' && *s <=
'9') {
333 }
else if (*s >=
'a' && *s <=
'f') {
335 }
else if (*s >=
'A' && *s <=
'F') {
337 }
else if (*s ==
':') {
344 if (s > buf && s[-1] ==
':') {
347 macp[i] = c1 << 4 | c2;
359 unsigned int a,b,c,d,e,f;
360 a = 0xff & mac_address[0];
361 b = 0xff & mac_address[1];
362 c = 0xff & mac_address[2];
363 d = 0xff & mac_address[3];
364 e = 0xff & mac_address[4];
365 f = 0xff & mac_address[5];
366 printf(
"%s %02x:%02x:%02x:%02x:%02x:%02x",
384 unsigned int num = 0, val;
389 if((ip_str ==
NULL) || (ip_val ==
NULL) || (strlen(ip_str) > 16))
394 tok = strtok(buf,
".");
399 if((val < 0) || (val > 0xff))
403 num = (num << 8) + val;
404 tok = strtok(
NULL,
".");
429 a = (host >> 24) & 0xff;
430 b = (host >> 16) & 0xff;
431 c = (host >> 8 ) & 0xff;
433 printf(
"%s %d.%d.%d.%d", str, a,b,c,d);
458 s += (neg = (*s ==
'-'));
462 if (*s ==
'x' || *s ==
'X') {
465 }
else if (*s ==
'b' || *s ==
'B') {
473 for (n = 0; ((*s >=
'a' && *s <
'a' + base - 10) ||
474 (*s >=
'A' && *s <
'A' + base - 10) ||
475 (*s >=
'0' && *s <=
'9')); s++) {
476 n = n * base + ((*s <=
'9' ? *s : *s + 9) & 15);
483 return (
int) (neg ? -n : n);
500 int num_front_panel_ports;
504 printf(
"Failed to get port configuration. Error %s\n",
opennsl_errmsg(rc));
509 num_front_panel_ports = num_ports;
511 num_front_panel_ports += num_ports;
513 *count = num_front_panel_ports;