diff options
author | Chia-chi Yeh <chiachi@android.com> | 2011-07-18 13:57:17 -0700 |
---|---|---|
committer | Chia-chi Yeh <chiachi@android.com> | 2011-07-18 13:57:17 -0700 |
commit | 0f725857a9901b62b20c96b2ee70372660d13f46 (patch) | |
tree | 7bf8c1f1affb2198275f481e9c10f92fc6337d7c | |
parent | ec2b0392adedaa2707b627b842f3f9f355d844d5 (diff) | |
download | mtpd-0f725857a9901b62b20c96b2ee70372660d13f46.tar.gz |
VPN: remove the workaround for driver ID changes.
Change-Id: I1ae33e065c293969fe8abe6e370cd9cb29a44ee2
-rw-r--r-- | l2tp.c | 27 | ||||
-rw-r--r-- | pptp.c | 27 |
2 files changed, 14 insertions, 40 deletions
@@ -23,13 +23,13 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <unistd.h> #include <fcntl.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/stat.h> #include <arpa/inet.h> -#include <linux/if_pppolac.h> +#include <linux/netdevice.h> +#include <linux/if_pppox.h> #include <openssl/md5.h> #include "mtpd.h" @@ -346,43 +346,30 @@ static int l2tp_connect(char **arguments) return TIMEOUT_INTERVAL; } -static int create_pppox_hack(unsigned int protocol) +static int create_pppox() { - int pppox; + int pppox = socket(AF_PPPOX, SOCK_DGRAM, PX_PROTO_OLAC); log_print(INFO, "Creating PPPoX socket"); - 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 = protocol, + .sa_protocol = PX_PROTO_OLAC, .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))) { log_print(FATAL, "Connect() %s", strerror(errno)); - close(pppox); - return -1; + exit(SYSTEM_ERROR); } } 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]; @@ -23,11 +23,11 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <arpa/inet.h> -#include <linux/if_pppopns.h> +#include <linux/netdevice.h> +#include <linux/if_pppox.h> #include "mtpd.h" @@ -229,43 +229,30 @@ static int pptp_connect(char **arguments) return 0; } -static int create_pppox_hack(unsigned int protocol) +static int create_pppox() { - int pppox; + int pppox = socket(AF_PPPOX, SOCK_DGRAM, PX_PROTO_OPNS); log_print(INFO, "Creating PPPoX socket"); - 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 = protocol, + .sa_protocol = PX_PROTO_OPNS, .tcp_socket = the_socket, .local = local, .remote = remote, }; if (connect(pppox, (struct sockaddr *)&address, sizeof(address))) { log_print(FATAL, "Connect() %s", strerror(errno)); - close(pppox); - return -1; + exit(SYSTEM_ERROR); } } 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(); |