[RESEND 3 PATCH 06/13] isimodem: IPv6 support
--- drivers/isimodem/gprs-context.c | 119 --- 1 files changed, 73 insertions(+), 46 deletions(-) diff --git a/drivers/isimodem/gprs-context.c b/drivers/isimodem/gprs-context.c index ad7abad..c386fef 100644 --- a/drivers/isimodem/gprs-context.c +++ b/drivers/isimodem/gprs-context.c @@ -62,10 +62,7 @@ struct context_data { uint16_t gpds; /* GPDS object handle */ unsigned cid; /* oFono core context ID */ struct ofono_gprs_context *context; - union { - ofono_gprs_context_up_cb_t up_cb; - ofono_gprs_context_cb_t down_cb; - }; + ofono_gprs_context_cb_t cb; void *data; GIsiPEP *pep; @@ -112,15 +109,14 @@ typedef void (*ContextFailFunc)(struct context_data *cd); static void gprs_up_fail(struct context_data *cd) { - CALLBACK_WITH_FAILURE(cd-up_cb, NULL, 0, NULL, NULL, NULL, NULL, - cd-data); reset_context(cd); + CALLBACK_WITH_FAILURE(cd-cb, cd-data); } static void gprs_down_fail(struct context_data *cd) { - CALLBACK_WITH_FAILURE(cd-down_cb, cd-data); reset_context(cd); + CALLBACK_WITH_FAILURE(cd-cb, cd-data); } static gboolean check_resp(const GIsiMessage *msg, uint8_t id, size_t minlen, @@ -206,12 +202,12 @@ static void activate_ind_cb(const GIsiMessage *msg, void *opaque) { struct context_data *cd = opaque; GIsiSubBlockIter iter; + const char *dns[5]; + int dns_count = 0; char ifname[IF_NAMESIZE]; - char *ip = NULL; - char *pdns = NULL; - char *sdns = NULL; - const char *dns[3]; + char *ip_addr = NULL; + char *ipv6_addr = NULL; if (!check_ind(msg, 2, cd)) return; @@ -225,8 +221,6 @@ static void activate_ind_cb(const GIsiMessage *msg, void *opaque) switch (g_isi_sb_iter_get_id(iter)) { - /* TODO: IPv6 address support */ - case GPDS_PDP_ADDRESS_INFO: if (!g_isi_sb_iter_get_byte(iter, addr_len, 3)) @@ -236,9 +230,15 @@ static void activate_ind_cb(const GIsiMessage *msg, void *opaque) 4)) goto error; - ip = alloca(INET_ADDRSTRLEN); - inet_ntop(AF_INET, (const void *)addr_value, ip, - INET_ADDRSTRLEN); + if (addr_len == 4) { + ip_addr = alloca(INET_ADDRSTRLEN); + inet_ntop(AF_INET, (const void *)addr_value, + ip_addr, INET_ADDRSTRLEN); + } else if (addr_len == 16) { + ipv6_addr = alloca(INET6_ADDRSTRLEN); + inet_ntop(AF_INET6, (const void *)addr_value, + ipv6_addr, INET6_ADDRSTRLEN); + } break; case GPDS_PDNS_ADDRESS_INFO: @@ -250,9 +250,17 @@ static void activate_ind_cb(const GIsiMessage *msg, void *opaque) 4)) break; - pdns = alloca(INET_ADDRSTRLEN); - inet_ntop(AF_INET, (const void *)addr_value, pdns, - INET_ADDRSTRLEN); + if (addr_len == 4) { + char *addr = alloca(INET_ADDRSTRLEN); + inet_ntop(AF_INET, (const void *)addr_value, + addr, INET_ADDRSTRLEN); + dns[dns_count++] = addr; + } else if (addr_len == 16) { + char *addr = alloca(INET6_ADDRSTRLEN); + inet_ntop(AF_INET6, (const void *)addr_value, + addr, INET6_ADDRSTRLEN); + dns[dns_count++] = addr; + } break; case GPDS_SDNS_ADDRESS_INFO: @@ -264,9 +272,17 @@ static void activate_ind_cb(const GIsiMessage *msg, void *opaque) 4)) break; - sdns = alloca(INET_ADDRSTRLEN); - inet_ntop(AF_INET, (const void *)addr_value, sdns, - INET_ADDRSTRLEN); + if (addr_len == 4) { + char *addr = alloca(INET_ADDRSTRLEN); + inet_ntop(AF_INET, (const void *)addr_value, + addr, INET_ADDRSTRLEN); + dns[dns_count++] = addr; + }
[RESEND 2 PATCH 06/13] isimodem: IPv6 support
--- drivers/isimodem/gprs-context.c | 119 --- 1 files changed, 73 insertions(+), 46 deletions(-) diff --git a/drivers/isimodem/gprs-context.c b/drivers/isimodem/gprs-context.c index bbf7ca9..674d0ab 100644 --- a/drivers/isimodem/gprs-context.c +++ b/drivers/isimodem/gprs-context.c @@ -62,10 +62,7 @@ struct context_data { uint16_t gpds; /* GPDS object handle */ unsigned cid; /* oFono core context ID */ struct ofono_gprs_context *context; - union { - ofono_gprs_context_up_cb_t up_cb; - ofono_gprs_context_cb_t down_cb; - }; + ofono_gprs_context_cb_t cb; void *data; GIsiPEP *pep; @@ -112,15 +109,14 @@ typedef void (*ContextFailFunc)(struct context_data *cd); static void gprs_up_fail(struct context_data *cd) { - CALLBACK_WITH_FAILURE(cd-up_cb, NULL, 0, NULL, NULL, NULL, NULL, - cd-data); reset_context(cd); + CALLBACK_WITH_FAILURE(cd-cb, cd-data); } static void gprs_down_fail(struct context_data *cd) { - CALLBACK_WITH_FAILURE(cd-down_cb, cd-data); reset_context(cd); + CALLBACK_WITH_FAILURE(cd-cb, cd-data); } static gboolean check_resp(const GIsiMessage *msg, uint8_t id, size_t minlen, @@ -206,12 +202,12 @@ static void activate_ind_cb(const GIsiMessage *msg, void *opaque) { struct context_data *cd = opaque; GIsiSubBlockIter iter; + const char *dns[5]; + int dns_count = 0; char ifname[IF_NAMESIZE]; - char *ip = NULL; - char *pdns = NULL; - char *sdns = NULL; - const char *dns[3]; + char *ip_addr = NULL; + char *ipv6_addr = NULL; if (!check_ind(msg, 2, cd)) return; @@ -225,8 +221,6 @@ static void activate_ind_cb(const GIsiMessage *msg, void *opaque) switch (g_isi_sb_iter_get_id(iter)) { - /* TODO: IPv6 address support */ - case GPDS_PDP_ADDRESS_INFO: if (!g_isi_sb_iter_get_byte(iter, addr_len, 3)) @@ -236,9 +230,15 @@ static void activate_ind_cb(const GIsiMessage *msg, void *opaque) 4)) goto error; - ip = alloca(INET_ADDRSTRLEN); - inet_ntop(AF_INET, (const void *)addr_value, ip, - INET_ADDRSTRLEN); + if (addr_len == 4) { + ip_addr = alloca(INET_ADDRSTRLEN); + inet_ntop(AF_INET, (const void *)addr_value, + ip_addr, INET_ADDRSTRLEN); + } else if (addr_len == 16) { + ipv6_addr = alloca(INET6_ADDRSTRLEN); + inet_ntop(AF_INET6, (const void *)addr_value, + ipv6_addr, INET6_ADDRSTRLEN); + } break; case GPDS_PDNS_ADDRESS_INFO: @@ -250,9 +250,17 @@ static void activate_ind_cb(const GIsiMessage *msg, void *opaque) 4)) break; - pdns = alloca(INET_ADDRSTRLEN); - inet_ntop(AF_INET, (const void *)addr_value, pdns, - INET_ADDRSTRLEN); + if (addr_len == 4) { + char *addr = alloca(INET_ADDRSTRLEN); + inet_ntop(AF_INET, (const void *)addr_value, + addr, INET_ADDRSTRLEN); + dns[dns_count++] = addr; + } else if (addr_len == 16) { + char *addr = alloca(INET6_ADDRSTRLEN); + inet_ntop(AF_INET6, (const void *)addr_value, + addr, INET6_ADDRSTRLEN); + dns[dns_count++] = addr; + } break; case GPDS_SDNS_ADDRESS_INFO: @@ -264,9 +272,17 @@ static void activate_ind_cb(const GIsiMessage *msg, void *opaque) 4)) break; - sdns = alloca(INET_ADDRSTRLEN); - inet_ntop(AF_INET, (const void *)addr_value, sdns, - INET_ADDRSTRLEN); + if (addr_len == 4) { + char *addr = alloca(INET_ADDRSTRLEN); + inet_ntop(AF_INET, (const void *)addr_value, + addr, INET_ADDRSTRLEN); + dns[dns_count++] = addr; + }
[RESEND PATCH 06/13] isimodem: IPv6 support
--- drivers/isimodem/gprs-context.c | 119 --- 1 files changed, 73 insertions(+), 46 deletions(-) diff --git a/drivers/isimodem/gprs-context.c b/drivers/isimodem/gprs-context.c index 6d579d8..942cb13 100644 --- a/drivers/isimodem/gprs-context.c +++ b/drivers/isimodem/gprs-context.c @@ -62,10 +62,7 @@ struct context_data { uint16_t gpds; /* GPDS object handle */ unsigned cid; /* oFono core context ID */ struct ofono_gprs_context *context; - union { - ofono_gprs_context_up_cb_t up_cb; - ofono_gprs_context_cb_t down_cb; - }; + ofono_gprs_context_cb_t cb; void *data; GIsiPEP *pep; @@ -112,15 +109,14 @@ typedef void (*ContextFailFunc)(struct context_data *cd); static void gprs_up_fail(struct context_data *cd) { - CALLBACK_WITH_FAILURE(cd-up_cb, NULL, 0, NULL, NULL, NULL, NULL, - cd-data); reset_context(cd); + CALLBACK_WITH_FAILURE(cd-cb, cd-data); } static void gprs_down_fail(struct context_data *cd) { - CALLBACK_WITH_FAILURE(cd-down_cb, cd-data); reset_context(cd); + CALLBACK_WITH_FAILURE(cd-cb, cd-data); } static gboolean check_resp(const GIsiMessage *msg, uint8_t id, size_t minlen, @@ -206,12 +202,12 @@ static void activate_ind_cb(const GIsiMessage *msg, void *opaque) { struct context_data *cd = opaque; GIsiSubBlockIter iter; + const char *dns[5]; + int dns_count = 0; char ifname[IF_NAMESIZE]; - char *ip = NULL; - char *pdns = NULL; - char *sdns = NULL; - const char *dns[3]; + char *ip_addr = NULL; + char *ipv6_addr = NULL; if (!check_ind(msg, 2, cd)) return; @@ -225,8 +221,6 @@ static void activate_ind_cb(const GIsiMessage *msg, void *opaque) switch (g_isi_sb_iter_get_id(iter)) { - /* TODO: IPv6 address support */ - case GPDS_PDP_ADDRESS_INFO: if (!g_isi_sb_iter_get_byte(iter, addr_len, 3)) @@ -236,9 +230,15 @@ static void activate_ind_cb(const GIsiMessage *msg, void *opaque) 4)) goto error; - ip = alloca(INET_ADDRSTRLEN); - inet_ntop(AF_INET, (const void *)addr_value, ip, - INET_ADDRSTRLEN); + if (addr_len == 4) { + ip_addr = alloca(INET_ADDRSTRLEN); + inet_ntop(AF_INET, (const void *)addr_value, + ip_addr, INET_ADDRSTRLEN); + } else if (addr_len == 16) { + ipv6_addr = alloca(INET6_ADDRSTRLEN); + inet_ntop(AF_INET6, (const void *)addr_value, + ipv6_addr, INET6_ADDRSTRLEN); + } break; case GPDS_PDNS_ADDRESS_INFO: @@ -250,9 +250,17 @@ static void activate_ind_cb(const GIsiMessage *msg, void *opaque) 4)) break; - pdns = alloca(INET_ADDRSTRLEN); - inet_ntop(AF_INET, (const void *)addr_value, pdns, - INET_ADDRSTRLEN); + if (addr_len == 4) { + char *addr = alloca(INET_ADDRSTRLEN); + inet_ntop(AF_INET, (const void *)addr_value, + addr, INET_ADDRSTRLEN); + dns[dns_count++] = addr; + } else if (addr_len == 16) { + char *addr = alloca(INET6_ADDRSTRLEN); + inet_ntop(AF_INET6, (const void *)addr_value, + addr, INET6_ADDRSTRLEN); + dns[dns_count++] = addr; + } break; case GPDS_SDNS_ADDRESS_INFO: @@ -264,9 +272,17 @@ static void activate_ind_cb(const GIsiMessage *msg, void *opaque) 4)) break; - sdns = alloca(INET_ADDRSTRLEN); - inet_ntop(AF_INET, (const void *)addr_value, sdns, - INET_ADDRSTRLEN); + if (addr_len == 4) { + char *addr = alloca(INET_ADDRSTRLEN); + inet_ntop(AF_INET, (const void *)addr_value, + addr, INET_ADDRSTRLEN); + dns[dns_count++] = addr; + }
[PATCH 06/13] isimodem: IPv6 support
--- drivers/isimodem/gprs-context.c | 119 --- 1 files changed, 73 insertions(+), 46 deletions(-) diff --git a/drivers/isimodem/gprs-context.c b/drivers/isimodem/gprs-context.c index 6d579d8..942cb13 100644 --- a/drivers/isimodem/gprs-context.c +++ b/drivers/isimodem/gprs-context.c @@ -62,10 +62,7 @@ struct context_data { uint16_t gpds; /* GPDS object handle */ unsigned cid; /* oFono core context ID */ struct ofono_gprs_context *context; - union { - ofono_gprs_context_up_cb_t up_cb; - ofono_gprs_context_cb_t down_cb; - }; + ofono_gprs_context_cb_t cb; void *data; GIsiPEP *pep; @@ -112,15 +109,14 @@ typedef void (*ContextFailFunc)(struct context_data *cd); static void gprs_up_fail(struct context_data *cd) { - CALLBACK_WITH_FAILURE(cd-up_cb, NULL, 0, NULL, NULL, NULL, NULL, - cd-data); reset_context(cd); + CALLBACK_WITH_FAILURE(cd-cb, cd-data); } static void gprs_down_fail(struct context_data *cd) { - CALLBACK_WITH_FAILURE(cd-down_cb, cd-data); reset_context(cd); + CALLBACK_WITH_FAILURE(cd-cb, cd-data); } static gboolean check_resp(const GIsiMessage *msg, uint8_t id, size_t minlen, @@ -206,12 +202,12 @@ static void activate_ind_cb(const GIsiMessage *msg, void *opaque) { struct context_data *cd = opaque; GIsiSubBlockIter iter; + const char *dns[5]; + int dns_count = 0; char ifname[IF_NAMESIZE]; - char *ip = NULL; - char *pdns = NULL; - char *sdns = NULL; - const char *dns[3]; + char *ip_addr = NULL; + char *ipv6_addr = NULL; if (!check_ind(msg, 2, cd)) return; @@ -225,8 +221,6 @@ static void activate_ind_cb(const GIsiMessage *msg, void *opaque) switch (g_isi_sb_iter_get_id(iter)) { - /* TODO: IPv6 address support */ - case GPDS_PDP_ADDRESS_INFO: if (!g_isi_sb_iter_get_byte(iter, addr_len, 3)) @@ -236,9 +230,15 @@ static void activate_ind_cb(const GIsiMessage *msg, void *opaque) 4)) goto error; - ip = alloca(INET_ADDRSTRLEN); - inet_ntop(AF_INET, (const void *)addr_value, ip, - INET_ADDRSTRLEN); + if (addr_len == 4) { + ip_addr = alloca(INET_ADDRSTRLEN); + inet_ntop(AF_INET, (const void *)addr_value, + ip_addr, INET_ADDRSTRLEN); + } else if (addr_len == 16) { + ipv6_addr = alloca(INET6_ADDRSTRLEN); + inet_ntop(AF_INET6, (const void *)addr_value, + ipv6_addr, INET6_ADDRSTRLEN); + } break; case GPDS_PDNS_ADDRESS_INFO: @@ -250,9 +250,17 @@ static void activate_ind_cb(const GIsiMessage *msg, void *opaque) 4)) break; - pdns = alloca(INET_ADDRSTRLEN); - inet_ntop(AF_INET, (const void *)addr_value, pdns, - INET_ADDRSTRLEN); + if (addr_len == 4) { + char *addr = alloca(INET_ADDRSTRLEN); + inet_ntop(AF_INET, (const void *)addr_value, + addr, INET_ADDRSTRLEN); + dns[dns_count++] = addr; + } else if (addr_len == 16) { + char *addr = alloca(INET6_ADDRSTRLEN); + inet_ntop(AF_INET6, (const void *)addr_value, + addr, INET6_ADDRSTRLEN); + dns[dns_count++] = addr; + } break; case GPDS_SDNS_ADDRESS_INFO: @@ -264,9 +272,17 @@ static void activate_ind_cb(const GIsiMessage *msg, void *opaque) 4)) break; - sdns = alloca(INET_ADDRSTRLEN); - inet_ntop(AF_INET, (const void *)addr_value, sdns, - INET_ADDRSTRLEN); + if (addr_len == 4) { + char *addr = alloca(INET_ADDRSTRLEN); + inet_ntop(AF_INET, (const void *)addr_value, + addr, INET_ADDRSTRLEN); + dns[dns_count++] = addr; + }