use super::super::*;
use super::push_field_id;

pub(super) fn push_network_field_ids(
    index: &mut FlowIndex,
    rec: &FlowRecord,
    missing_ip: IpAddr,
    scratch_field_ids: &mut Vec<u32>,
) -> Result<(), FlowIndexError> {
    push_field_id(
        index,
        scratch_field_ids,
        38,
        IndexFieldValue::Text(rec.src_net_name.as_str()),
    )?;
    push_field_id(
        index,
        scratch_field_ids,
        39,
        IndexFieldValue::Text(rec.dst_net_name.as_str()),
    )?;
    push_field_id(
        index,
        scratch_field_ids,
        40,
        IndexFieldValue::Text(rec.src_net_role.as_str()),
    )?;
    push_field_id(
        index,
        scratch_field_ids,
        41,
        IndexFieldValue::Text(rec.dst_net_role.as_str()),
    )?;
    push_field_id(
        index,
        scratch_field_ids,
        42,
        IndexFieldValue::Text(rec.src_net_site.as_str()),
    )?;
    push_field_id(
        index,
        scratch_field_ids,
        43,
        IndexFieldValue::Text(rec.dst_net_site.as_str()),
    )?;
    push_field_id(
        index,
        scratch_field_ids,
        44,
        IndexFieldValue::Text(rec.src_net_region.as_str()),
    )?;
    push_field_id(
        index,
        scratch_field_ids,
        45,
        IndexFieldValue::Text(rec.dst_net_region.as_str()),
    )?;
    push_field_id(
        index,
        scratch_field_ids,
        46,
        IndexFieldValue::Text(rec.src_net_tenant.as_str()),
    )?;
    push_field_id(
        index,
        scratch_field_ids,
        47,
        IndexFieldValue::Text(rec.dst_net_tenant.as_str()),
    )?;
    push_field_id(
        index,
        scratch_field_ids,
        48,
        IndexFieldValue::Text(rec.src_country.as_str()),
    )?;
    push_field_id(
        index,
        scratch_field_ids,
        49,
        IndexFieldValue::Text(rec.dst_country.as_str()),
    )?;
    push_field_id(
        index,
        scratch_field_ids,
        50,
        IndexFieldValue::Text(rec.src_geo_state.as_str()),
    )?;
    push_field_id(
        index,
        scratch_field_ids,
        51,
        IndexFieldValue::Text(rec.dst_geo_state.as_str()),
    )?;
    push_field_id(
        index,
        scratch_field_ids,
        52,
        IndexFieldValue::U8(u8::from(rec.next_hop.is_some())),
    )?;
    push_field_id(
        index,
        scratch_field_ids,
        53,
        IndexFieldValue::IpAddr(rec.next_hop.unwrap_or(missing_ip)),
    )?;
    push_field_id(
        index,
        scratch_field_ids,
        54,
        IndexFieldValue::U16(rec.src_vlan),
    )?;
    push_field_id(
        index,
        scratch_field_ids,
        55,
        IndexFieldValue::U16(rec.dst_vlan),
    )
}
