forked from espressif/esp-protocols
fix(modem): Fix PPP mode detection to accept LCP/conf
This commit is contained in:
@ -328,12 +328,19 @@ modem_mode DCE_Mode::guess_unsafe(DTE *dte, bool with_cmux)
|
|||||||
if (reply_pos >= sizeof(probe::ppp::lcp_echo_reply_head)) {
|
if (reply_pos >= sizeof(probe::ppp::lcp_echo_reply_head)) {
|
||||||
// check for initial 2 bytes
|
// check for initial 2 bytes
|
||||||
auto *ptr = static_cast<uint8_t *>(memmem(reply, reply_pos, probe::ppp::lcp_echo_reply_head.data(), 2));
|
auto *ptr = static_cast<uint8_t *>(memmem(reply, reply_pos, probe::ppp::lcp_echo_reply_head.data(), 2));
|
||||||
// and check the other two bytes for protocol ID: LCP
|
// and check the other two bytes for protocol ID:
|
||||||
|
// * either LCP reply
|
||||||
if (ptr && ptr[3] == probe::ppp::lcp_echo_reply_head[3] && ptr[4] == probe::ppp::lcp_echo_reply_head[4]) {
|
if (ptr && ptr[3] == probe::ppp::lcp_echo_reply_head[3] && ptr[4] == probe::ppp::lcp_echo_reply_head[4]) {
|
||||||
if (auto signal = weak_signal.lock()) {
|
if (auto signal = weak_signal.lock()) {
|
||||||
signal->set(probe::ppp::mode);
|
signal->set(probe::ppp::mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// * or LCP conf request
|
||||||
|
if (ptr && ptr[3] == probe::ppp::lcp_echo_request[3] && ptr[4] == probe::ppp::lcp_echo_request[4]) {
|
||||||
|
if (auto signal = weak_signal.lock()) {
|
||||||
|
signal->set(probe::ppp::mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (reply_pos >= 4 && memmem(reply, reply_pos, probe::cmd::reply, sizeof(probe::cmd::reply))) {
|
if (reply_pos >= 4 && memmem(reply, reply_pos, probe::cmd::reply, sizeof(probe::cmd::reply))) {
|
||||||
if (reply[0] != 0xf9) { // double check that the reply is not wrapped in CMUX headers
|
if (reply[0] != 0xf9) { // double check that the reply is not wrapped in CMUX headers
|
||||||
|
Reference in New Issue
Block a user