author | benmeyer <benmeyer> | 2002-09-30 14:26:33 (UTC) |
---|---|---|
committer | benmeyer <benmeyer> | 2002-09-30 14:26:33 (UTC) |
commit | 9965bd5c49ff2f22d640d132ac343fdec97b3fb4 (patch) (side-by-side diff) | |
tree | 45e8f1d1bf414530b637692ba43b730110611856 /noncore/net/networksetup/interfaces.h | |
parent | 5db3af80f392f8f063f53cbbad67bbe7c5c6eb6d (diff) | |
download | opie-9965bd5c49ff2f22d640d132ac343fdec97b3fb4.zip opie-9965bd5c49ff2f22d640d132ac343fdec97b3fb4.tar.gz opie-9965bd5c49ff2f22d640d132ac343fdec97b3fb4.tar.bz2 |
Initial commit
Diffstat (limited to 'noncore/net/networksetup/interfaces.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/networksetup/interfaces.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/noncore/net/networksetup/interfaces.h b/noncore/net/networksetup/interfaces.h new file mode 100644 index 0000000..2cc9689 --- a/dev/null +++ b/noncore/net/networksetup/interfaces.h @@ -0,0 +1,70 @@ +#ifndef INTERFACES_H +#define INTERFACES_H + +#include <qstring.h> +#include <qstringlist.h> + +#define INTERFACES_LOOPBACK "loopback" + +#define INTERFACES_FAMILY_INET "inet" +#define INTERFACES_FAMILY_IPX "ipx" +#define INTERFACES_FAMILY_INET6 "inet6" + +#define INTERFACES_METHOD_DHCP "dhcp" +#define INTERFACES_METHOD_STATIC "static" +#define INTERFACES_METHOD_PPP "ppp" + +/** + * This class provides a clean frontend for parsing the network interfaces file. + * It provides helper functions to minipulate the options within the file. + * See the interfaces man page for the syntax rules. + */ +class Interfaces { + +public: + Interfaces(QString useInterfacesFile = "/etc/network/interfaces"); + + bool isAuto(QString interface); + bool setAuto(QString interface, bool setAuto); + + bool removeInterface(); + bool addInterface(QString interface, QString family, QString method); + bool setInterface(QString interface); + bool isInterfaceSet(); + QString getInterfaceName(bool &error); + bool setInterfaceName(QString newName); + QString getInterfaceFamily(bool &error); + bool setInterfaceFamily(QString newName); + QString getInterfaceMethod(bool &error); + bool setInterfaceMethod(QString newName); + QString getInterfaceOption(QString option, bool &error); + bool setInterfaceOption(QString option, QString value); + bool removeAllInterfaceOptions(); + + bool setMapping(QString interface); + void addMapping(QString interfaces); + bool setMap(QString map, QString value); + QString getMap(QString map, bool &error); + bool setScript(QString); + QString getScript(bool &error); + + bool write(); + +private: + bool setStanza(QString stanza, QString option,QStringList::Iterator &iterator); + bool setOption(QStringList::Iterator start, QString option, QString value); + QString getOption(QStringList::Iterator start, QString option, bool &error); + bool removeAllOptions(QStringList::Iterator start); + + QString interfacesFile; + QStringList interfaces; + QStringList::Iterator currentIface; + QStringList::Iterator currentMapping; + + QStringList acceptedFamily; +}; + +#endif + +// interfaces + |