Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/hyperv/utilities/hv_kvp.c
Show First 20 Lines • Show All 298 Lines • ▼ Show 20 Lines | |||||
* Convert ip related info in hmsg from utf16 to utf8 and store in umsg | * Convert ip related info in hmsg from utf16 to utf8 and store in umsg | ||||
*/ | */ | ||||
static int | static int | ||||
hv_kvp_convert_utf16_ipinfo_to_utf8(struct hv_kvp_ip_msg *host_ip_msg, | hv_kvp_convert_utf16_ipinfo_to_utf8(struct hv_kvp_ip_msg *host_ip_msg, | ||||
struct hv_kvp_msg *umsg) | struct hv_kvp_msg *umsg) | ||||
{ | { | ||||
int err_ip, err_subnet, err_gway, err_dns, err_adap; | int err_ip, err_subnet, err_gway, err_dns, err_adap; | ||||
int UNUSED_FLAG = 1; | int UNUSED_FLAG = 1; | ||||
int guid_index; | |||||
struct hv_device *hv_dev; /* GUID Data Structure */ | struct hv_device *hv_dev; /* GUID Data Structure */ | ||||
hn_softc_t *sc; /* hn softc structure */ | hn_softc_t *sc; /* hn softc structure */ | ||||
char if_name[4]; | char if_name[4]; | ||||
unsigned char guid_instance[40]; | |||||
char *guid_data = NULL; | |||||
char buf[39]; | char buf[39]; | ||||
struct guid_extract { | |||||
char a1[2]; | |||||
char a2[2]; | |||||
char a3[2]; | |||||
char a4[2]; | |||||
char b1[2]; | |||||
char b2[2]; | |||||
char c1[2]; | |||||
char c2[2]; | |||||
char d[4]; | |||||
char e[12]; | |||||
}; | |||||
struct guid_extract *id; | |||||
device_t *devs; | device_t *devs; | ||||
int devcnt; | int devcnt; | ||||
/* IP Address */ | /* IP Address */ | ||||
utf16_to_utf8((char *)umsg->body.kvp_ip_val.ip_addr, | utf16_to_utf8((char *)umsg->body.kvp_ip_val.ip_addr, | ||||
MAX_IP_ADDR_SIZE, | MAX_IP_ADDR_SIZE, | ||||
(uint16_t *)host_ip_msg->kvp_ip_val.ip_addr, | (uint16_t *)host_ip_msg->kvp_ip_val.ip_addr, | ||||
MAX_IP_ADDR_SIZE, | MAX_IP_ADDR_SIZE, | ||||
Show All 10 Lines | hv_kvp_convert_utf16_ipinfo_to_utf8(struct hv_kvp_ip_msg *host_ip_msg, | ||||
if (devclass_get_devices(devclass_find("hn"), &devs, &devcnt) == 0) { | if (devclass_get_devices(devclass_find("hn"), &devs, &devcnt) == 0) { | ||||
for (devcnt = devcnt - 1; devcnt >= 0; devcnt--) { | for (devcnt = devcnt - 1; devcnt >= 0; devcnt--) { | ||||
sc = device_get_softc(devs[devcnt]); | sc = device_get_softc(devs[devcnt]); | ||||
/* Trying to find GUID of Network Device */ | /* Trying to find GUID of Network Device */ | ||||
hv_dev = sc->hn_dev_obj; | hv_dev = sc->hn_dev_obj; | ||||
for (guid_index = 0; guid_index < 16; guid_index++) { | snprintf_hv_guid(buf, sizeof(buf), &hv_dev->device_id); | ||||
sprintf(&guid_instance[guid_index * 2], "%02x", | |||||
hv_dev->device_id.data[guid_index]); | |||||
} | |||||
guid_data = (char *)guid_instance; | |||||
id = (struct guid_extract *)guid_data; | |||||
snprintf(buf, sizeof(buf), "{%.2s%.2s%.2s%.2s-%.2s%.2s-%.2s%.2s-%.4s-%s}", | |||||
id->a4, id->a3, id->a2, id->a1, | |||||
id->b2, id->b1, id->c2, id->c1, id->d, id->e); | |||||
guid_data = NULL; | |||||
sprintf(if_name, "%s%d", "hn", device_get_unit(devs[devcnt])); | sprintf(if_name, "%s%d", "hn", device_get_unit(devs[devcnt])); | ||||
if (strncmp(buf, (char *)umsg->body.kvp_ip_val.adapter_id, 39) == 0) { | if (strncmp(buf, (char *)umsg->body.kvp_ip_val.adapter_id, 39) == 0) { | ||||
strcpy((char *)umsg->body.kvp_ip_val.adapter_id, if_name); | strcpy((char *)umsg->body.kvp_ip_val.adapter_id, if_name); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
free(devs, M_TEMP); | free(devs, M_TEMP); | ||||
▲ Show 20 Lines • Show All 596 Lines • Show Last 20 Lines |