2 * Copyright (c) 2015 Mohamed Aslan <maslan@sce.carleton.ca>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 #include <sys/socket.h>
26 #define OFP_VERSION_10 0x01
35 enum of_event_type type
;
36 struct of_dataplane
*dp
;
38 struct ofp_header
*ofp_hdr
;
45 struct sockaddr_storage sw_addr
;
47 const struct of_protocol
*protocol
;
48 struct ofp_header
*sw_features
;
51 struct of_controller
{
56 struct hashtab conns
; /* map: int -> uintptr_t, socket to struct dataplane* */
57 struct hashtab dpids
; /* map: uint64_t -> uinptr_t, dpid to struct dataplane* */
58 struct hashtab timer_callbacks
; /* timer call backs */
59 const struct of_protocol
*protocol
;
60 void (*of_handler
)(struct of_controller
*, struct of_event
*);
62 void (*handler
)(struct of_controller
*, void (*)(struct of_controller
*, struct of_event
*));
63 void (*timer
)(struct of_controller
*, unsigned int, void (*)(struct of_controller
*));
64 void (*send
)(struct of_controller
*, struct of_dataplane
*, struct ofp_header
*);
65 void (*loop
)(struct of_controller
*);
70 void (*init
)(struct of_controller
*);
71 int (*handshake
)(struct of_controller
*, struct of_dataplane
*); /* async handshake */
72 int (*recv
)(struct of_controller
*, struct of_dataplane
*, struct ofp_header
*);
73 int (*ping
)(struct of_controller
*, struct of_dataplane
*); /* async ping */
77 assume that ofp_header will be the same across all OpenFlow versions
84 }__attribute__((packed
));
85 /* assert(sizeof(struct ofp_header) == 8); */
88 int of_controller_init(struct of_controller
*, int, const struct of_protocol
*);