#!/bin/bash # (c) 2013, 2014, f0o@devilcode.org # (c) 2015 by Maximilian Wilhelm # # 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 . 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