In quiet-mode, no AC information is printed and the program
exits after the first PADO was received.
This is very useful if you use the tool in shell script
environments where you just want to evaluate the exit code.
Signed-off-by: Martin Schiller <ms@dev.tdt.de>
switch(type) {
case TAG_AC_NAME:
pc->seenACName = 1;
switch(type) {
case TAG_AC_NAME:
pc->seenACName = 1;
- printf("Access-Concentrator: %.*s\n", (int) len, data);
+ if (conn->printACNames) {
+ printf("Access-Concentrator: %.*s\n", (int) len, data);
+ }
if (conn->acName && len == strlen(conn->acName) &&
!strncmp((char *) data, conn->acName, len)) {
pc->acNameOK = 1;
if (conn->acName && len == strlen(conn->acName) &&
!strncmp((char *) data, conn->acName, len)) {
pc->acNameOK = 1;
break;
case TAG_SERVICE_NAME:
pc->seenServiceName = 1;
break;
case TAG_SERVICE_NAME:
pc->seenServiceName = 1;
+ if (conn->printACNames && len > 0) {
printf(" Service-Name: %.*s\n", (int) len, data);
}
if (conn->serviceName && len == strlen(conn->serviceName) &&
printf(" Service-Name: %.*s\n", (int) len, data);
}
if (conn->serviceName && len == strlen(conn->serviceName) &&
}
break;
case TAG_AC_COOKIE:
}
break;
case TAG_AC_COOKIE:
- printf("Got a cookie:");
- /* Print first 20 bytes of cookie */
- for (i=0; i<len && i < 20; i++) {
- printf(" %02x", (unsigned) data[i]);
+ if (conn->printACNames) {
+ printf("Got a cookie:");
+ /* Print first 20 bytes of cookie */
+ for (i=0; i<len && i < 20; i++) {
+ printf(" %02x", (unsigned) data[i]);
+ }
+ if (i < len) printf("...");
+ printf("\n");
- if (i < len) printf("...");
- printf("\n");
conn->cookie.type = htons(type);
conn->cookie.length = htons(len);
memcpy(conn->cookie.payload, data, len);
break;
case TAG_RELAY_SESSION_ID:
conn->cookie.type = htons(type);
conn->cookie.length = htons(len);
memcpy(conn->cookie.payload, data, len);
break;
case TAG_RELAY_SESSION_ID:
- printf("Got a Relay-ID:");
- /* Print first 20 bytes of relay ID */
- for (i=0; i<len && i < 20; i++) {
- printf(" %02x", (unsigned) data[i]);
+ if (conn->printACNames) {
+ printf("Got a Relay-ID:");
+ /* Print first 20 bytes of relay ID */
+ for (i=0; i<len && i < 20; i++) {
+ printf(" %02x", (unsigned) data[i]);
+ }
+ if (i < len) printf("...");
+ printf("\n");
- if (i < len) printf("...");
- printf("\n");
conn->relayId.type = htons(type);
conn->relayId.length = htons(len);
memcpy(conn->relayId.payload, data, len);
break;
case TAG_SERVICE_NAME_ERROR:
conn->relayId.type = htons(type);
conn->relayId.length = htons(len);
memcpy(conn->relayId.payload, data, len);
break;
case TAG_SERVICE_NAME_ERROR:
- printf("Got a Service-Name-Error tag: %.*s\n", (int) len, data);
+ if (conn->printACNames) {
+ printf("Got a Service-Name-Error tag: %.*s\n", (int) len, data);
+ }
break;
case TAG_AC_SYSTEM_ERROR:
break;
case TAG_AC_SYSTEM_ERROR:
- printf("Got a System-Error tag: %.*s\n", (int) len, data);
+ if (conn->printACNames) {
+ printf("Got a System-Error tag: %.*s\n", (int) len, data);
+ }
break;
case TAG_GENERIC_ERROR:
break;
case TAG_GENERIC_ERROR:
- printf("Got a Generic-Error tag: %.*s\n", (int) len, data);
+ if (conn->printACNames) {
+ printf("Got a Generic-Error tag: %.*s\n", (int) len, data);
+ }
continue;
}
conn->numPADOs++;
continue;
}
conn->numPADOs++;
- printf("--------------------------------------------------\n");
if (pc.acNameOK && pc.serviceNameOK) {
memcpy(conn->peerEth, packet.ethHdr.h_source, ETH_ALEN);
if (conn->printACNames) {
if (pc.acNameOK && pc.serviceNameOK) {
memcpy(conn->peerEth, packet.ethHdr.h_source, ETH_ALEN);
if (conn->printACNames) {
(unsigned) conn->peerEth[3],
(unsigned) conn->peerEth[4],
(unsigned) conn->peerEth[5]);
(unsigned) conn->peerEth[3],
(unsigned) conn->peerEth[4],
(unsigned) conn->peerEth[5]);
+ printf("--------------------------------------------------\n");
continue;
}
conn->discoveryState = STATE_RECEIVED_PADO;
continue;
}
conn->discoveryState = STATE_RECEIVED_PADO;
memset(conn, 0, sizeof(PPPoEConnection));
memset(conn, 0, sizeof(PPPoEConnection));
- while ((opt = getopt(argc, argv, "I:D:VUAS:C:h")) > 0) {
+ conn->printACNames = 1;
+
+ while ((opt = getopt(argc, argv, "I:D:VUQS:C:h")) > 0) {
switch(opt) {
case 'S':
conn->serviceName = xstrdup(optarg);
switch(opt) {
case 'S':
conn->serviceName = xstrdup(optarg);
case 'I':
conn->ifName = xstrdup(optarg);
break;
case 'I':
conn->ifName = xstrdup(optarg);
break;
- case 'A':
- /* this is the default */
+ case 'Q':
+ conn->printACNames = 0;
break;
case 'V':
case 'h':
break;
case 'V':
case 'h':
conn->discoverySocket = -1;
conn->sessionSocket = -1;
conn->discoverySocket = -1;
conn->sessionSocket = -1;
- conn->printACNames = 1;
fprintf(stderr, " -D filename -- Log debugging information in filename.\n");
fprintf(stderr,
" -V -- Print version and exit.\n"
fprintf(stderr, " -D filename -- Log debugging information in filename.\n");
fprintf(stderr,
" -V -- Print version and exit.\n"
+ " -Q -- Quit Mode: Do not print access concentrator names\n"
" -S name -- Set desired service name.\n"
" -C name -- Set desired access concentrator name.\n"
" -U -- Use Host-Unique to allow multiple PPPoE sessions.\n"
" -S name -- Set desired service name.\n"
" -C name -- Set desired access concentrator name.\n"
" -U -- Use Host-Unique to allow multiple PPPoE sessions.\n"