diff options
-rw-r--r-- | gatchat/gatppp.c | 1 | ||||
-rw-r--r-- | gatchat/ppp.c | 51 | ||||
-rw-r--r-- | gatchat/ppp.h | 1 |
3 files changed, 22 insertions, 31 deletions
diff --git a/gatchat/gatppp.c b/gatchat/gatppp.c index b69a334d..bc607a8f 100644 --- a/gatchat/gatppp.c +++ b/gatchat/gatppp.c @@ -147,7 +147,6 @@ GAtPPP *g_at_ppp_new(GIOChannel *modem) /* allocate the queues */ ppp->event_queue = g_queue_new(); - ppp->recv_queue = g_queue_new(); ppp->index = 0; diff --git a/gatchat/ppp.c b/gatchat/ppp.c index 289c235f..6312daba 100644 --- a/gatchat/ppp.c +++ b/gatchat/ppp.c @@ -188,31 +188,29 @@ static gint is_proto_handler(gconstpointer a, gconstpointer b) } /* 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; - struct frame_buffer *frame; - /* pop frames off of receive queue */ - while ((frame = g_queue_pop_head(ppp->recv_queue))) { - 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 - * registered for this packet - */ - list = g_list_find_custom(packet_handlers, - GUINT_TO_POINTER(protocol), - is_proto_handler); - if (list) { - h = list->data; - h->handler(h->priv, packet); - } else - lcp_protocol_reject(ppp->lcp, frame->bytes, frame->len); - g_free(frame); - } + if (!frame) + return; + + /* + * check to see if we have a protocol handler + * registered for this packet + */ + list = g_list_find_custom(packet_handlers, + GUINT_TO_POINTER(protocol), is_proto_handler); + if (list) { + h = list->data; + h->handler(h->priv, packet); + } else + lcp_protocol_reject(ppp->lcp, frame->bytes, frame->len); + + g_free(frame); } /* 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]; frame = ppp_decode(ppp, ppp->buffer); - /* push decoded frame onto receive queue */ - if (frame) - g_queue_push_tail(ppp->recv_queue, - frame); + /* process receive frame */ + ppp_recv(ppp, frame); /* zero buffer */ memset(ppp->buffer, 0, BUFFERSZ); @@ -292,8 +288,6 @@ static void ppp_feed(GAtPPP *ppp, guint8 *data, gsize len) if (ppp->index < BUFFERSZ) ppp->buffer[ppp->index++] = data[pos]; } - /* process receive queue */ - ppp_recv(ppp); } 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 */ g_queue_free(ppp->event_queue); - g_queue_free(ppp->recv_queue); /* cleanup modem channel */ g_source_remove(ppp->modem_watch); diff --git a/gatchat/ppp.h b/gatchat/ppp.h index e8473517..9e5c5a70 100644 --- a/gatchat/ppp.h +++ b/gatchat/ppp.h @@ -131,7 +131,6 @@ struct _GAtPPP { guint32 recv_accm; GIOChannel *modem; GQueue *event_queue; - GQueue *recv_queue; GAtPPPConnectFunc connect_cb; gpointer connect_data; GAtDisconnectFunc disconnect_cb; |