[PATCH 0/5] Prototype to handle asynchronized callback
Hi, These patches are the prototype to handle the asynchronized callback for AtServer. During the callback function execution period, GAtServer waits for its result and then process next command. At the same time, the server is capable to accept new data comes from the client side and cache them in the read buffer. Please review them. Any comments are welcome! In-Reply-To: ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH 4/5] Add register S3-S5 basic command callbacks
--- gatchat/gatserver.c | 162 +++ 1 files changed, 162 insertions(+), 0 deletions(-) diff --git a/gatchat/gatserver.c b/gatchat/gatserver.c index 5d2a036..9d4d221 100644 --- a/gatchat/gatserver.c +++ b/gatchat/gatserver.c @@ -294,6 +294,159 @@ void g_at_server_send_info_text(GAtServer *server, GSList *text) send_common(server, buf, len); } +static gboolean get_result_value(GAtServer *server, GAtResult *result, + const char *command, + int min, int max, int *value) +{ + GAtResultIter iter; + int val; + char prefix[10]; + + if (command[0] != 'S') + return FALSE; + + sprintf(prefix, %s=, command); + + g_at_result_iter_init(iter, result); + + if (!g_at_result_iter_next(iter, prefix)) + return FALSE; + + if (!g_at_result_iter_next_number(iter, val)) + return FALSE; + + if (val min || val max) + return FALSE; + + *value = val; + + return TRUE; +} + +static void send_info_text(GAtServer *server, char *buf) +{ + GSList *text = NULL; + + text = g_slist_append(NULL, buf); + g_at_server_send_info_text(server, text); + g_slist_free(text); +} + +static void set_s_value(GAtServer *server, const char *prefix, int val) +{ + char c = prefix[1]; + + switch (c) { + case '3': + server-v250.s3 = val; + break; + + case '4': + server-v250.s4 = val; + break; + + case '5': + server-v250.s5 = val; + break; + + default: + break; + } +} + +static int get_s_value(GAtServer *server, const char *prefix) +{ + char c = prefix[1]; + int val = 0; + + switch (c) { + case '3': + val = server-v250.s3; + break; + + case '4': + val = server-v250.s4; + break; + + case '5': + val = server-v250.s5; + break; + + default: + break; + } + + return val; +} + +static void s_template_cb(GAtServerRequestType type, + GAtResult *result, gpointer user_data, + const char *prefix, + int min, int max, + GAtServerNotifyCallback cb, + gpointer cb_data) +{ + GAtServerResult res = G_AT_SERVER_RESULT_ERROR; + GAtServer *server = user_data; + char buf[20]; + int val; + + switch (type) { + case G_AT_SERVER_REQUEST_TYPE_SET: + if (!get_result_value(server, result, prefix, min, max, val)) + goto done; + + set_s_value(server, prefix, val); + res = G_AT_SERVER_RESULT_OK; + break; + + case G_AT_SERVER_REQUEST_TYPE_QUERY: + val = get_s_value(server, prefix); + sprintf(buf, %03d, val); + send_info_text(server, buf); + res = G_AT_SERVER_RESULT_OK; + break; + + case G_AT_SERVER_REQUEST_TYPE_SUPPORT: + sprintf(buf, %s: (%d-%d), prefix, min, max); + send_info_text(server, buf); + res = G_AT_SERVER_RESULT_OK; + break; + + default: + break; + } + +done: + g_at_server_send_final(server, res); + + cb(cb_data); +} + +static void at_s3_cb(GAtServerRequestType type, GAtResult *result, + gpointer user_data, + GAtServerNotifyCallback cb, + gpointer cb_data) +{ + s_template_cb(type, result, user_data, S3, 0, 127, cb, cb_data); +} + +static void at_s4_cb(GAtServerRequestType type, GAtResult *result, + gpointer user_data, + GAtServerNotifyCallback cb, + gpointer cb_data) +{ + s_template_cb(type, result, user_data, S4, 0, 127, cb, cb_data); +} + +static void at_s5_cb(GAtServerRequestType type, GAtResult *result, + gpointer user_data, + GAtServerNotifyCallback cb, + gpointer cb_data) +{ + s_template_cb(type, result, user_data, S5, 0, 127, cb, cb_data); +} + static inline gboolean is_extended_command_prefix(const char c) { switch (c) { @@ -1008,6 +1161,13 @@ static void at_notify_node_destroy(gpointer data) g_free(node); } +static void basic_command_register(GAtServer *server) +{ + g_at_server_register(server, S3, at_s3_cb, server, NULL); +
Re: [PATCH 0/4] add PPP_DEAD and PPP_TERMINATE support
Hi Kristen, These patches complete implementation of the PPP_DEAD and PPP_TERMINATE phases, as well as allow this to be tested via gsmdial. Kristen Carlson Accardi (4): remove unneeded debug statement add tracing for PPP terminate path separate memory cleanup from PPP shutdown gsmdial: shutdown ppp link if we have one. gatchat/gatppp.c | 25 +++-- gatchat/gsmdial.c |4 +++- gatchat/ppp.c | 27 +++ gatchat/ppp_cp.c | 10 ++ 4 files changed, 43 insertions(+), 23 deletions(-) all four patches have been applied. Thanks. Regards Marcel ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH 5/5] Add register ATE and other basic command callbacks
--- gatchat/gatserver.c | 195 +- 1 files changed, 191 insertions(+), 4 deletions(-) diff --git a/gatchat/gatserver.c b/gatchat/gatserver.c index 9d4d221..06b5751 100644 --- a/gatchat/gatserver.c +++ b/gatchat/gatserver.c @@ -302,10 +302,10 @@ static gboolean get_result_value(GAtServer *server, GAtResult *result, int val; char prefix[10]; - if (command[0] != 'S') - return FALSE; - - sprintf(prefix, %s=, command); + if (command[0] == 'S') + sprintf(prefix, %s=, command); + else + strcpy(prefix, command); g_at_result_iter_init(iter, result); @@ -447,6 +447,187 @@ static void at_s5_cb(GAtServerRequestType type, GAtResult *result, s_template_cb(type, result, user_data, S5, 0, 127, cb, cb_data); } +static void set_v250_value(GAtServer *server, const char *prefix, int val) +{ + char c = prefix[0]; + + if (c == '') { + c = prefix[1]; + switch (c) { + case 'C': + server-v250.c109 = val; + break; + + case 'D': + server-v250.c108 = val; + break; + default: + break; + } + } else { + switch (c) { + case 'E': + server-v250.echo = val; + break; + + case 'Q': + server-v250.quiet = val; + break; + + case 'V': + server-v250.is_v1 = val; + break; + + case 'X': + server-v250.res_format = val; + break; + } + } +} + +static int get_v250_value(GAtServer *server, const char *prefix) +{ + char c = prefix[0]; + int val = 0; + + if (c == '') { + c = prefix[1]; + + switch (c) { + case 'C': + val = server-v250.c109; + break; + + case 'D': + val = server-v250.c108; + break; + + default: + break; + } + } else { + switch (c) { + case 'E': + val = server-v250.echo; + break; + + case 'Q': + val = server-v250.quiet; + break; + + case 'V': + val = server-v250.is_v1; + break; + + case 'X': + val = server-v250.res_format; + break; + + default: + break; + } + } + + return val; +} + +static void at_template_cb(GAtServerRequestType type, + GAtResult *result, gpointer user_data, + const char *prefix, + int min, int max, int deftval, + GAtServerNotifyCallback cb, + gpointer cb_data) +{ + GAtServerResult res = G_AT_SERVER_RESULT_ERROR; + GAtServer *server = user_data; + char buf[20]; + int val; + + switch (type) { + case G_AT_SERVER_REQUEST_TYPE_SET: + if (!get_result_value(server, result, prefix, min, max, val)) + goto done; + + set_v250_value(server, prefix, val); + res = G_AT_SERVER_RESULT_OK; + break; + + case G_AT_SERVER_REQUEST_TYPE_QUERY: + val = get_v250_value(server, prefix); + sprintf(buf, %s: %d, prefix, val); + send_info_text(server, buf); + res = G_AT_SERVER_RESULT_OK; + break; + + case G_AT_SERVER_REQUEST_TYPE_SUPPORT: + sprintf(buf, %s: (%d-%d), prefix, min, max); + send_info_text(server, buf); + res = G_AT_SERVER_RESULT_OK; + break; + + case G_AT_SERVER_REQUEST_TYPE_COMMAND_ONLY: + set_v250_value(server, prefix, deftval); + res = G_AT_SERVER_RESULT_OK; + break; + + default: + break; + } + +done: + g_at_server_send_final(server, res); + + cb(cb_data); +} + +static void at_e_cb(GAtServerRequestType type, GAtResult *result, + gpointer user_data, + GAtServerNotifyCallback cb, + gpointer cb_data) +{ + at_template_cb(type, result, user_data, E, 0, 1, 1, cb, cb_data); +} + +static void at_q_cb(GAtServerRequestType type, GAtResult *result, +
[PATCH 1/7] Unify some macro names of ber-tlv and comprehension tlv
--- src/stkutil.h |8 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/stkutil.h b/src/stkutil.h index e66b4c0..23c6a3f 100644 --- a/src/stkutil.h +++ b/src/stkutil.h @@ -54,7 +54,7 @@ enum stk_command_type { STK_COMMAND_TYPE_GET_INPUT =0x23, STK_COMMAND_TYPE_SELECT_ITEM = 0x24, STK_COMMAND_TYPE_SETUP_MENU = 0x25, - STK_COMMAND_TYPE_PROVIDE_LOCAL_INFORMATION =0x26, + STK_COMMAND_TYPE_PROVIDE_LOCAL_INFO = 0x26, STK_COMMAND_TYPE_TIMER_MANAGEMENT = 0x27, STK_COMMAND_TYPE_SETUP_IDLE_MODE_TEXT = 0x28, STK_COMMAND_TYPE_PERFORM_CARD_APDU =0x30, @@ -69,7 +69,7 @@ enum stk_command_type { STK_COMMAND_TYPE_SEND_DATA =0x43, STK_COMMAND_TYPE_GET_CHANNEL_STATUS = 0x44, STK_COMMAND_TYPE_SERVICE_SEARCH = 0x45, - STK_COMMAND_TYPE_GET_SERVICE_INFORMATION = 0x46, + STK_COMMAND_TYPE_GET_SERVICE_INFO = 0x46, STK_COMMAND_TYPE_DECLARE_SERVICE = 0x47, STK_COMMAND_TYPE_SET_FRAMES = 0x50, STK_COMMAND_TYPE_GET_FRAMES_STATUS =0x51, @@ -131,7 +131,7 @@ enum stk_data_object_type { STK_DATA_OBJECT_TYPE_BROWSER_ID = 0x30, STK_DATA_OBJECT_TYPE_URL = 0x31, STK_DATA_OBJECT_TYPE_BEARER = 0x32, - STK_DATA_OBJECT_TYPE_PROVISIONING_REFERENCE_FILE = 0x33, + STK_DATA_OBJECT_TYPE_PROVISIONING_FILE_REFERENCE = 0x33, STK_DATA_OBJECT_TYPE_BROWSER_TERMINATION_CAUSE =0x34, STK_DATA_OBJECT_TYPE_BEARER_DESCRIPTION = 0x35, STK_DATA_OBJECT_TYPE_CHANNEL_DATA = 0x36, @@ -167,7 +167,7 @@ enum stk_data_object_type { STK_DATA_OBJECT_TYPE_MMS_ID = 0x6B, STK_DATA_OBJECT_TYPE_MMS_TRANSFER_STATUS = 0x6C, STK_DATA_OBJECT_TYPE_MEID = 0x6D, - STK_DATA_OBJECT_TYPE_CONTENT_ID = 0x6E, + STK_DATA_OBJECT_TYPE_MMS_CONTENT_ID = 0x6E, STK_DATA_OBJECT_TYPE_MMS_NOTIFICATION = 0x6F, STK_DATA_OBJECT_TYPE_LAST_ENVELOPE =0x70, STK_DATA_OBJECT_TYPE_REGISTRY_APPLICATION_DATA =0x71, -- 1.6.3.3 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH 2/7] Make the function to parse mcc and mnc public
--- src/simutil.c |6 +++--- src/simutil.h |1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/simutil.c b/src/simutil.c index d9383b7..9fb111f 100644 --- a/src/simutil.c +++ b/src/simutil.c @@ -538,7 +538,7 @@ static char *sim_network_name_parse(const unsigned char *buffer, int length, return ret; } -static void parse_mcc_mnc(const guint8 *bcd, char *mcc, char *mnc) +void sim_parse_mcc_mnc(const guint8 *bcd, char *mcc, char *mnc) { static const char digit_lut[] = 0123456789*#abd\0; guint8 digit; @@ -609,7 +609,7 @@ struct sim_spdi *sim_spdi_new(const guint8 *tlv, int length) oper = g_new0(struct spdi_operator, 1); - parse_mcc_mnc(plmn_list, oper-mcc, oper-mnc); + sim_parse_mcc_mnc(plmn_list, oper-mcc, oper-mnc); spdi-operators = g_slist_insert_sorted(spdi-operators, oper, spdi_operator_compare); } @@ -694,7 +694,7 @@ static struct opl_operator *opl_operator_alloc(const guint8 *record) { struct opl_operator *oper = g_new0(struct opl_operator, 1); - parse_mcc_mnc(record, oper-mcc, oper-mnc); + sim_parse_mcc_mnc(record, oper-mcc, oper-mnc); record += 3; oper-lac_tac_low = (record[0] 8) | record[1]; diff --git a/src/simutil.h b/src/simutil.h index 043c21f..7590cca 100644 --- a/src/simutil.h +++ b/src/simutil.h @@ -181,6 +181,7 @@ const struct sim_eons_operator_info *sim_eons_lookup(struct sim_eons *eons, const char *mnc); void sim_eons_free(struct sim_eons *eons); +void sim_parse_mcc_mnc(const guint8 *bcd, char *mcc, char *mnc); struct sim_spdi *sim_spdi_new(const guint8 *tlv, int length); gboolean sim_spdi_lookup(struct sim_spdi *spdi, const char *mcc, const char *mnc); -- 1.6.3.3 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH 6/7] Use common bool parser to reimplement immediate response object
--- src/stkutil.c | 14 ++ 1 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/stkutil.c b/src/stkutil.c index ecf1301..4e42ae4 100644 --- a/src/stkutil.c +++ b/src/stkutil.c @@ -637,18 +637,8 @@ static gboolean parse_dataobj_icon_id(struct comprehension_tlv_iter *iter, static gboolean parse_dataobj_imm_resp(struct comprehension_tlv_iter *iter, void *user) { - gboolean *resp = user; - - if (comprehension_tlv_iter_get_tag(iter) != - STK_DATA_OBJECT_TYPE_IMMEDIATE_RESPONSE) - return FALSE; - - if (comprehension_tlv_iter_get_length(iter) != 0) - return FALSE; - - *resp = TRUE; - - return TRUE; + return parse_dataobj_common_bool(iter, user, + STK_DATA_OBJECT_TYPE_IMMEDIATE_RESPONSE); } /* Defined in TS 102.223 Section 8.72 */ -- 1.6.3.3 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH 7/7] Add parser for help request objects
--- src/stkutil.c | 10 ++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/src/stkutil.c b/src/stkutil.c index 4e42ae4..9a91a25 100644 --- a/src/stkutil.c +++ b/src/stkutil.c @@ -611,6 +611,14 @@ static gboolean parse_dataobj_imei(struct comprehension_tlv_iter *iter, return TRUE; } +/* Defined in TS 102.223 Section 8.21 */ +static gboolean parse_dataobj_help_request(struct comprehension_tlv_iter *iter, + void *user) +{ + return parse_dataobj_common_bool(iter, user, + STK_DATA_OBJECT_TYPE_HELP_REQUEST); +} + /* Defined in TS 102.223 Section 8.31 */ static gboolean parse_dataobj_icon_id(struct comprehension_tlv_iter *iter, void *user) @@ -724,6 +732,8 @@ static dataobj_handler handler_for_type(enum stk_data_object_type type) return parse_dataobj_location_info; case STK_DATA_OBJECT_TYPE_IMEI: return parse_dataobj_imei; + case STK_DATA_OBJECT_TYPE_HELP_REQUEST: + return parse_dataobj_help_request; case STK_DATA_OBJECT_TYPE_ICON_ID: return parse_dataobj_icon_id; case STK_DATA_OBJECT_TYPE_IMMEDIATE_RESPONSE: -- 1.6.3.3 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH 3/7] Add parser for location information objects
--- src/stkutil.c | 36 src/stkutil.h | 11 +++ 2 files changed, 47 insertions(+), 0 deletions(-) diff --git a/src/stkutil.c b/src/stkutil.c index 9c83f49..d67c5c4 100644 --- a/src/stkutil.c +++ b/src/stkutil.c @@ -519,6 +519,40 @@ error: return FALSE; } +/* Defined in TS 102.223 Section 8.19 */ +static gboolean parse_dataobj_location_info( + struct comprehension_tlv_iter *iter, void *user) +{ + struct stk_location_info *li = user; + const unsigned char *data; + unsigned int len; + + if (comprehension_tlv_iter_get_tag(iter) != + STK_DATA_OBJECT_TYPE_LOCATION_INFO) + return FALSE; + + len = comprehension_tlv_iter_get_length(iter); + if ((len != 5) (len != 7) (len != 9)) + return FALSE; + + data = comprehension_tlv_iter_get_data(iter); + + sim_parse_mcc_mnc(data, li-mcc, li-mnc); + li-lac_tac = (data[3] 8) + data[4]; + + if (len = 7) { + li-has_ci = TRUE; + li-ci = (data[5] 8) + data[6]; + } + + if (len == 9) { + li-has_ext_ci = TRUE; + li-ext_ci = (data[7] 8) + data[8]; + } + + return TRUE; +} + /* Defined in TS 102.223 Section 8.31 */ static gboolean parse_dataobj_icon_id(struct comprehension_tlv_iter *iter, void *user) @@ -638,6 +672,8 @@ static dataobj_handler handler_for_type(enum stk_data_object_type type) return parse_dataobj_tone; case STK_DATA_OBJECT_TYPE_FILE_LIST: return parse_dataobj_file_list; + case STK_DATA_OBJECT_TYPE_LOCATION_INFO: + return parse_dataobj_location_info; case STK_DATA_OBJECT_TYPE_ICON_ID: return parse_dataobj_icon_id; case STK_DATA_OBJECT_TYPE_IMMEDIATE_RESPONSE: diff --git a/src/stkutil.h b/src/stkutil.h index 23c6a3f..a9495de 100644 --- a/src/stkutil.h +++ b/src/stkutil.h @@ -347,6 +347,17 @@ struct stk_result { unsigned char *additional; }; +/* Defined in TS 102.223 Section 8.19 */ +struct stk_location_info { + char mnc[OFONO_MAX_MNC_LENGTH + 1]; + char mcc[OFONO_MAX_MCC_LENGTH + 1]; + unsigned short lac_tac; + ofono_bool_t has_ci; + unsigned short ci; + ofono_bool_t has_ext_ci; + unsigned short ext_ci; +}; + /* Define the struct of single file in TS102.223 Section 8.18. * According to TS 11.11 Section 6.2, each file id has two bytes, and the * maximum Dedicated File level is 2. So the maximum size of file is 8, which -- 1.6.3.3 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [PATCH 1/7] Unify some macro names of ber-tlv and comprehension tlv
Hi Yang, --- src/stkutil.h |8 1 files changed, 4 insertions(+), 4 deletions(-) Patch has been applied, thanks. Regards, -Denis ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [PATCH 2/7] Make the function to parse mcc and mnc public
Hi Yang, --- src/simutil.c |6 +++--- src/simutil.h |1 + 2 files changed, 4 insertions(+), 3 deletions(-) Patch has been applied, thanks. Regards, -Denis ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [PATCH 3/7] Add parser for location information objects
Hi Yang, --- src/stkutil.c | 36 src/stkutil.h | 11 +++ 2 files changed, 47 insertions(+), 0 deletions(-) Patch has been applied, thanks. Regards, -Denis ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [PATCH 4/7] Add parser for imei objects
Hi Yang, --- src/stkutil.c | 43 +++ 1 files changed, 43 insertions(+), 0 deletions(-) Patch has been applied, with a small fix afterwards. Thanks. Regards, -Denis ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [PATCH 6/7] Use common bool parser to reimplement immediate response object
Hi Yang, --- src/stkutil.c | 14 ++ 1 files changed, 2 insertions(+), 12 deletions(-) Patch has been applied, thanks. Regards, -Denis ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [PATCH 7/7] Add parser for help request objects
Hi Yang, --- src/stkutil.c | 10 ++ 1 files changed, 10 insertions(+), 0 deletions(-) Patch has been applied, thanks. Regards, -Denis ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [PATCH 1/5] Refactor the command parsing framework
Hi Zhenhua, --- gatchat/gatserver.c | 182 +++--- gatchat/gatserver.h | 7 ++- 2 files changed, 133 insertions(+), 56 deletions(-) - at_command_notify(server, buf, prefix, type); + notify = at_node_new(server, buf, prefix, type); + if (!notify) + goto error; /* Also consume the terminating null */ - return i + 1; + server-read_pos += i + 1; + server-notify_source = g_idle_add_full(G_PRIORITY_DEFAULT, + at_command_notify, + notify, g_free); + + return; + +error: + g_free(notify); + + g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR); } Err, OK stop right there. This is really way too complicated. How about we simply set a flag before calling at_command_notify. If after executing it send_final or send_ext_final response has been sent, then we continue processing, otherwise we restart when send_ext_final or send_final will be called again. You really don't need to touch this function at all. +typedef void (*GAtServerNotifyCallback)(gpointer user_data); + Get rid of this, not necessary. typedef void (*GAtServerNotifyFunc)(GAtServerRequestType type, - GAtResult *result, gpointer user_data); + GAtResult *result, + gpointer user_data, + GAtServerNotifyCallback cb, + gpointer cb_data); Keep the NotifyFunc the way it is, your changes are really not required. Regards, -Denis ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH] ppp: change debug output to include control protocol prefix
--- gatchat/ppp_cp.c | 12 ++-- gatchat/ppp_cp.h | 10 +- gatchat/ppp_lcp.c | 12 ++-- gatchat/ppp_net.c | 12 ++-- 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/gatchat/ppp_cp.c b/gatchat/ppp_cp.c index 75b3bec..137f6b9 100644 --- a/gatchat/ppp_cp.c +++ b/gatchat/ppp_cp.c @@ -40,7 +40,7 @@ static const char *pppcp_state_strings[] = REQSENT, ACKRCVD, ACKSENT, OPENED }; #define pppcp_trace(p) do { \ - g_print(%s: current state %d:%s\n, __FUNCTION__, \ + g_print(%s: %s: current state %d:%s\n, p-prefix, __FUNCTION__, \ p-state, pppcp_state_strings[p-state]); \ } while (0) #else @@ -1483,8 +1483,7 @@ void pppcp_free(struct pppcp_data *data) g_free(data); } -struct pppcp_data *pppcp_new(GAtPPP *ppp, guint16 proto, - gpointer priv) +struct pppcp_data *pppcp_new(struct pppcp_protocol_data *protocol_data) { struct pppcp_data *data; @@ -1502,9 +1501,10 @@ struct pppcp_data *pppcp_new(GAtPPP *ppp, guint16 proto, data-max_failure = MAX_FAILURE; data-event_queue = g_queue_new(); data-identifier = 0; - data-ppp = ppp; - data-proto = proto; - data-priv = priv; + data-ppp = protocol_data-ppp; + data-proto = protocol_data-proto; + data-priv = protocol_data-priv; + data-prefix = protocol_data-prefix; /* setup func ptrs for processing packet by pppcp code */ data-packet_ops[CONFIGURE_REQUEST - 1] = diff --git a/gatchat/ppp_cp.h b/gatchat/ppp_cp.h index 095a8b5..69676cd 100644 --- a/gatchat/ppp_cp.h +++ b/gatchat/ppp_cp.h @@ -106,6 +106,13 @@ struct pppcp_timer_data { guint restart_timer; }; +struct pppcp_protocol_data { + guint16 proto; + const char *prefix; + gpointer priv; + GAtPPP *ppp; +}; + struct pppcp_data { enum pppcp_state state; struct pppcp_timer_data config_timer_data; @@ -131,9 +138,10 @@ struct pppcp_data { guint length); gpointer priv; guint16 proto; + const char *prefix; }; -struct pppcp_data *pppcp_new(GAtPPP *ppp, guint16 proto, gpointer priv); +struct pppcp_data *pppcp_new(struct pppcp_protocol_data *proto_data); void pppcp_free(struct pppcp_data *data); void pppcp_add_config_option(struct pppcp_data *data, struct ppp_option *option); diff --git a/gatchat/ppp_lcp.c b/gatchat/ppp_lcp.c index 0892b2c..7206b4b 100644 --- a/gatchat/ppp_lcp.c +++ b/gatchat/ppp_lcp.c @@ -153,6 +153,13 @@ static void lcp_option_process(gpointer data, gpointer user) } } +static const char lcp_prefix[] = lcp; + +static struct pppcp_protocol_data lcp_protocol_data = { + .proto = LCP_PROTOCOL, + .prefix = lcp_prefix, +}; + struct ppp_packet_handler lcp_packet_handler = { .proto = LCP_PROTOCOL, .handler = pppcp_process_packet, @@ -213,13 +220,14 @@ void lcp_free(struct pppcp_data *lcp) pppcp_free(lcp); } -struct pppcp_data * lcp_new(GAtPPP *ppp) +struct pppcp_data *lcp_new(GAtPPP *ppp) { struct pppcp_data *pppcp; struct ppp_option *option; guint16 codes = LCP_SUPPORTED_CODES; - pppcp = pppcp_new(ppp, LCP_PROTOCOL, NULL); + lcp_protocol_data.ppp = ppp; + pppcp = pppcp_new(lcp_protocol_data); if (!pppcp) { g_print(Failed to allocate PPPCP struct\n); return NULL; diff --git a/gatchat/ppp_net.c b/gatchat/ppp_net.c index a873c00..d8df896 100644 --- a/gatchat/ppp_net.c +++ b/gatchat/ppp_net.c @@ -249,6 +249,8 @@ static void ipcp_finished(struct pppcp_data *data) g_print(ipcp finished\n); } +static const char ipcp_prefix[] = ipcp; + struct pppcp_action ipcp_action = { .this_layer_up =ipcp_up, .this_layer_down = ipcp_down, @@ -258,6 +260,11 @@ struct pppcp_action ipcp_action = { .option_process = ipcp_option_process, }; +static struct pppcp_protocol_data ipcp_protocol_data = { + .proto = IPCP_PROTO, + .prefix = ipcp_prefix, +}; + struct ppp_packet_handler ipcp_packet_handler = { .proto = IPCP_PROTO, .handler = pppcp_process_packet, @@ -326,14 +333,15 @@ static struct pppcp_data * ipcp_new(GAtPPP *ppp) if (!data) return NULL; - pppcp = pppcp_new(ppp, IPCP_PROTO, data); + ipcp_protocol_data.ppp = ppp; + ipcp_protocol_data.priv = data; + pppcp = pppcp_new(ipcp_protocol_data); if (!pppcp) { g_printerr(Failed to allocate PPPCP struct\n); g_free(data); return NULL; } pppcp_set_valid_codes(pppcp, IPCP_SUPPORTED_CODES); - pppcp-priv = data; /* set the actions */ pppcp-action = ipcp_action; -- 1.6.6.1 ___ ofono mailing list ofono@ofono.org
Re: [PATCH] ppp: change debug output to include control protocol prefix
Hi Kristen, gatchat/ppp_cp.c | 12 ++-- gatchat/ppp_cp.h | 10 +- gatchat/ppp_lcp.c | 12 ++-- gatchat/ppp_net.c | 12 ++-- 4 files changed, 35 insertions(+), 11 deletions(-) patch has been applied. Thanks. Regards Marcel ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH 1/2] ppp: allow empty secret for chap challenge
Just do a checksum over the identifier if we have an empty password for our chap secret. --- gatchat/ppp_auth.c |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/gatchat/ppp_auth.c b/gatchat/ppp_auth.c index 6c3913e..95b2f96 100644 --- a/gatchat/ppp_auth.c +++ b/gatchat/ppp_auth.c @@ -83,7 +83,8 @@ static void chap_process_challenge(struct auth_data *auth, guint8 *packet) if (!checksum) return; g_checksum_update(checksum, header-identifier, 1); - g_checksum_update(checksum, (guchar *) secret, strlen(secret)); + if (secret) + g_checksum_update(checksum, (guchar *) secret, strlen(secret)); g_checksum_update(checksum, header-data[1], header-data[0]); /* transmit a response packet */ -- 1.6.6.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
[PATCH 2/2] ppp: send PPP_FAIL when authentication fails
--- gatchat/ppp_auth.c |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/gatchat/ppp_auth.c b/gatchat/ppp_auth.c index 95b2f96..fe3c501 100644 --- a/gatchat/ppp_auth.c +++ b/gatchat/ppp_auth.c @@ -128,7 +128,8 @@ static void chap_process_failure(struct auth_data *data, guint8 *packet) { struct chap_header *header = (struct chap_header *) packet; - g_print(Failed to authenticate, message %s\n, header-data); + ppp_generate_event(data-ppp, PPP_FAIL); + g_printerr(Failed to authenticate, message %s\n, header-data); } /* -- 1.6.6.1 ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
RE: [PATCH 1/5] Refactor the command parsing framework
Hi Denis, Denis Kenzior wrote: Hi Zhenhua, --- gatchat/gatserver.c | 182 +++--- gatchat/gatserver.h | 7 ++- 2 files changed, 133 insertions(+), 56 deletions(-) -at_command_notify(server, buf, prefix, type); +notify = at_node_new(server, buf, prefix, type); +if (!notify) +goto error; /* Also consume the terminating null */ -return i + 1; +server-read_pos += i + 1; +server-notify_source = g_idle_add_full(G_PRIORITY_DEFAULT, +at_command_notify, + notify, g_free); + +return; + +error: +g_free(notify); + +g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR); } Err, OK stop right there. This is really way too complicated. How about we simply set a flag before calling at_command_notify. If after executing it send_final or send_ext_final response has been sent, then we continue processing, otherwise we restart when send_ext_final or send_final will be called again. You really don't need to touch this function at all. OK. So the problem is if the at_command_notify is blocked by user callback, the mainloop won't have chance to read data in from non-blocking I/O I guess. That's the reason I added this. If we don't need to handle such case, then the logic could be much simplier. We could discuss it on IRC. +typedef void (*GAtServerNotifyCallback)(gpointer user_data); + Get rid of this, not necessary. typedef void (*GAtServerNotifyFunc)(GAtServerRequestType type, -GAtResult *result, gpointer user_data); +GAtResult *result, +gpointer user_data, +GAtServerNotifyCallback cb, +gpointer cb_data); Keep the NotifyFunc the way it is, your changes are really not required. Regards, -Denis ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono Regards, Zhenhua ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [PATCH 1/5] Refactor the command parsing framework
Hi Zhenhua Err, OK stop right there. This is really way too complicated. How about we simply set a flag before calling at_command_notify. If after executing it send_final or send_ext_final response has been sent, then we continue processing, otherwise we restart when send_ext_final or send_final will be called again. You really don't need to touch this function at all. OK. So the problem is if the at_command_notify is blocked by user callback, the mainloop won't have chance to read data in from non-blocking I/O I guess. That's the reason I added this. If we don't need to handle such case, then the logic could be much simplier. We could discuss it on IRC. So what you want to assume here is that for long running operations the callback with schedule its own g_sources and will eventually call send_final. This works because the server can only have one outstanding command at a time. You don't need to worry about blocking semantics here (they just work) and we won't consider re-entrant event loops for now. Regards, -Denis ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono