#ifndef CLICK_WINGSETSOURCEROUTE_HH
#define CLICK_WINGSETSOURCEROUTE_HH
#include <click/element.hh>
#include <click/glue.hh>
#include <click/timer.hh>
#include <click/ipaddress.hh>
#include <click/etheraddress.hh>
#include <click/vector.hh>
#include <click/hashmap.hh>
#include "pathmulti.hh"
CLICK_DECLS

/*
 * =c
 * WINGSetSourceRoute(IP, WINGForwarder element)
 * =s Wifi, Wireless Routing
 * =d
 * Set the Source Route for packet's destination inside the source route
 * header based on the destination ip annotation. If no source route is
 * found for a given packet, the unmodified packet is sent to output 1 if
 * the output is present.
 *
 * Regular Arguments:
 * =over 8
 * =item IP IPAddress
 * =item WINGForwarder element
 * =back 8
 *
 * =h clear write
 * Removes all routes from this element
 * =h routes read
 * Prints routes 
 * 
 * =h set_route write
 * Writing "0 5.0.0.1 1 1 5.0.0.2 0" to this element will make all packets 
 * destined for 5.0.0.2 from 5.0.0.1 to use the first wireless interface
 * on both nodes.
 * 
 * =a WINGForwarder
 */

class WINGSetSourceRoute: public Element {
public:

	WINGSetSourceRoute();
	~WINGSetSourceRoute();

	const char *class_name() const { return "WINGSetSourceRoute"; }
	const char *port_count() const { return "1/1-2"; }
	const char *processing() const { return AGNOSTIC; }

	int configure(Vector<String> &conf, ErrorHandler *errh);
	Packet *simple_action(Packet *);

	/* handler stuff */
	void add_handlers();
	String print_routes();
	String route_to_string(PathMulti);

private:

	typedef HashMap<IPAddress, PathMulti> RouteTable;
	RouteTable _routes;

	IPAddress _ip; // My address.
	class WINGForwarder *_forwarder;

	bool _debug;

	static int write_handler(const String &, Element *, void *, ErrorHandler *);
	static String read_handler(Element *, void *);

};

CLICK_ENDDECLS
#endif
