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];
+ char out[40];
int i;
uint32_t offset;
if (le32toh(ip->ipv4configurationavailable) & MBIM_IP_CONFIGURATION_AVAILABLE_FLAG_ADDRESS)
for (i = 0; i < le32toh(ip->ipv4addresscount); i++) {
offset = le32toh(ip->ipv4address) + (i * 4);
- mbim_get_ipv4(buffer, ipv4, 4 + offset);
- printf(" ipv4address: %s/%d\n", ipv4, mbim_get_int(buffer, offset));
+ mbim_get_ipv4(buffer, out, 4 + offset);
+ printf(" ipv4address: %s/%d\n", out, mbim_get_int(buffer, offset));
}
if (le32toh(ip->ipv4configurationavailable) & MBIM_IP_CONFIGURATION_AVAILABLE_FLAG_DNS) {
- mbim_get_ipv4(buffer, ipv4, ip->ipv4gateway);
- printf(" ipv4gateway: %s\n", ipv4);
+ mbim_get_ipv4(buffer, out, le32toh(ip->ipv4gateway));
+ printf(" ipv4gateway: %s\n", out);
}
if (le32toh(ip->ipv4configurationavailable) & MBIM_IP_CONFIGURATION_AVAILABLE_FLAG_MTU)
printf(" ipv4mtu: %d\n", le32toh(ip->ipv4mtu));
if (le32toh(ip->ipv4configurationavailable) & MBIM_IP_CONFIGURATION_AVAILABLE_FLAG_DNS)
for (i = 0; i < le32toh(ip->ipv4dnsservercount); i++) {
- mbim_get_ipv4(buffer, ipv4, ip->ipv4dnsserver + (i * 4));
- printf(" ipv4dnsserver: %s\n", ipv4);
+ mbim_get_ipv4(buffer, out, le32toh(ip->ipv4dnsserver) + (i * 4));
+ printf(" ipv4dnsserver: %s\n", out);
}
- printf(" ipv6configurationavailable: %04X\n", le32toh(ip->ipv6configurationavailable));
+ if (le32toh(ip->ipv6configurationavailable) & MBIM_IP_CONFIGURATION_AVAILABLE_FLAG_ADDRESS)
+ for (i = 0; i < le32toh(ip->ipv6addresscount); i++) {
+ offset = le32toh(ip->ipv6address) + (i * 16);
+ mbim_get_ipv6(buffer, out, 4 + offset);
+ printf(" ipv6address: %s/%d\n", out, mbim_get_int(buffer, offset));
+ }
+ if (le32toh(ip->ipv6configurationavailable) & MBIM_IP_CONFIGURATION_AVAILABLE_FLAG_DNS) {
+ mbim_get_ipv6(buffer, out, le32toh(ip->ipv6gateway));
+ printf(" ipv6gateway: %s\n", out);
+ }
+ if (le32toh(ip->ipv6configurationavailable) & MBIM_IP_CONFIGURATION_AVAILABLE_FLAG_MTU)
+ printf(" ipv6mtu: %d\n", le32toh(ip->ipv6mtu));
+ if (le32toh(ip->ipv6configurationavailable) & MBIM_IP_CONFIGURATION_AVAILABLE_FLAG_DNS)
+ for (i = 0; i < le32toh(ip->ipv6dnsservercount); i++) {
+ mbim_get_ipv6(buffer, out, le32toh(ip->ipv6dnsserver) + (i * 16));
+ printf(" ipv6dnsserver: %s\n", out);
+ }
return 0;
}
snprintf(out, 16, "%d.%d.%d.%d", b[0], b[1], b[2], b[3]);
}
+void
+mbim_get_ipv6(void *buffer, char *out, uint32_t offset)
+{
+ uint8_t *b = buffer + offset;
+
+ snprintf(out, 40, "%x:%x:%x:%x:%x:%x:%x:%x", b[0] << 8 | b[1],
+ b[2] << 8 | b[3], b[4] << 8 | b[5], b[6] << 8 | b[7],
+ b[8] << 8 | b[9], b[10] << 8 | b[11], b[12] << 8 | b[13],
+ b[14] << 8 | b[15]);
+}
uint32_t
mbim_get_int(void *buffer, uint32_t offset)