trema/trema — pull request #196 by userlocalhost2000 (2012-08-08 18:08:13+00:00)
Title: Add discover_path example

I made an example that discovers all the path that are connected to a node, which means switch or host, through a physical port.

This example generate and send a discovery-frame that only have source-addr of switch to OFPP_FLOOD vertual-port when switches are ready.
Then, each switches send packet-in message to controller and it can be to know which switches are connected from nodes through a specific physical port.

To detect position where is a host, this controller also listens for the transmission of the packet from the host with Packet-in handler. Then check the current network topology.
If the host which sends this packet is not registerd, this controller update the topology information.

The core data structure is following.

/* OpenFlow node, which means switch or host, infomation */
struct ofnode {
uint32_t type;
union {
struct {
uint64_t dpid;
uint16_t port_len;
struct ofnode **ports;
} switch_info;

struct {
uint8_t macaddr[ ETH_ADDRLEN ];
uint32_t nwaddr;
void *data;
} host_info;
};
};

Parameters of "ports" and "port_len" at switch_info are initizlied at event handler of Feature-Reply message.
And this controller makes up relationship of these objects as described above.