#include "config.h"
-#if defined(HAVE_NETPACKET_PACKET_H) || defined(HAVE_LINUX_IF_PACKET_H)
-#define _POSIX_SOURCE 1 /* For sigaction defines */
-#endif
-
#include <stdio.h> /* For FILE */
#include <sys/types.h> /* For pid_t */
+#include <ctype.h>
+#include <string.h>
+
+#include "pppd/pppd.h" /* For error */
/* How do we access raw Ethernet devices? */
#undef USE_LINUX_PACKET
#error Unknown method for accessing raw Ethernet frames
#endif
-#ifdef HAVE_SYS_CDEFS_H
-#include <sys/cdefs.h>
-#endif
-
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
char *serviceName; /* Desired service name, if any */
char *acName; /* Desired AC name, if any */
int synchronous; /* Use synchronous PPP */
- int useHostUniq; /* Use Host-Uniq tag */
+ PPPoETag hostUniq; /* Use Host-Uniq tag */
int printACNames; /* Just print AC names */
FILE *debugFile; /* Debug file for dumping packets */
int numPADOs; /* Number of PADO packets received */
int error; /* Error packet received */
int debug; /* Set to log packets sent and received */
int discoveryTimeout; /* Timeout for discovery packets */
+ int discoveryAttempts; /* Number of discovery attempts */
int seenMaxPayload;
int mtu; /* Stored MTU */
int mru; /* Stored MRU */
void (*printer)(void *, char *, ...), void *arg);
void pppoe_log_packet(const char *prefix, PPPoEPacket *packet);
+static inline int parseHostUniq(const char *uniq, PPPoETag *tag)
+{
+ unsigned i, len = strlen(uniq);
+
+#define hex(x) \
+ (((x) <= '9') ? ((x) - '0') : \
+ (((x) <= 'F') ? ((x) - 'A' + 10) : \
+ ((x) - 'a' + 10)))
+
+ if (!len || len % 2 || len / 2 > sizeof(tag->payload))
+ return 0;
+
+ for (i = 0; i < len; i += 2) {
+ if (!isxdigit(uniq[i]) || !isxdigit(uniq[i+1]))
+ return 0;
+
+ tag->payload[i / 2] = (char)(hex(uniq[i]) << 4 | hex(uniq[i+1]));
+ }
+
+#undef hex
+
+ tag->type = htons(TAG_HOST_UNIQ);
+ tag->length = htons(len / 2);
+ return 1;
+}
+
#define SET_STRING(var, val) do { if (var) free(var); var = strDup(val); } while(0);
#define CHECK_ROOM(cursor, start, len) \