static void tcp_deserialize(struct proto_info *info_, uint8_t const **buf) { struct tcp_proto_info *info = DOWNCAST(info_, info, tcp_proto_info); proto_info_deserialize(info_, buf); info->key.port[0] = deserialize_2(buf); info->key.port[1] = deserialize_2(buf); unsigned flags = deserialize_1(buf); info->syn = !!(flags & 0x01); info->ack = !!(flags & 0x02); info->rst = !!(flags & 0x04); info->fin = !!(flags & 0x08); info->urg = !!(flags & 0x10); info->psh = !!(flags & 0x20); info->to_srv = !!(flags & 0x40); info->window = deserialize_2(buf); info->urg_ptr = deserialize_2(buf); info->ack_num = deserialize_4(buf); info->seq_num = deserialize_4(buf); info->rel_seq_num = deserialize_4(buf); info->set_values = deserialize_1(buf); info->mss = deserialize_2(buf); info->wsf = deserialize_1(buf); info->nb_options = deserialize_1(buf); for (unsigned o = 0; o < info->nb_options; o++) { info->options[o] = deserialize_1(buf); } }
static void sip_deserialize(struct proto_info *info_, uint8_t const **buf) { struct sip_proto_info *info = DOWNCAST(info_, info, sip_proto_info); proto_info_deserialize(info_, buf); info->set_values = deserialize_2(buf); if (info->set_values & SIP_CMD_SET) info->cmd = deserialize_1(buf); if (info->set_values & SIP_FROM_SET) deserialize_str(buf, info->from, sizeof(info->from)); if (info->set_values & SIP_TO_SET) deserialize_str(buf, info->to, sizeof(info->to)); if (info->set_values & SIP_CALLID_SET) deserialize_str(buf, info->call_id, sizeof(info->call_id)); if (info->set_values & SIP_MIME_SET) deserialize_str(buf, info->mime_type, sizeof(info->mime_type)); if (info->set_values & SIP_VIA_SET) { info->via.protocol = deserialize_1(buf); ip_addr_deserialize(&info->via.addr, buf); info->via.port = deserialize_2(buf); } if (info->set_values & SIP_LENGTH_SET) info->content_length = deserialize_4(buf); if (info->set_values & SIP_CODE_SET) info->code = deserialize_4(buf); if (info->set_values & SIP_CSEQ_SET) info->cseq = deserialize_4(buf); }
static void dhcp_deserialize(struct proto_info *info_, uint8_t const **buf) { struct dhcp_proto_info *info = DOWNCAST(info_, info, dhcp_proto_info); proto_info_deserialize(info_, buf); unsigned u = deserialize_1(buf); info->hw_addr_is_eth = u & 1U; info->opcode = u >> 1U; info->set_values = deserialize_1(buf); if (info->set_values & DHCP_CLIENT_SET) ip_addr_deserialize(&info->client, buf); deserialize_n(buf, info->client_mac, sizeof(info->client_mac)); deserialize_str(buf, info->server_name, sizeof(info->server_name)); }
static void rtp_deserialize(struct proto_info *info_, uint8_t const **buf) { struct rtp_proto_info *info = DOWNCAST(info_, info, rtp_proto_info); proto_info_deserialize(info_, buf); info->sync_src = deserialize_4(buf); info->seq_num = deserialize_2(buf); info->payload_type = deserialize_1(buf); info->timestamp = deserialize_4(buf); }
static void sdp_deserialize(struct proto_info *info_, uint8_t const **buf) { struct sdp_proto_info *info = DOWNCAST(info_, info, sdp_proto_info); proto_info_deserialize(info_, buf); info->set_values = deserialize_1(buf); if (info->set_values & SDP_HOST_SET) ip_addr_deserialize(&info->host, buf); if (info->set_values & SDP_PORT_SET) info->port = deserialize_2(buf); }
void ip_addr_deserialize(struct ip_addr *addr, uint8_t const **buf) { unsigned version = deserialize_1(buf); if (version == 4) { addr->family = AF_INET; addr->u.v4.s_addr = deserialize_4(buf); } else if (version == 6) { addr->family = AF_INET6; deserialize_n(buf, &addr->u.v6, sizeof(addr->u.v6)); } else { SLOG(LOG_ERR, "Cannot deserialize ip_addr of version %u", version); addr->family = AF_INET; // run forest, run! addr->u.v4.s_addr = 0U; } }