diff options
-rw-r--r-- | usr.sbin/switchd/ofp.c | 26 | ||||
-rw-r--r-- | usr.sbin/switchd/ofp13.c | 15 | ||||
-rw-r--r-- | usr.sbin/switchd/ofp_common.c | 26 | ||||
-rw-r--r-- | usr.sbin/switchd/switchd.h | 18 |
4 files changed, 42 insertions, 43 deletions
diff --git a/usr.sbin/switchd/ofp.c b/usr.sbin/switchd/ofp.c index 5c77deeef9f..7b8fadbd82a 100644 --- a/usr.sbin/switchd/ofp.c +++ b/usr.sbin/switchd/ofp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofp.c,v 1.14 2016/10/12 19:07:42 reyk Exp $ */ +/* $OpenBSD: ofp.c,v 1.15 2016/11/04 22:27:08 reyk Exp $ */ /* * Copyright (c) 2013-2016 Reyk Floeter <reyk@openbsd.org> @@ -155,30 +155,6 @@ ofp_input(struct switch_connection *con, struct ibuf *ibuf) } int -ofp_output(struct switch_connection *con, struct ofp_header *oh, - struct ibuf *obuf) -{ - struct ibuf *buf; - - if ((buf = ibuf_static()) == NULL) - return (-1); - if ((oh != NULL) && - (ibuf_add(buf, oh, sizeof(*oh)) == -1)) { - ibuf_release(buf); - return (-1); - } - if ((obuf != NULL) && - (ibuf_cat(buf, obuf) == -1)) { - ibuf_release(buf); - return (-1); - } - - ofrelay_write(con, buf); - - return (0); -} - -int ofp_open(struct privsep *ps, struct switch_connection *con) { struct switch_control *sw; diff --git a/usr.sbin/switchd/ofp13.c b/usr.sbin/switchd/ofp13.c index 9df6d80f5cc..d130386e78f 100644 --- a/usr.sbin/switchd/ofp13.c +++ b/usr.sbin/switchd/ofp13.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofp13.c,v 1.21 2016/10/13 08:29:14 rzalamena Exp $ */ +/* $OpenBSD: ofp13.c,v 1.22 2016/11/04 22:27:08 reyk Exp $ */ /* * Copyright (c) 2013-2016 Reyk Floeter <reyk@openbsd.org> @@ -43,12 +43,6 @@ #include "switchd.h" #include "ofp_map.h" -int ofp13_validate(struct switchd *, - struct sockaddr_storage *, struct sockaddr_storage *, - struct ofp_header *, struct ibuf *); - -int ofp13_hello(struct switchd *, struct switch_connection *, - struct ofp_header *, struct ibuf *); int ofp13_echo_request(struct switchd *, struct switch_connection *, struct ofp_header *, struct ibuf *); int ofp13_validate_features_reply(struct switchd *, @@ -90,11 +84,6 @@ int ofp13_multipart_request_validate(struct switchd *, struct sockaddr_storage *, struct sockaddr_storage *, struct ofp_header *, struct ibuf *); -int ofp13_desc(struct switchd *, struct switch_connection *); -int ofp13_flow_stats(struct switchd *, struct switch_connection *, - uint32_t, uint32_t, uint8_t); -int ofp13_table_features(struct switchd *, struct switch_connection *, - uint8_t); int ofp13_error(struct switchd *, struct switch_connection *, struct ofp_header *, struct ibuf *, uint16_t, uint16_t); @@ -109,8 +98,6 @@ int ofp13_setconfig_validate(struct switchd *, struct ofp_header *, struct ibuf *); int ofp13_setconfig(struct switchd *, struct switch_connection *, uint16_t, uint16_t); -int ofp13_featuresrequest(struct switchd *, struct switch_connection *); - struct ofp_callback ofp13_callbacks[] = { { OFP_T_HELLO, ofp13_hello, NULL }, diff --git a/usr.sbin/switchd/ofp_common.c b/usr.sbin/switchd/ofp_common.c index 96fdb20ed17..fee9da2c82b 100644 --- a/usr.sbin/switchd/ofp_common.c +++ b/usr.sbin/switchd/ofp_common.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofp_common.c,v 1.1 2016/10/07 08:49:53 reyk Exp $ */ +/* $OpenBSD: ofp_common.c,v 1.2 2016/11/04 22:27:08 reyk Exp $ */ /* * Copyright (c) 2013-2016 Reyk Floeter <reyk@openbsd.org> @@ -43,6 +43,30 @@ #include "switchd.h" #include "ofp_map.h" +int +ofp_output(struct switch_connection *con, struct ofp_header *oh, + struct ibuf *obuf) +{ + struct ibuf *buf; + + if ((buf = ibuf_static()) == NULL) + return (-1); + if ((oh != NULL) && + (ibuf_add(buf, oh, sizeof(*oh)) == -1)) { + ibuf_release(buf); + return (-1); + } + if ((obuf != NULL) && + (ibuf_cat(buf, obuf) == -1)) { + ibuf_release(buf); + return (-1); + } + + ofrelay_write(con, buf); + + return (0); +} + /* Appends an action with just the generic header. */ int action_new(struct ibuf *ibuf, uint16_t type) diff --git a/usr.sbin/switchd/switchd.h b/usr.sbin/switchd/switchd.h index ad94ee56306..6a43deb83e0 100644 --- a/usr.sbin/switchd/switchd.h +++ b/usr.sbin/switchd/switchd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: switchd.h,v 1.16 2016/10/12 19:07:42 reyk Exp $ */ +/* $OpenBSD: switchd.h,v 1.17 2016/11/04 22:27:08 reyk Exp $ */ /* * Copyright (c) 2013-2016 Reyk Floeter <reyk@openbsd.org> @@ -224,8 +224,6 @@ void ofrelay_write(struct switch_connection *, struct ibuf *); void ofp(struct privsep *, struct privsep_proc *); void ofp_close(struct switch_connection *); int ofp_open(struct privsep *, struct switch_connection *); -int ofp_output(struct switch_connection *, struct ofp_header *, - struct ibuf *); void ofp_accept(int, short, void *); int ofp_validate_header(struct switchd *, struct sockaddr_storage *, struct sockaddr_storage *, @@ -244,8 +242,22 @@ int ofp10_input(struct switchd *, struct switch_connection *, /* ofp13.c */ int ofp13_input(struct switchd *, struct switch_connection *, struct ofp_header *, struct ibuf *); +int ofp13_hello(struct switchd *, struct switch_connection *, + struct ofp_header *oh, struct ibuf *); +int ofp13_validate(struct switchd *, + struct sockaddr_storage *, struct sockaddr_storage *, + struct ofp_header *, struct ibuf *); +int ofp13_desc(struct switchd *, struct switch_connection *); +int ofp13_flow_stats(struct switchd *, struct switch_connection *, + uint32_t, uint32_t, uint8_t); +int ofp13_table_features(struct switchd *, + struct switch_connection *, uint8_t); +int ofp13_featuresrequest(struct switchd *, + struct switch_connection *); /* ofp_common.c */ +int ofp_output(struct switch_connection *, struct ofp_header *, + struct ibuf *); int ofp_multipart_add(struct switch_connection *, uint32_t, uint8_t); void ofp_multipart_del(struct switch_connection *, uint32_t); |