Re: [patch 3/6] LCP support

2010-03-17 Thread Marcel Holtmann
Hi Kristen,

  Makefile.am   |6 -
  gatchat/gatppp.c  |   53 +
  gatchat/gatppp_internal.h |8 +
  gatchat/gatppplcp.c   |  244 
 ++

this should be gatchat/ppp_lcp.c

 +void __ppp_set_auth(GAtPPP *ppp, guint8* auth_data)
 +{
 + guint16 proto = ntohs(*(guint16 *)auth_data);

This are again one of these constructs that will break on non-x86
hardware.

I think you need to create ppp_get_unaligned and ppp_put_unaligned. If
all of them are be16 anyway, you could do ppp_get_unaligned_be16 etc.

Regards

Marcel


___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[patch 3/6] LCP support

2010-03-11 Thread kristen
Implement LCP support for the PPP protocol

Index: ofono/Makefile.am
===
--- ofono.orig/Makefile.am  2010-03-10 17:00:34.037087986 -0800
+++ ofono/Makefile.am   2010-03-10 17:01:56.687955124 -0800
@@ -56,9 +56,9 @@
gatchat/gatutil.h gatchat/gatutil.c \
gatchat/gat.h \
gatchat/gatserver.h gatchat/gatserver.c \
-   gatchat/gatppp.c gatchat/gatppp.h \
-   gatchat/gatppp_internal.h gatchat/gatpppcp.c
-   gatchat/gatpppcp.h
+   gatchat/gatppp_internal.h gatchat/gatpppcp.c \
+   gatchat/gatpppcp.h gatchat/gatppp.c \
+   gatchat/gatppplcp.c gatchat/gatppp.h
 
 udev_files = plugins/ofono.rules
 
Index: ofono/gatchat/gatppp.c
===
--- ofono.orig/gatchat/gatppp.c 2010-03-10 16:58:12.039961039 -0800
+++ ofono/gatchat/gatppp.c  2010-03-10 17:01:56.687955124 -0800
@@ -352,22 +352,26 @@
 static void ppp_close(struct ppp_link *link)
 {
/* send a CLOSE event to the lcp layer */
+   lcp_close(link-lcp);
 }
 
 /* Administrative Open */
 void g_at_ppp_open(struct ppp_link *link)
 {
/* send an OPEN event to the lcp layer */
+   lcp_open(link-lcp);
 }
 
 static void ppp_link_establishment(struct ppp_link *link)
 {
/* signal UP event to LCP */
+   lcp_establish(link-lcp);
 }
 
 static void ppp_terminate(struct ppp_link *link)
 {
/* signal DOWN event to LCP */
+   lcp_terminate(link-lcp);
 }
 
 static void ppp_authenticate(struct ppp_link *link)
@@ -485,6 +489,9 @@
/* cleanup modem channel */
g_source_remove(link-modem_watch);
g_io_channel_unref(link-modem);
+
+   /* remove lcp */
+   lcp_free(link-lcp);
 }
 
 void g_at_ppp_ref(struct ppp_link *link)
@@ -503,6 +510,50 @@
}
 }
 
+void __ppp_set_auth(struct ppp_link *link, guint8* auth_data)
+{
+   guint16 proto = ntohs(*(guint16 *)auth_data);
+
+   switch(proto) {
+   case CHAP_PROTOCOL:
+   /* get the algorithm */
+   break;
+   default:
+   g_printerr(unknown authentication proto\n);
+   break;
+   }
+}
+
+void __ppp_set_recv_accm(struct ppp_link *link, guint32 accm)
+{
+   link-recv_accm = accm;
+}
+
+guint32 __ppp_get_xmit_accm(struct ppp_link *link)
+{
+   return link-xmit_accm[0];
+}
+
+void __ppp_set_pfc(struct ppp_link *link, gboolean pfc)
+{
+   link-pfc = pfc;
+}
+
+gboolean __ppp_get_pfc(struct ppp_link *link)
+{
+   return link-pfc;
+}
+
+void __ppp_set_acfc(struct ppp_link *link, gboolean acfc)
+{
+   link-acfc = acfc;
+}
+
+gboolean __ppp_get_acfc(struct ppp_link *link)
+{
+   return link-acfc;
+}
+
 struct ppp_link * g_at_ppp_new(GIOChannel *modem)
 {
struct ppp_link *link;
@@ -540,7 +591,7 @@
g_io_channel_set_buffered(modem, FALSE);
 
/* initialize the lcp state */
-
+   link-lcp = lcp_new(link);
 
/* initialize the autentication state */
 
Index: ofono/gatchat/gatppp.h
===
--- ofono.orig/gatchat/gatppp.h 2010-03-10 16:58:12.040979395 -0800
+++ ofono/gatchat/gatppp.h  2010-03-10 17:01:56.688955112 -0800
@@ -43,6 +43,7 @@
 struct ppp_link {
gint ref_count;
guint phase;
+   struct pppcp_data *lcp;
guint8 *buffer;
int index;
gint mru;
Index: ofono/gatchat/gatppp_internal.h
===
--- ofono.orig/gatchat/gatppp_internal.h2010-03-10 17:00:34.040101010 
-0800
+++ ofono/gatchat/gatppp_internal.h 2010-03-10 17:01:56.688955112 -0800
@@ -91,6 +91,12 @@
 gboolean __ppp_get_pfc(struct ppp_link *link);
 void __ppp_set_acfc(struct ppp_link *link, gboolean acfc);
 gboolean __ppp_get_acfc(struct ppp_link *link);
+struct pppcp_data * lcp_new(struct ppp_link *link);
+void lcp_free(struct pppcp_data *lcp);
+void lcp_open(struct pppcp_data *data);
+void lcp_close(struct pppcp_data *data);
+void lcp_establish(struct pppcp_data *data);
+void lcp_terminate(struct pppcp_data *data);
 #ifdef __cplusplus
 }
 #endif
Index: ofono/gatchat/gatppplcp.c
===
--- /dev/null   1970-01-01 00:00:00.0 +
+++ ofono/gatchat/gatppplcp.c   2010-03-10 17:01:56.688955112 -0800
@@ -0,0 +1,225 @@
+/*
+ *
+ *  AT chat library with GLib integration
+ *
+ *  Copyright (C) 2008-2009  Intel Corporation. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in