【发布时间】:2014-07-24 20:35:36
【问题描述】:
我想构建简单的DHCP packet,其中一个协议 oprion 是client mac address(选项 61),所以我有我的 mac 地址:
string macAddress = "00:14:22:18:81:11";
我想把它放在我的数据包数组中(6 个字节),这是我尝试过的,我想知道如何做到这一点(我尝试将我的字符串转换为字节 [],但这个数组长度是 24)
// Set requested ip address - 61
index += DHCPMessageTypeLength;
packetArrayBytes[index] = 61; // option
packetArrayBytes[index + 1] = 7; // length
packetArrayBytes[index + 2] = 1; // hardware type Ethernet
packetArrayBytes[index + 3] = ?; // mac
packetArrayBytes[index + 4] = ?; // mac
packetArrayBytes[index + 5] = ?; // mac
packetArrayBytes[index + 6] = ?; // mac
packetArrayBytes[index + 7] = ?; // mac
packetArrayBytes[index + 8] = ?; // mac
【问题讨论】: