rendered paste bodystruct libnet_ether_addr *libnet_get_hwaddr(libnet_t *l){ /* This implementation is not-reentrant. */ static struct libnet_ether_addr *mac; ULONG IoCtlBufferLength = (sizeof(PACKET_OID_DATA) + sizeof(ULONG) - 1); PPACKET_OID_DATA OidData; int i = 0; if (l == NULL) { return (NULL); } if (l->device == NULL) { if (libnet_select_device(l) == -1) { snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, "%s(): can't figure out a device to use\n", __func__); return (NULL); } } mac = (struct libnet_ether_addr *)calloc(1,sizeof(struct libnet_ether_addr)); if (mac == NULL) { snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, "%s(): calloc error\n", __func__); return (NULL); } OidData = (struct _PACKET_OID_DATA *) malloc(IoCtlBufferLength); if (OidData == NULL) { snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, "%s(): OidData is NULL\n", __func__); return(NULL); } if (l->link_type == DLT_IEEE802) { OidData->Oid = OID_802_5_CURRENT_ADDRESS; } else { OidData->Oid = OID_802_3_CURRENT_ADDRESS; } OidData->Length = 6; if((PacketRequest(l->lpAdapter, FALSE, OidData)) == FALSE) { memset(mac, 0, 6); } else { for (i = 0; i < 6; i++) { mac->ether_addr_octet[i] = OidData->Data[i]; } } free(OidData); return(mac);}