/*
 * This file is part of DesktopBSD, see the README file.
 *
 * Author: Peter Hofer <ph@desktopbsd.net>
 *         (C) 2004, 2005
 *
 * Copyright: BSD, see the COPYING file included in this distribution
 *
 */

#ifndef __LAN_H
#define __LAN_H

#include <ipv4addr.h>
#include <ipv4netmask.h>

#include <qptrlist.h>

class QString;

/** @brief Stores a "LAN connect profile".
  *
  * This class stores all information necessary to connect
  * to a local area network, such as host ip address, subnet
  * mask, gateway (@sa DefaultRouter) and nameservers.
  *
  * Use the toString() and fromString() methods to
  * properly serialize this object or create a
  * new Object from a saved string representation.
  */
class LAN {
public:
   LAN();
   LAN(IPv4Addr,  IPv4Netmask,  IPv4Addr,  QPtrList<IPv4Addr>);

   virtual  ~LAN() {};

   virtual  QString  toString();
   static   LAN      fromString(const QString&);

   bool  usesDHCP()  const { return useDHCP; }
	bool	hasGateway() const { return gateway.isValid(); }

   const IPv4Addr&     getIP()           const { return ip;          }
   const IPv4Netmask&  getNetmask()      const { return netmask;     }
   const IPv4Addr&     getGateway()      const { return gateway;     }
   QPtrList<IPv4Addr>  getNameservers()  const { return nameservers; }

   void  setIP(const IPv4Addr& ip)              { this->ip = ip;           }
   void  setNetmask(const IPv4Netmask& netmask) { this->netmask = netmask; }
   void  setGateway(const IPv4Addr& gateway)    { this->gateway = gateway; }
   void  setDNSList(QPtrList<IPv4Addr>&  ns)    { this->nameservers = ns;  }
   void  setDHCPEnabled(bool  value)            { this->useDHCP = value;   }

private:
   /** If useDHCP is TRUE, settings for IP Address,
     * netmask, ... are ignored.
     */
   bool  useDHCP;

   IPv4Addr     ip;
   IPv4Netmask  netmask;
   IPv4Addr     gateway;
   QPtrList<IPv4Addr>  nameservers;
};



#endif /* __LAN_H */
