123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- #!/bin/bash
- # (c) 2013, 2014, f0o@devilcode.org
- # (c) 2015 by Maximilian Wilhelm <max@rfc2324.org>
- #
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation, either version 3 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
- ALIASES_FILE="/etc/snmp/if_aliases"
- BASE='.1.3.6.1.2.1.31.1.1.1.18'
- ID=$(cut -d . -f 13 <<< $2)
- cache=$(ip l)
- if [ -z "$ID" ]; then
- ID=0
- fi
- if [ "$1" = "-n" ]; then
- IFS="
- "
- for dev in $(grep mtu <<<"$cache" | cut -d : -f 1|sort -n); do
- if [ "$LAST" == "$ID" ]; then
- ID=$dev
- BRK=1
- break
- else
- LAST=$dev
- fi
- done
- if [ -z "$BRK" ]; then
- exit 0
- fi
- fi
- IFACE=$(grep "^${ID}: " <<<"$cache" | sed 's/[:@]\s/ /g'| cut -d " " -f 2)
- echo ${BASE}.${ID}
- if [ "X${IFACE}" = "X" ]; then
- echo noSuchName
- else
- if_alias=""
- # Generic magic removed.
- # FFHO local
- case "${IFACE}" in
- # Transit
- tun42)
- if_alias="Transit: Perfect Privacy"
- ;;
- he-ipv6)
- if_alias="Transit: HE-IPv6"
- ;;
- gre_ffrl*)
- if_alias="Transit: FFRL"
- ;;
- # Peerings
- icvpn)
- if_alias="Peering: ICVPN"
- ;;
- # Core
- core*)
- if_alias="Core: core-vpn"
- ;;
- bb-*)
- if_alias="Core: Backbone-vpn"
- ;;
- vlan1*)
- if_alias="Core: X-Connect"
- ;;
- inter-gw-vpn)
- if_alias="Core: Inter-Gateway-B.A.T.M.A.N."
- ;;
- # Server
- infra-srv-vpn|user-srv-vpn)
- if_alias="Server: ${IFACE}"
- ;;
- vlan3*)
- if_alias="Server: Mgmt"
- ;;
- # Customer
- mesh-*)
- if_alias="Cust: B.A.T.M.A.N. mesh"
- ;;
- vlan23)
- if_alias="Cust: Local Mesh break-out"
- ;;
- esac
- echo "string"
- echo ${if_alias}
- fi
- exit 0
|