diff options
author | Denis Kenzior <denkenz@gmail.com> | 2010-04-05 16:55:28 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2010-04-05 16:55:28 -0500 |
commit | 8bff9b65411d5ff1dfb9fbc5f03a28ffdc88d596 (patch) | |
tree | a24335df1a32954aa5ca0ee59e417cd20d0e8c2e | |
parent | 04cfa990e289cd3c600f878e28f62709e860e292 (diff) | |
download | ofono-8bff9b65411d5ff1dfb9fbc5f03a28ffdc88d596.tar.bz2 |
Refactor: Make struct pppcp declaration private
-rw-r--r-- | gatchat/ppp_cp.c | 43 | ||||
-rw-r--r-- | gatchat/ppp_cp.h | 28 | ||||
-rw-r--r-- | gatchat/ppp_ipcp.c | 5 | ||||
-rw-r--r-- | gatchat/ppp_lcp.c | 5 |
4 files changed, 39 insertions, 42 deletions
diff --git a/gatchat/ppp_cp.c b/gatchat/ppp_cp.c index 7eac46fe..eb447a63 100644 --- a/gatchat/ppp_cp.c +++ b/gatchat/ppp_cp.c @@ -154,6 +154,31 @@ enum pppcp_event_type { RXR = 15, }; +struct pppcp_data { + unsigned char state; + struct pppcp_timer_data config_timer_data; + struct pppcp_timer_data terminate_timer_data; + guint max_failure; + guint failure_counter; + guint32 magic_number; + GList *config_options; + GList *acceptable_options; + GList *unacceptable_options; + GList *rejected_options; + GList *applied_options; + GAtPPP *ppp; + guint8 identifier; /* don't think I need this now */ + guint8 config_identifier; + guint8 terminate_identifier; + guint8 reject_identifier; + const struct pppcp_action *action; + guint16 valid_codes; + gpointer priv; + guint16 proto; + const char *prefix; + const char **option_strings; +}; + static void pppcp_generate_event(struct pppcp_data *data, enum pppcp_event_type event_type, guint8 *packet, guint len); @@ -233,7 +258,7 @@ static void pppcp_illegal_event(guint8 state, guint8 type) static void pppcp_this_layer_up(struct pppcp_data *data) { - struct pppcp_action *action = data->action; + const struct pppcp_action *action = data->action; if (action->this_layer_up) action->this_layer_up(data); @@ -241,7 +266,7 @@ static void pppcp_this_layer_up(struct pppcp_data *data) static void pppcp_this_layer_down(struct pppcp_data *data) { - struct pppcp_action *action = data->action; + const struct pppcp_action *action = data->action; if (action->this_layer_down) action->this_layer_down(data); @@ -249,7 +274,7 @@ static void pppcp_this_layer_down(struct pppcp_data *data) static void pppcp_this_layer_started(struct pppcp_data *data) { - struct pppcp_action *action = data->action; + const struct pppcp_action *action = data->action; if (action->this_layer_started) action->this_layer_started(data); @@ -257,7 +282,7 @@ static void pppcp_this_layer_started(struct pppcp_data *data) static void pppcp_this_layer_finished(struct pppcp_data *data) { - struct pppcp_action *action = data->action; + const struct pppcp_action *action = data->action; pppcp_trace(data); if (action->this_layer_finished) @@ -847,7 +872,7 @@ static guint8 pppcp_process_configure_request(struct pppcp_data *data, int i = 0; struct ppp_option *option; enum option_rval rval; - struct pppcp_action *action = data->action; + const struct pppcp_action *action = data->action; pppcp_trace(data); @@ -924,7 +949,7 @@ static guint8 pppcp_process_configure_ack(struct pppcp_data *data, GList *list; struct ppp_option *acked_option; guint i = 0; - struct pppcp_action *action = data->action; + const struct pppcp_action *action = data->action; pppcp_trace(data); @@ -984,7 +1009,7 @@ static guint8 pppcp_process_configure_nak(struct pppcp_data *data, struct ppp_option *config_option; guint i = 0; enum option_rval rval; - struct pppcp_action *action = data->action; + const struct pppcp_action *action = data->action; pppcp_trace(data); @@ -1309,7 +1334,8 @@ guint32 pppcp_get_magic_number(struct pppcp_data *pppcp) return pppcp->magic_number; } -struct pppcp_data *pppcp_new(GAtPPP *ppp, guint16 proto) +struct pppcp_data *pppcp_new(GAtPPP *ppp, guint16 proto, + const struct pppcp_action *action) { struct pppcp_data *data; @@ -1329,6 +1355,7 @@ struct pppcp_data *pppcp_new(GAtPPP *ppp, guint16 proto) data->ppp = ppp; data->proto = proto; + data->action = action; return data; } diff --git a/gatchat/ppp_cp.h b/gatchat/ppp_cp.h index f1a590f4..bbb81844 100644 --- a/gatchat/ppp_cp.h +++ b/gatchat/ppp_cp.h @@ -75,32 +75,8 @@ struct pppcp_timer_data { guint restart_timer; }; -struct pppcp_data { - unsigned char state; - struct pppcp_timer_data config_timer_data; - struct pppcp_timer_data terminate_timer_data; - guint max_failure; - guint failure_counter; - guint32 magic_number; - GList *config_options; - GList *acceptable_options; - GList *unacceptable_options; - GList *rejected_options; - GList *applied_options; - GAtPPP *ppp; - guint8 identifier; /* don't think I need this now */ - guint8 config_identifier; - guint8 terminate_identifier; - guint8 reject_identifier; - struct pppcp_action *action; - guint16 valid_codes; - gpointer priv; - guint16 proto; - const char *prefix; - const char **option_strings; -}; - -struct pppcp_data *pppcp_new(GAtPPP *ppp, guint16 proto); +struct pppcp_data *pppcp_new(GAtPPP *ppp, guint16 proto, + const struct pppcp_action *action); void pppcp_free(struct pppcp_data *data); void pppcp_set_data(struct pppcp_data *pppcp, gpointer data); diff --git a/gatchat/ppp_ipcp.c b/gatchat/ppp_ipcp.c index fc5b33d7..cb52f2fc 100644 --- a/gatchat/ppp_ipcp.c +++ b/gatchat/ppp_ipcp.c @@ -188,7 +188,7 @@ struct pppcp_data *ipcp_new(GAtPPP *ppp) if (!data) return NULL; - pppcp = pppcp_new(ppp, IPCP_PROTO); + pppcp = pppcp_new(ppp, IPCP_PROTO, &ipcp_action); if (!pppcp) { g_printerr("Failed to allocate PPPCP struct\n"); g_free(data); @@ -201,9 +201,6 @@ struct pppcp_data *ipcp_new(GAtPPP *ppp) pppcp_set_valid_codes(pppcp, IPCP_SUPPORTED_CODES); pppcp_set_data(pppcp, data); - /* set the actions */ - pppcp->action = &ipcp_action; - /* add the default config options */ ipcp_option = g_try_malloc0(6); if (!ipcp_option) { diff --git a/gatchat/ppp_lcp.c b/gatchat/ppp_lcp.c index 090e290c..81182ba1 100644 --- a/gatchat/ppp_lcp.c +++ b/gatchat/ppp_lcp.c @@ -224,7 +224,7 @@ struct pppcp_data *lcp_new(GAtPPP *ppp) struct pppcp_data *pppcp; struct ppp_option *option; - pppcp = pppcp_new(ppp, LCP_PROTOCOL); + pppcp = pppcp_new(ppp, LCP_PROTOCOL, &lcp_action); if (!pppcp) { g_print("Failed to allocate PPPCP struct\n"); return NULL; @@ -235,9 +235,6 @@ struct pppcp_data *lcp_new(GAtPPP *ppp) pppcp_set_valid_codes(pppcp, LCP_SUPPORTED_CODES); - /* set the actions */ - pppcp->action = &lcp_action; - /* add the default config options */ option = g_try_malloc0(6); if (option == NULL) { |