2 * Perform PPPoE discovery
4 * Copyright (C) 2000-2001 by Roaring Penguin Software Inc.
5 * Copyright (C) 2004 Marco d'Itri <md@linux.it>
7 * This program may be distributed according to the terms of the GNU
8 * General Public License, version 2 or (at your option) any later version.
20 char *xstrdup(const char *s);
28 int main(int argc, char *argv[])
31 PPPoEConnection *conn;
33 conn = malloc(sizeof(PPPoEConnection));
37 memset(conn, 0, sizeof(PPPoEConnection));
39 while ((opt = getopt(argc, argv, "I:D:VUAS:C:h")) > 0) {
42 conn->serviceName = xstrdup(optarg);
45 conn->acName = xstrdup(optarg);
48 conn->useHostUniq = 1;
51 conn->debugFile = fopen(optarg, "w");
52 if (!conn->debugFile) {
53 fprintf(stderr, "Could not open %s: %s\n",
54 optarg, strerror(errno));
57 fprintf(conn->debugFile, "pppoe-discovery %s\n", VERSION);
60 conn->ifName = xstrdup(optarg);
63 /* this is the default */
75 /* default interface name */
77 conn->ifName = strdup("eth0");
79 conn->discoverySocket = -1;
80 conn->sessionSocket = -1;
81 conn->printACNames = 1;
87 void rp_fatal(char const *str)
92 sprintf(buf, "pppoe-discovery: %.256s", str);
96 void fatalSys(char const *str)
101 sprintf(buf, "%.256s: %.256s", str, strerror(i));
103 sprintf(buf, "pppoe-discovery: %.256s: %.256s", str, strerror(i));
107 void sysErr(char const *str)
112 char *xstrdup(const char *s)
114 register char *ret = strdup(s);
122 fprintf(stderr, "Usage: pppoe-discovery [options]\n");
123 fprintf(stderr, "\nVersion " VERSION "\n");