VPN: temporary workaround for driver ID changes.

Change-Id: I0b520357027fc1b81db7a37220ed49e327ce50c9
diff --git a/l2tp.c b/l2tp.c
index 4fda9d6..339ae3d 100644
--- a/l2tp.c
+++ b/l2tp.c
@@ -23,6 +23,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
+#include <unistd.h>
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -345,31 +346,43 @@
     return TIMEOUT_INTERVAL;
 }
 
-static int create_pppox()
+static int create_pppox_hack(unsigned int protocol)
 {
     int pppox;
     log_print(INFO, "Creating PPPoX socket");
-    pppox = socket(AF_PPPOX, SOCK_DGRAM, PX_PROTO_OLAC);
+    pppox = socket(AF_PPPOX, SOCK_DGRAM, protocol);
 
     if (pppox == -1) {
         log_print(FATAL, "Socket() %s", strerror(errno));
-        exit(SYSTEM_ERROR);
     } else {
         struct sockaddr_pppolac address = {
             .sa_family = AF_PPPOX,
-            .sa_protocol = PX_PROTO_OLAC,
+            .sa_protocol = protocol,
             .udp_socket = the_socket,
             .local = {.tunnel = local_tunnel, .session = local_session},
             .remote = {.tunnel = remote_tunnel, .session = remote_session},
         };
         if (connect(pppox, (struct sockaddr *)&address, sizeof(address)) != 0) {
             log_print(FATAL, "Connect() %s", strerror(errno));
-            exit(SYSTEM_ERROR);
+            close(pppox);
+            return -1;
         }
     }
     return pppox;
 }
 
+static int create_pppox() {
+    /* PX_PROTO_OLAC is bumped from 2 to 3 after 2.6.38. :( */
+    int pppox = create_pppox_hack(3);
+    if (pppox == -1) {
+        pppox = create_pppox_hack(2);
+    }
+    if (pppox == -1) {
+        exit(SYSTEM_ERROR);
+    }
+    return pppox;
+}
+
 static uint8_t *compute_response(uint8_t type, void *challenge, int size)
 {
     static uint8_t response[MD5_DIGEST_LENGTH];
diff --git a/pptp.c b/pptp.c
index f749c5c..ccd0faa 100644
--- a/pptp.c
+++ b/pptp.c
@@ -23,6 +23,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
+#include <unistd.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <arpa/inet.h>
@@ -231,31 +232,43 @@
     return 0;
 }
 
-static int create_pppox()
+static int create_pppox_hack(unsigned int protocol)
 {
     int pppox;
     log_print(INFO, "Creating PPPoX socket");
-    pppox = socket(AF_PPPOX, SOCK_DGRAM, PX_PROTO_OPNS);
+    pppox = socket(AF_PPPOX, SOCK_DGRAM, protocol);
 
     if (pppox == -1) {
         log_print(FATAL, "Socket() %s", strerror(errno));
-        exit(SYSTEM_ERROR);
     } else {
         struct sockaddr_pppopns address = {
             .sa_family = AF_PPPOX,
-            .sa_protocol = PX_PROTO_OPNS,
+            .sa_protocol = protocol,
             .tcp_socket = the_socket,
             .local = local,
             .remote = remote,
         };
         if (connect(pppox, (struct sockaddr *)&address, sizeof(address)) != 0) {
             log_print(FATAL, "Connect() %s", strerror(errno));
-            exit(SYSTEM_ERROR);
+            close(pppox);
+            return -1;
         }
     }
     return pppox;
 }
 
+static int create_pppox() {
+    /* PX_PROTO_OPNS is bumped from 3 to 4 after 2.6.38. :( */
+    int pppox = create_pppox_hack(4);
+    if (pppox == -1) {
+        pppox = create_pppox_hack(3);
+    }
+    if (pppox == -1) {
+        exit(SYSTEM_ERROR);
+    }
+    return pppox;
+}
+
 static int pptp_process()
 {
     int result = recv_packet();