mirror of git://git.sysmocom.de/ofono
gathdlc: Try to detect no carrier conditions
Sometimes we receive the no carrier embedded in a stream following the PPP packets. This might be due to write scheduling on the remote side or read scheduling locally. Try not to consume the no carrier condition and assume the previous hdlc frames will result in closing of the ppp stack.
This commit is contained in:
parent
ef2c133281
commit
0dc8e5e588
|
@ -65,6 +65,7 @@ struct _GAtHDLC {
|
|||
int record_fd;
|
||||
gboolean in_read_handler;
|
||||
gboolean destroyed;
|
||||
gboolean no_carrier_detect;
|
||||
};
|
||||
|
||||
static void hdlc_record(int fd, gboolean in, guint8 *data, guint16 length)
|
||||
|
@ -140,6 +141,16 @@ static void new_bytes(struct ring_buffer *rbuf, gpointer user_data)
|
|||
hdlc->in_read_handler = TRUE;
|
||||
|
||||
while (pos < len) {
|
||||
/*
|
||||
* We try to detect NO CARRIER conditions here. We
|
||||
* (ab) use the fact that a HDLC_FLAG must be followed
|
||||
* by the Address or Protocol fields, depending on whether
|
||||
* ACFC is enabled.
|
||||
*/
|
||||
if (hdlc->no_carrier_detect &&
|
||||
hdlc->decode_offset == 0 && *buf == '\r')
|
||||
break;
|
||||
|
||||
if (hdlc->decode_escape == TRUE) {
|
||||
unsigned char val = *buf ^ HDLC_TRANS;
|
||||
|
||||
|
@ -435,3 +446,11 @@ gboolean g_at_hdlc_send(GAtHDLC *hdlc, const unsigned char *data, gsize size)
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void g_at_hdlc_set_no_carrier_detect(GAtHDLC *hdlc, gboolean detect)
|
||||
{
|
||||
if (hdlc == NULL)
|
||||
return;
|
||||
|
||||
hdlc->no_carrier_detect = detect;
|
||||
}
|
||||
|
|
|
@ -55,6 +55,8 @@ void g_at_hdlc_set_recording(GAtHDLC *hdlc, const char *filename);
|
|||
|
||||
GAtIO *g_at_hdlc_get_io(GAtHDLC *hdlc);
|
||||
|
||||
void g_at_hdlc_set_no_carrier_detect(GAtHDLC *hdlc, gboolean detect);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue