Skip to content

Commit

Permalink
enlarge username & update logging position
Browse files Browse the repository at this point in the history
  • Loading branch information
mchome committed Jun 22, 2017
1 parent cfda241 commit 23a501c
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 30 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# dogcom [![travis-ci](https://travis-ci.org/mchome/dogcom.svg "Build status")](https://travis-ci.org/mchome/dogcom) [![badge](https://img.shields.io/badge/%20built%20with-%20%E2%9D%A4-ff69b4.svg "build with love")](https://github.com/mchome/dogcom) [![version](https://img.shields.io/badge/stable%20-%20v1.4.0-4dc71f.svg "stable version")](https://github.com/mchome/dogcom/tree/v1.4.0)
# dogcom [![travis-ci](https://travis-ci.org/mchome/dogcom.svg "Build status")](https://travis-ci.org/mchome/dogcom) [![badge](https://img.shields.io/badge/%20built%20with-%20%E2%9D%A4-ff69b4.svg "build with love")](https://github.com/mchome/dogcom) [![version](https://img.shields.io/badge/stable%20-%20v1.4.1-4dc71f.svg "stable version")](https://github.com/mchome/dogcom/tree/v1.4.1)

[Drcom-generic](https://github.com/drcoms/drcom-generic) implementation in C.

Expand Down
42 changes: 23 additions & 19 deletions auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ int challenge(int sockfd, struct sockaddr_in addr, unsigned char seed[]) {
perror("Failed to recv data");
return 1;
}
if (recv_packet[0] != 0x02) {
printf("Bad challenge response received.\n");
return 1;
}

if (verbose_flag) {
print_packet("[Challenge recv] ", recv_packet, 76);
Expand All @@ -65,6 +61,11 @@ int challenge(int sockfd, struct sockaddr_in addr, unsigned char seed[]) {
logging("[Challenge recv] ", recv_packet, 76);
}

if (recv_packet[0] != 0x02) {
printf("Bad challenge response received.\n");
return 1;
}

memcpy(seed, &recv_packet[4], 4 * sizeof(*recv_packet));
#ifdef DEBUG
print_packet("<GET SEED> ", seed, 4);
Expand Down Expand Up @@ -226,10 +227,6 @@ int login(int sockfd, struct sockaddr_in addr, unsigned char seed[], unsigned ch
perror("Failed to recv data");
return 1;
}
if (recv_packet[0] != 0x04) {
printf("<<< login failed >>>\n");
return 1;
}

if (verbose_flag) {
print_packet("[login recv] ", recv_packet, 100);
Expand All @@ -240,6 +237,11 @@ int login(int sockfd, struct sockaddr_in addr, unsigned char seed[], unsigned ch
logging("<<< Logged in >>>", NULL, 0);
}

if (recv_packet[0] != 0x04) {
printf("<<< login failed >>>\n");
return 1;
}

memcpy(auth_information, &recv_packet[23], 16);
#ifdef DEBUG
print_packet("<GET AUTH_INFORMATION> ", auth_information, 16);
Expand Down Expand Up @@ -285,6 +287,14 @@ int pppoe_challenge(int sockfd, struct sockaddr_in addr, int *pppoe_counter, uns
perror("Failed to recv data");
return 1;
}

if (verbose_flag) {
print_packet("[Challenge recv] ", recv_packet, 32);
}
if (logging_flag) {
logging("[Challenge recv] ", recv_packet, 32);
}

if (recv_packet[0] != 0x07) {
printf("Bad challenge response received.\n");
return 1;
Expand All @@ -299,13 +309,6 @@ int pppoe_challenge(int sockfd, struct sockaddr_in addr, int *pppoe_counter, uns
*encrypt_mode = 1;
#endif

if (verbose_flag) {
print_packet("[Challenge recv] ", recv_packet, 32);
}
if (logging_flag) {
logging("[Challenge recv] ", recv_packet, 32);
}

memcpy(seed, &recv_packet[8], 4);
memcpy(sip, &recv_packet[12], 4);
memcpy(drcom_config.KEEP_ALIVE_VERSION, &recv_packet[28], 2);
Expand Down Expand Up @@ -385,10 +388,6 @@ int pppoe_login(int sockfd, struct sockaddr_in addr, int *pppoe_counter, unsigne
perror("Failed to recv data");
return 1;
}
if (recv_packet[0] != 0x07) {
printf("Bad pppoe_login response received.\n");
return 1;
}

if (verbose_flag) {
print_packet("[PPPoE_login recv] ", recv_packet, 48);
Expand All @@ -397,6 +396,11 @@ int pppoe_login(int sockfd, struct sockaddr_in addr, int *pppoe_counter, unsigne
logging("[PPPoE_login recv] ", recv_packet, 48);
}

if (recv_packet[0] != 0x07) {
printf("Bad pppoe_login response received.\n");
return 1;
}

if(recvfrom(sockfd, recv_packet, 1024, 0, (struct sockaddr *)&addr, &addrlen) >= 0) {
DEBUG_PRINT(("Get notice packet."));
}
Expand Down
2 changes: 1 addition & 1 deletion configparse.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

struct config {
char server[20];
char username[20];
char username[36];
char password[20];
unsigned char CONTROLCHECKSTATUS;
unsigned char ADAPTERNUM;
Expand Down
16 changes: 8 additions & 8 deletions keepalive.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ int keepalive_1(int sockfd, struct sockaddr_in addr, unsigned char seed[], unsig
perror("Failed to recv data");
return 1;
} else {
if (verbose_flag) {
print_packet("[Keepalive1 recv] ", recv_packet, 100);
}
if (logging_flag) {
logging("[Keepalive1 recv] ", recv_packet, 100);
}

if (recv_packet[0] == 0x07) {
break;
} else if (recv_packet[0] == 0x4d) {
Expand All @@ -66,13 +73,6 @@ int keepalive_1(int sockfd, struct sockaddr_in addr, unsigned char seed[], unsig
}
}

if (verbose_flag) {
print_packet("[Keepalive1 recv] ", recv_packet, 100);
}
if (logging_flag) {
logging("[Keepalive1 recv] ", recv_packet, 100);
}

return 0;
}

Expand Down Expand Up @@ -204,7 +204,7 @@ int keepalive_2(int sockfd, struct sockaddr_in addr, int *keepalive_counter, int
}
#endif

// send the first pacekt
// send the first packet
*first = 0;
memset(keepalive_2_packet, 0, 40);
if (strcmp(mode, "pppoe") == 0) {
Expand Down
2 changes: 1 addition & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "libs/common.h"
#endif

#define VERSION "1.4.0"
#define VERSION "1.4.1"

void print_help(int exval);
int try_smart_eaplogin(void);
Expand Down

0 comments on commit 23a501c

Please sign in to comment.