huawei: handle optional 0x prefix on hex numbers in ^DHCP response

On Huawei ME936, the hex numbers in the response to AT^DHCP contain the 0x prefix, e.g.

  AT^DHCP?

  ^DHCP: 0xda7d0e0a,0xff000000,0xdb7d0e0a,0xdb7d0e0a,0x01261aac,0x00000000,100000000,50000000

This patch updates mm_huawei_parse_dhcp_response() to handle the
optional 0x prefix.
This commit is contained in:
Ben Chan
2018-01-26 14:25:56 -08:00
committed by Dan Williams
parent 90b89bb9f4
commit 456e1e0d0c
2 changed files with 7 additions and 1 deletions

View File

@@ -230,7 +230,7 @@ mm_huawei_parse_dhcp_response (const char *reply,
* actually 10.10.1.1.
*/
r = g_regex_new ("\\^DHCP:\\s*([0-9a-fA-F]+),([0-9a-fA-F]+),([0-9a-fA-F]+),([0-9a-fA-F]+),([0-9a-fA-F]+),([0-9a-fA-F]+),.*$", 0, 0, NULL);
r = g_regex_new ("\\^DHCP:\\s*(?:0[xX])?([0-9a-fA-F]+),(?:0[xX])?([0-9a-fA-F]+),(?:0[xX])?([0-9a-fA-F]+),(?:0[xX])?([0-9a-fA-F]+),(?:0[xX])?([0-9a-fA-F]+),(?:0[xX])?([0-9a-fA-F]+),.*$", 0, 0, NULL);
g_assert (r != NULL);
matched = g_regex_match_full (r, reply, -1, 0, 0, &match_info, &match_error);

View File

@@ -154,10 +154,16 @@ typedef struct {
static const DhcpTest dhcp_tests[] = {
{ "^DHCP:a3ec5c64,f8ffffff,a1ec5c64,a1ec5c64,2200b10a,74bba80a,236800,236800\r\n",
"100.92.236.163", 29, "100.92.236.161", "10.177.0.34", "10.168.187.116" },
{ "^DHCP:0xa3ec5c64,0xf8ffffff,0xa1ec5c64,0xa1ec5c64,0x2200b10a,0x74bba80a,236800,236800\r\n",
"100.92.236.163", 29, "100.92.236.161", "10.177.0.34", "10.168.187.116" },
{ "^DHCP: 1010A0A,FCFFFFFF,2010A0A,2010A0A,0,0,150000000,150000000\r\n",
"10.10.1.1", 30, "10.10.1.2", "0.0.0.0", "0.0.0.0" },
{ "^DHCP: CCDB080A,F8FFFFFF,C9DB080A,C9DB080A,E67B59C0,E77B59C0,85600,85600\r\n",
"10.8.219.204", 29, "10.8.219.201", "192.89.123.230", "192.89.123.231" },
{ "^DHCP: 0xCCDB080A,0xF8FFFFFF,0xC9DB080A,0xC9DB080A,0xE67B59C0,0xE77B59C0,85600,85600\r\n",
"10.8.219.204", 29, "10.8.219.201", "192.89.123.230", "192.89.123.231" },
{ "^DHCP: 0XCCDB080A,0XF8FFFFFF,0XC9DB080A,0XC9DB080A,0XE67B59C0,0XE77B59C0,85600,85600\r\n",
"10.8.219.204", 29, "10.8.219.201", "192.89.123.230", "192.89.123.231" },
{ NULL }
};