summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@ozlabs.org>2022-01-10 15:06:21 +1100
committerGitHub <noreply@github.com>2022-01-10 15:06:21 +1100
commitc5ff7d10cfd97fae1783fce445c575373b65856c (patch)
tree81bcca9a4c996b48f581f5fe23c58bbe246d75f8
parent20fa5e803ff90eb9c90055afd679d1f2c00932bf (diff)
parent3492e78b33c8ef96ec4b4e6e2766cd700fd205e7 (diff)
downloadppp-c5ff7d10cfd97fae1783fce445c575373b65856c.tar.gz
Merge pull request #330 from pali/pppoe-discovery
pppoe-discovery: Do not set eth0 as default interface and valide all cmdline options
-rw-r--r--pppd/plugins/pppoe/pppoe-discovery.82
-rw-r--r--pppd/plugins/pppoe/pppoe-discovery.c41
2 files changed, 12 insertions, 31 deletions
diff --git a/pppd/plugins/pppoe/pppoe-discovery.8 b/pppd/plugins/pppoe/pppoe-discovery.8
index d0a93db..e048f66 100644
--- a/pppd/plugins/pppoe/pppoe-discovery.8
+++ b/pppd/plugins/pppoe/pppoe-discovery.8
@@ -26,7 +26,7 @@ Under Linux, it is typically eth0 or eth1.
The interface should be \(lqup\(rq before you start
\fBpppoe\-discovery\fR, but should \fInot\fR be configured to have an
IP address.
-The default interface is eth0.
+This option is mandatory.
.RE
.TP
.BI \-D " file_name"
diff --git a/pppd/plugins/pppoe/pppoe-discovery.c b/pppd/plugins/pppoe/pppoe-discovery.c
index 1fe999d..10f51dc 100644
--- a/pppd/plugins/pppoe/pppoe-discovery.c
+++ b/pppd/plugins/pppoe/pppoe-discovery.c
@@ -24,32 +24,6 @@
#include "pppoe.h"
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef HAVE_NETPACKET_PACKET_H
-#include <netpacket/packet.h>
-#elif defined(HAVE_LINUX_IF_PACKET_H)
-#include <linux/if_packet.h>
-#endif
-
-#ifdef HAVE_ASM_TYPES_H
-#include <asm/types.h>
-#endif
-
-#ifdef HAVE_SYS_IOCTL_H
-#include <sys/ioctl.h>
-#endif
-
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef HAVE_NET_IF_ARP_H
-#include <net/if_arp.h>
-#endif
-
int debug;
int got_sigterm;
int pppoe_verbose;
@@ -251,9 +225,16 @@ int main(int argc, char *argv[])
}
}
- /* default interface name */
- if (!conn->ifName)
- conn->ifName = xstrdup("eth0");
+ if (optind != argc) {
+ fprintf(stderr, "%s: extra argument '%s'\n", argv[0], argv[optind]);
+ usage();
+ exit(EXIT_FAILURE);
+ }
+
+ if (!conn->ifName) {
+ fprintf(stderr, "Interface was not specified\n");
+ exit(EXIT_FAILURE);
+ }
conn->sessionSocket = -1;
@@ -276,7 +257,7 @@ usage(void)
{
fprintf(stderr, "Usage: pppoe-discovery [options]\n");
fprintf(stderr, "Options:\n");
- fprintf(stderr, " -I if_name -- Specify interface (default eth0)\n");
+ fprintf(stderr, " -I if_name -- Specify interface (mandatory option)\n");
fprintf(stderr, " -D filename -- Log debugging information in filename.\n");
fprintf(stderr,
" -t timeout -- Initial timeout for discovery packets in seconds\n"