# Supplemental topology discovery profile for endpoint correlation.
# Sources: BRIDGE-MIB FDB and IP-MIB neighbor tables.

topology:
  # Interface index -> interface name map used to annotate topology links.
  - kind: if_name
    MIB: IF-MIB
    table:
      OID: 1.3.6.1.2.1.31.1.1
      name: ifXTable
    symbols:
      # Use a numeric column to ensure row emission.
      - OID: 1.3.6.1.2.1.31.1.1.1.15
        name: if_name
    metric_tags:
      - tag: topo_if_index
        index: 1
      - tag: topo_if_name
        symbol:
          OID: 1.3.6.1.2.1.31.1.1.1.1
          name: ifName
      - tag: topo_if_alias
        symbol:
          OID: 1.3.6.1.2.1.31.1.1.1.18
          name: ifAlias
      - tag: topo_if_high_speed
        symbol:
          OID: 1.3.6.1.2.1.31.1.1.1.15
          name: ifHighSpeed

  # IF-MIB ifTable: explicit interface status collection for topology port states.
  # Some vendors do not support stable cross-table joins from ifXTable to ifTable.
  - kind: if_status
    MIB: IF-MIB
    table:
      OID: 1.3.6.1.2.1.2.2
      name: ifTable
    symbols:
      # Use oper status symbol to guarantee row emission for interfaces.
      - OID: 1.3.6.1.2.1.2.2.1.8
        name: if_status
    metric_tags:
      - tag: topo_if_index
        index: 1
      - tag: topo_if_type
        symbol:
          OID: 1.3.6.1.2.1.2.2.1.3
          name: ifType
      - tag: topo_if_descr
        symbol:
          OID: 1.3.6.1.2.1.2.2.1.2
          name: ifDescr
      - tag: topo_if_admin_status
        symbol:
          OID: 1.3.6.1.2.1.2.2.1.7
          name: ifAdminStatus
          mapping:
            1: up
            2: down
            3: testing
      - tag: topo_if_oper_status
        symbol:
          OID: 1.3.6.1.2.1.2.2.1.8
          name: ifOperStatus
          mapping:
            1: up
            2: down
            3: testing
            4: unknown
            5: dormant
            6: notPresent
            7: lowerLayerDown
      - tag: topo_if_phys_address
        symbol:
          OID: 1.3.6.1.2.1.2.2.1.6
          name: ifPhysAddress
          format: hex
      - tag: topo_if_speed
        symbol:
          OID: 1.3.6.1.2.1.2.2.1.5
          name: ifSpeed
      - tag: topo_if_last_change
        symbol:
          OID: 1.3.6.1.2.1.2.2.1.9
          name: ifLastChange

  # EtherLike-MIB: interface duplex mode.
  - kind: if_duplex
    MIB: EtherLike-MIB
    table:
      OID: 1.3.6.1.2.1.10.7.2
      name: dot3StatsTable
    symbols:
      - OID: 1.3.6.1.2.1.10.7.2.1.19
        name: if_duplex
    metric_tags:
      - tag: topo_if_index
        index: 1
      - tag: topo_if_duplex
        symbol:
          OID: 1.3.6.1.2.1.10.7.2.1.19
          name: dot3StatsDuplexStatus
          mapping:
            1: unknown
            2: half
            3: full

  # IP-MIB: interface address map used for management IP -> ifIndex correlation.
  - kind: ip_if_index
    MIB: IP-MIB
    table:
      OID: 1.3.6.1.2.1.4.20
      name: ipAddrTable
    symbols:
      - OID: 1.3.6.1.2.1.4.20.1.2
        name: ip_if_index
    metric_tags:
      - tag: topo_ip_addr
        symbol:
          OID: 1.3.6.1.2.1.4.20.1.1
          name: ipAdEntAddr
      - tag: topo_if_index
        symbol:
          OID: 1.3.6.1.2.1.4.20.1.2
          name: ipAdEntIfIndex
      - tag: topo_ip_netmask
        symbol:
          OID: 1.3.6.1.2.1.4.20.1.3
          name: ipAdEntNetMask

  # BRIDGE-MIB: maps bridge port number to ifIndex.
  - kind: bridge_port_if_index
    MIB: BRIDGE-MIB
    table:
      OID: 1.3.6.1.2.1.17.1.4
      name: dot1dBasePortTable
    symbols:
      - OID: 1.3.6.1.2.1.17.1.4.1.2
        name: bridge_port_if_index
    metric_tags:
      - tag: bridge_base_address
        symbol:
          OID: 1.3.6.1.2.1.17.1.1
          name: dot1dBaseBridgeAddress
          format: hex
      - tag: bridge_base_port
        index: 1
      - tag: bridge_if_index
        symbol:
          OID: 1.3.6.1.2.1.17.1.4.1.2
          name: dot1dBasePortIfIndex

  # BRIDGE-MIB: forwarding database (MAC -> bridge port).
  - kind: fdb_entry
    MIB: BRIDGE-MIB
    table:
      OID: 1.3.6.1.2.1.17.4.3
      name: dot1dTpFdbTable
    symbols:
      # Use the port column so rows are emitted only for learned entries.
      - OID: 1.3.6.1.2.1.17.4.3.1.2
        name: fdb_entry
    metric_tags:
      - tag: bridge_base_address
        symbol:
          OID: 1.3.6.1.2.1.17.1.1
          name: dot1dBaseBridgeAddress
          format: hex
      - tag: fdb_mac
        symbol:
          OID: 1.3.6.1.2.1.17.4.3.1.1
          name: dot1dTpFdbAddress
          format: hex
      - tag: fdb_bridge_port
        symbol:
          OID: 1.3.6.1.2.1.17.4.3.1.2
          name: dot1dTpFdbPort
      - tag: fdb_status
        symbol:
          OID: 1.3.6.1.2.1.17.4.3.1.3
          name: dot1dTpFdbStatus
          mapping:
            1: other
            2: invalid
            3: learned
            4: self
            5: mgmt

  # IP-MIB: modern ARP/ND cache (IPv4 + IPv6).
  - kind: arp_entry
    MIB: IP-MIB
    table:
      OID: 1.3.6.1.2.1.4.35.1
      name: ipNetToPhysicalTable
    symbols:
      # Use state column to emit rows only when neighbors exist.
      - OID: 1.3.6.1.2.1.4.35.1.6
        name: arp_entry
    metric_tags:
      - tag: arp_if_index
        index: 1
      - tag: arp_if_name
        table: ifXTable
        symbol:
          OID: 1.3.6.1.2.1.31.1.1.1.1
          name: ifName
        index_transform:
          - start: 0
            end: 0
      - tag: arp_addr_type
        index: 2
        symbol:
          name: ipNetToPhysicalNetAddressType
        mapping:
          0: unknown
          1: ipv4
          2: ipv6
          16: dns
      - tag: arp_ip
        symbol:
          name: ipNetToPhysicalNetAddress
          format: ip_address
        index_transform:
          - start: 3
      - tag: arp_mac
        symbol:
          OID: 1.3.6.1.2.1.4.35.1.4
          name: ipNetToPhysicalPhysAddress
          format: hex
      - tag: arp_state
        symbol:
          OID: 1.3.6.1.2.1.4.35.1.6
          name: ipNetToPhysicalState
          mapping:
            1: reachable
            2: stale
            3: delay
            4: probe
            5: invalid
            6: unknown
            7: incomplete

  # IP-MIB: legacy IPv4 ARP cache fallback.
  - kind: arp_legacy_entry
    MIB: IP-MIB
    table:
      OID: 1.3.6.1.2.1.4.22
      name: ipNetToMediaTable
    symbols:
      - OID: 1.3.6.1.2.1.4.22.1.4
        name: arp_legacy_entry
    metric_tags:
      - tag: arp_if_index
        symbol:
          OID: 1.3.6.1.2.1.4.22.1.1
          name: ipNetToMediaIfIndex
      - tag: arp_if_name
        table: ifXTable
        symbol:
          OID: 1.3.6.1.2.1.31.1.1.1.1
          name: ifName
        index_transform:
          - start: 0
            end: 0
      - tag: arp_ip
        symbol:
          OID: 1.3.6.1.2.1.4.22.1.3
          name: ipNetToMediaNetAddress
      - tag: arp_mac
        symbol:
          OID: 1.3.6.1.2.1.4.22.1.2
          name: ipNetToMediaPhysAddress
          format: hex
      - tag: arp_type
        symbol:
          OID: 1.3.6.1.2.1.4.22.1.4
          name: ipNetToMediaType
          mapping:
            1: other
            2: invalid
            3: dynamic
            4: static
