示例#1
0
文件: eth.c 项目: bsmr-c-cpp/junkie
static void eth_serialize(struct proto_info const *info_, uint8_t **buf)
{
    struct eth_proto_info const *info = DOWNCAST(info_, info, eth_proto_info);
    proto_info_serialize(info_, buf);
    serialize_3(buf, info->vlan_id);    // 16 bits for vlan itself, +we need to handle -1 for UNSET
    serialize_n(buf, info->addr[0], ETH_ADDR_LEN);
    serialize_n(buf, info->addr[1], ETH_ADDR_LEN);
    serialize_2(buf, info->protocol);
}
示例#2
0
文件: dhcp.c 项目: bonnefoa/junkie
static void dhcp_serialize(struct proto_info const *info_, uint8_t **buf)
{
    struct dhcp_proto_info const *info = DOWNCAST(info_, info, dhcp_proto_info);
    proto_info_serialize(info_, buf);
    serialize_1(buf, info->hw_addr_is_eth + (info->opcode << 1U));
    serialize_4(buf, info->xid);
    serialize_1(buf, info->set_values);
    if (info->set_values & DHCP_CLIENT_SET) ip_addr_serialize(&info->client, buf);
    serialize_n(buf, info->client_mac, sizeof(info->client_mac));
    serialize_str(buf, info->server_name);
}
示例#3
0
文件: ip_addr.c 项目: k8king/junkie
void ip_addr_serialize(struct ip_addr const *addr, uint8_t **buf)
{
    if (addr->family == AF_INET) {
        serialize_1(buf, 4);
        serialize_4(buf, addr->u.v4.s_addr);
    } else if (addr->family == AF_INET6) {
        serialize_1(buf, 6);
        serialize_n(buf, &addr->u.v6, sizeof(addr->u.v6));
    } else {
        SLOG(LOG_ERR, "Cannot serialize ip_addr of unknown type");
    }
}