【发布时间】:2016-09-27 20:54:32
【问题描述】:
我正在尝试使用一些转换为 uint8_t 将 IPv4 转换为 IPv6。我知道 IPv4 有 4 个字节,而 IPv6 有 16 个 2 个字节的无符号整数,但我找不到进行转换的方法。
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
int main() {
uint8_t ipv6[16],direccionIP[] = {193, 110, 128, 200};
ipv6 = &direccionIP; //this doesn't work, and I don't come up with any method
printf("%u", ipv6);
return 0;
}
【问题讨论】:
-
你不能在夸脱罐中装一品脱
-
什么,将 IPv4 转换为 IPv6 是什么意思?寻址不兼容,您对 IPv6 地址的概念似乎存在缺陷。 IPv4 地址是 32 位整数,IPv6 地址是 128 位整数。