/*
	AddressManager.h
	Copyright (C) 2003 Mike Saywell
	
	Southampton Open Wireless Network,
	http://www.sown.org.uk
	
	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 2
	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, write to the Free Software
	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 

*/

#include <pthread.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <netinet/ether.h>
#include <arpa/inet.h>
#include <errno.h>
#include <pthread.h>
#include <unistd.h>
#include <limits.h>
#include <fcntl.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <string>
#include <map>

#include <sys/socket.h>
#include <features.h>    /* for the glibc version number */
#include <netpacket/packet.h>
#include <net/ethernet.h>     /* the L2 protocols */

using namespace std;
extern short DEBUG;

struct AddressAllocation {
	bool    allocated;
	struct  in_addr network;
	struct  in_addr netmask;
};

struct AllocationList {
	struct  AddressAllocation alloc;
	struct	AllocationList* next;
};

class AddressManager {
	private:
		struct in_addr* network;
		struct in_addr* netmask;
		struct AllocationList* list;
		
	public:
		AddressManager();
		void setRange(struct in_addr* network, struct in_addr* netmask);
		AddressAllocation* allocate();
		void deallocate(AddressAllocation* alloc);
};