summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Mork <bjorn@mork.no>2015-04-08 14:28:48 +0200
committerBjørn Mork <bjorn@mork.no>2015-04-08 14:28:48 +0200
commit718e083f7f2003e945268775da4d658503decb8e (patch)
treeeede97a4d0a70f198fdba2256ef87fbb2c3f5bd0
parent7df361a7e5efa2ac56a3e05919c9953fe6009139 (diff)
fix IP configuration prefix output
Signed-off-by: Bjørn Mork <bjorn@mork.no>
-rw-r--r--cli.c6
-rw-r--r--mbim-msg.c9
-rw-r--r--mbim-msg.h1
3 files changed, 14 insertions, 2 deletions
diff --git a/cli.c b/cli.c
index cb107b7..c43b4f3 100644
--- a/cli.c
+++ b/cli.c
@@ -218,6 +218,7 @@ mbim_config_response(void *buffer, int len)
struct mbim_basic_connect_ip_configuration_r *ip = (struct mbim_basic_connect_ip_configuration_r *) buffer;
char ipv4[16];
int i;
+ uint32_t offset;
if (len < sizeof(struct mbim_basic_connect_ip_configuration_r)) {
fprintf(stderr, "message not long enough\n");
@@ -226,8 +227,9 @@ mbim_config_response(void *buffer, int len)
if (le32toh(ip->ipv4configurationavailable) & MBIM_IP_CONFIGURATION_AVAILABLE_FLAG_ADDRESS)
for (i = 0; i < le32toh(ip->ipv4addresscount); i++) {
- mbim_get_ipv4(buffer, ipv4, ip->ipv4address + (i * 4));
- printf(" ipv4address: %s\n", ipv4);
+ offset = le32toh(ip->ipv4address) + (i * 4);
+ mbim_get_ipv4(buffer, ipv4, 4 + offset);
+ printf(" ipv4address: %s/%d\n", ipv4, mbim_get_int(buffer, offset));
}
if (le32toh(ip->ipv4configurationavailable) & MBIM_IP_CONFIGURATION_AVAILABLE_FLAG_DNS) {
mbim_get_ipv4(buffer, ipv4, ip->ipv4gateway);
diff --git a/mbim-msg.c b/mbim-msg.c
index a327c6a..7199e85 100644
--- a/mbim-msg.c
+++ b/mbim-msg.c
@@ -97,6 +97,15 @@ mbim_get_ipv4(void *buffer, char *out, uint32_t offset)
snprintf(out, 16, "%d.%d.%d.%d", b[0], b[1], b[2], b[3]);
}
+
+uint32_t
+mbim_get_int(void *buffer, uint32_t offset)
+{
+ uint32_t *i = buffer + offset;
+
+ return le32toh(*i);
+}
+
const char*
mbim_enum_string(struct mbim_enum *e, uint32_t key)
{
diff --git a/mbim-msg.h b/mbim-msg.h
index 353d998..25415a5 100644
--- a/mbim-msg.h
+++ b/mbim-msg.h
@@ -94,5 +94,6 @@ int mbim_send_command_msg(void);
int mbim_add_payload(uint8_t len);
int mbim_encode_string(struct mbim_string *str, char *in);
void mbim_get_ipv4(void *buffer, char *out, uint32_t offset);
+uint32_t mbim_get_int(void *buffer, uint32_t offset);
#endif