00001 // 00002 // Copyright (C) 2000 Institut fuer Telematik, Universitaet Karlsruhe 00003 // Copyright (C) 2004 Andras Varga 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 00020 // 00021 // Author: Jochen Reber 00022 // Date: 18.5.00 00023 // On Linux: 19.5.00 - 29.5.00 00024 // Modified by Vincent Oberle 00025 // Date: 1.2.2001 00026 // Cleanup and rewrite: Andras Varga, 2004 00027 // 00028 00029 00030 #ifndef __INET_ROUTINGTABLEPARSER_H 00031 #define __INET_ROUTINGTABLEPARSER_H 00032 00033 #include <omnetpp.h> 00034 #include "RoutingTable.h" 00035 00039 class INET_API RoutingTableParser 00040 { 00041 protected: 00042 IInterfaceTable *ift; 00043 IRoutingTable *rt; 00044 00045 public: 00049 RoutingTableParser(IInterfaceTable *ift, IRoutingTable *rt); 00050 00054 virtual int readRoutingTableFromFile (const char *filename); 00055 00056 protected: 00057 // Parsing functions 00058 00059 00060 // Used to create specific "files" char arrays without comments or blanks 00061 // from original file. 00062 virtual char *createFilteredFile (char *file, 00063 int &charpointer, 00064 const char *endtoken); 00065 00066 // Go through the ifconfigFile char array, parse all entries and 00067 // write them into the interface table. 00068 // Loopback interface is not part of the file. 00069 virtual void parseInterfaces(char *ifconfigFile); 00070 00071 // Go through the routeFile char array, parse all entries line by line and 00072 // write them into the routing table. 00073 virtual void parseRouting(char *routeFile); 00074 00075 virtual char *parseEntry (char *ifconfigFile, 00076 const char *tokenStr, 00077 int &charpointer, 00078 char* destStr); 00079 00080 // Convert string separated by ':' into dynamic string array. 00081 virtual void parseMulticastGroups (char *groupStr, InterfaceEntry*); 00082 00083 // Return 1 if beginning of str1 and str2 is equal up to str2-len, 00084 // otherwise 0. 00085 static int streq(const char *str1, const char *str2); 00086 00087 // Skip blanks in string 00088 static void skipBlanks (char *str, int &charptr); 00089 00090 // Copies the first word of src up to a space-char into dest 00091 // and appends \0, returns position of next space-char in src 00092 static int strcpyword (char *dest, const char *src); 00093 }; 00094 00095 00096 #endif 00097