00001 // 00002 // Copyright (C) 2004-2006 Andras Varga 00003 // Copyright (C) 2000 Institut fuer Telematik, Universitaet Karlsruhe 00004 // 00005 // This program is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU Lesser General Public License 00007 // as published by the Free Software Foundation; either version 2 00008 // of the License, or (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with this program; if not, see <http://www.gnu.org/licenses/>. 00017 // 00018 00019 #include <stdio.h> 00020 #include <sstream> 00021 #include "IPRoute.h" 00022 #include "InterfaceEntry.h" 00023 00024 00025 IPRoute::IPRoute() 00026 { 00027 interfacePtr = NULL; 00028 00029 metric = 0; 00030 type = DIRECT; 00031 source = MANUAL; 00032 } 00033 00034 std::string IPRoute::info() const 00035 { 00036 std::stringstream out; 00037 out << "dest:"; if (host.isUnspecified()) out << "* "; else out << host << " "; 00038 out << "gw:"; if (gateway.isUnspecified()) out << "* "; else out << gateway << " "; 00039 out << "mask:"; if (netmask.isUnspecified()) out << "* "; else out << netmask << " "; 00040 out << "metric:" << metric << " "; 00041 out << "if:"; if (!interfacePtr) out << "* "; else out << interfacePtr->getName() << " "; 00042 out << (type==DIRECT ? "DIRECT" : "REMOTE"); 00043 switch (source) 00044 { 00045 case MANUAL: out << " MANUAL"; break; 00046 case IFACENETMASK: out << " IFACENETMASK"; break; 00047 case RIP: out << " RIP"; break; 00048 case OSPF: out << " OSPF"; break; 00049 case BGP: out << " BGP"; break; 00050 case ZEBRA: out << " ZEBRA"; break; 00051 default: out << " ???"; break; 00052 } 00053 return out.str(); 00054 } 00055 00056 std::string IPRoute::detailedInfo() const 00057 { 00058 return std::string(); 00059 } 00060 00061 const char *IPRoute::getInterfaceName() const 00062 { 00063 return interfacePtr ? interfacePtr->getName() : ""; 00064 } 00065