mirror of git://git.sysmocom.de/ofono
Remove PPP recv_queue handling and process frames directly
This commit is contained in:
parent
cb791ceb78
commit
dabac98cb4
|
@ -147,7 +147,6 @@ GAtPPP *g_at_ppp_new(GIOChannel *modem)
|
||||||
|
|
||||||
/* allocate the queues */
|
/* allocate the queues */
|
||||||
ppp->event_queue = g_queue_new();
|
ppp->event_queue = g_queue_new();
|
||||||
ppp->recv_queue = g_queue_new();
|
|
||||||
|
|
||||||
ppp->index = 0;
|
ppp->index = 0;
|
||||||
|
|
||||||
|
|
|
@ -188,31 +188,29 @@ static gint is_proto_handler(gconstpointer a, gconstpointer b)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* called when we have received a complete ppp frame */
|
/* called when we have received a complete ppp frame */
|
||||||
static void ppp_recv(GAtPPP *ppp)
|
static void ppp_recv(GAtPPP *ppp, struct frame_buffer *frame)
|
||||||
{
|
{
|
||||||
|
guint protocol = ppp_proto(frame->bytes);
|
||||||
|
guint8 *packet = ppp_info(frame->bytes);
|
||||||
|
struct ppp_packet_handler *h;
|
||||||
GList *list;
|
GList *list;
|
||||||
struct frame_buffer *frame;
|
|
||||||
|
|
||||||
/* pop frames off of receive queue */
|
if (!frame)
|
||||||
while ((frame = g_queue_pop_head(ppp->recv_queue))) {
|
return;
|
||||||
guint protocol = ppp_proto(frame->bytes);
|
|
||||||
guint8 *packet = ppp_info(frame->bytes);
|
|
||||||
struct ppp_packet_handler *h;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* check to see if we have a protocol handler
|
* check to see if we have a protocol handler
|
||||||
* registered for this packet
|
* registered for this packet
|
||||||
*/
|
*/
|
||||||
list = g_list_find_custom(packet_handlers,
|
list = g_list_find_custom(packet_handlers,
|
||||||
GUINT_TO_POINTER(protocol),
|
GUINT_TO_POINTER(protocol), is_proto_handler);
|
||||||
is_proto_handler);
|
if (list) {
|
||||||
if (list) {
|
h = list->data;
|
||||||
h = list->data;
|
h->handler(h->priv, packet);
|
||||||
h->handler(h->priv, packet);
|
} else
|
||||||
} else
|
lcp_protocol_reject(ppp->lcp, frame->bytes, frame->len);
|
||||||
lcp_protocol_reject(ppp->lcp, frame->bytes, frame->len);
|
|
||||||
g_free(frame);
|
g_free(frame);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX - Implement PFC and ACFC */
|
/* XXX - Implement PFC and ACFC */
|
||||||
|
@ -277,10 +275,8 @@ static void ppp_feed(GAtPPP *ppp, guint8 *data, gsize len)
|
||||||
ppp->buffer[ppp->index++] = data[pos];
|
ppp->buffer[ppp->index++] = data[pos];
|
||||||
frame = ppp_decode(ppp, ppp->buffer);
|
frame = ppp_decode(ppp, ppp->buffer);
|
||||||
|
|
||||||
/* push decoded frame onto receive queue */
|
/* process receive frame */
|
||||||
if (frame)
|
ppp_recv(ppp, frame);
|
||||||
g_queue_push_tail(ppp->recv_queue,
|
|
||||||
frame);
|
|
||||||
|
|
||||||
/* zero buffer */
|
/* zero buffer */
|
||||||
memset(ppp->buffer, 0, BUFFERSZ);
|
memset(ppp->buffer, 0, BUFFERSZ);
|
||||||
|
@ -292,8 +288,6 @@ static void ppp_feed(GAtPPP *ppp, guint8 *data, gsize len)
|
||||||
if (ppp->index < BUFFERSZ)
|
if (ppp->index < BUFFERSZ)
|
||||||
ppp->buffer[ppp->index++] = data[pos];
|
ppp->buffer[ppp->index++] = data[pos];
|
||||||
}
|
}
|
||||||
/* process receive queue */
|
|
||||||
ppp_recv(ppp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ppp_record(GAtPPP *ppp, gboolean in, guint8 *data, guint16 length)
|
static void ppp_record(GAtPPP *ppp, gboolean in, guint8 *data, guint16 length)
|
||||||
|
@ -418,7 +412,6 @@ static void ppp_dead(GAtPPP *ppp)
|
||||||
|
|
||||||
/* clean up all the queues */
|
/* clean up all the queues */
|
||||||
g_queue_free(ppp->event_queue);
|
g_queue_free(ppp->event_queue);
|
||||||
g_queue_free(ppp->recv_queue);
|
|
||||||
|
|
||||||
/* cleanup modem channel */
|
/* cleanup modem channel */
|
||||||
g_source_remove(ppp->modem_watch);
|
g_source_remove(ppp->modem_watch);
|
||||||
|
|
|
@ -131,7 +131,6 @@ struct _GAtPPP {
|
||||||
guint32 recv_accm;
|
guint32 recv_accm;
|
||||||
GIOChannel *modem;
|
GIOChannel *modem;
|
||||||
GQueue *event_queue;
|
GQueue *event_queue;
|
||||||
GQueue *recv_queue;
|
|
||||||
GAtPPPConnectFunc connect_cb;
|
GAtPPPConnectFunc connect_cb;
|
||||||
gpointer connect_data;
|
gpointer connect_data;
|
||||||
GAtDisconnectFunc disconnect_cb;
|
GAtDisconnectFunc disconnect_cb;
|
||||||
|
|
Loading…
Reference in New Issue