Skip to content

Commit

Permalink
exec offline hook before unexpected exit
Browse files Browse the repository at this point in the history
  • Loading branch information
hanwckf committed Oct 18, 2019
1 parent 20b1ba1 commit 3857f08
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ void loginToGetServerMAC(uint8_t recv_data[]) {
// 初始化服务器MAC地址
memcpy(EthHeader, recv_data + 6, 6);
if(auth_8021x_Handler(recv_data))
exit(EXIT_FAILURE); //这里不需要考虑重拨的问题,正常第一个请求是Identity,不会失败。
exit_with_hook(EXIT_FAILURE); //这里不需要考虑重拨的问题,正常第一个请求是Identity,不会失败。
return;
} else {
continue;
Expand All @@ -391,7 +391,7 @@ void loginToGetServerMAC(uint8_t recv_data[]) {
LogWrite(DOT1X, ERROR, "Error! No Response");
// 确保下线
auth_8021x_Logoff();
exit(EXIT_FAILURE);
exit_with_hook(EXIT_FAILURE);
}

times--;
Expand Down Expand Up @@ -644,7 +644,7 @@ int auth_8021x_Handler(uint8_t recv_data[]) {
return 1;
} else {
LogWrite(DOT1X, ERROR, "Reconnection failed. Server: errtype=0x%02hhx", errtype);
exit(EXIT_FAILURE);
exit_with_hook(EXIT_FAILURE);
}
} else if ((EAP_Code) recv_data[18] == SUCCESS) {
LogWrite(DOT1X, INF, "Server: Success.");
Expand All @@ -669,3 +669,9 @@ int auth_8021x_Handler(uint8_t recv_data[]) {
}
return 0;
}

void exit_with_hook(int a) {
if (OfflineHookCmd)
system(OfflineHookCmd);
exit(a);
}
2 changes: 1 addition & 1 deletion src/auth.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ int Drcom_UDP_Handler(uint8_t *recv_data);
void initAuthenticationInfo();
void loginToGetServerMAC(uint8_t recv_data[]);
void printIfInfo();

void exit_with_hook(int a);

0 comments on commit 3857f08

Please sign in to comment.