diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2016-11-17 10:05:45 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2016-11-17 10:05:45 +0000 |
commit | 85cb953cdab70e0b5bbaf0286f11d65961d037aa (patch) | |
tree | 15aa0d5dc57e7da307aa22e002db8ca0d16feabf /usr.sbin | |
parent | 6f09aefc3da8aaa3de36589d4e9beae41b901cad (diff) |
Add ofp_validate() for all supported versions. Will be used by switchctl,
no functional change.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/switchctl/Makefile | 4 | ||||
-rw-r--r-- | usr.sbin/switchd/ofp_common.c | 19 | ||||
-rw-r--r-- | usr.sbin/switchd/switchd.h | 5 |
3 files changed, 24 insertions, 4 deletions
diff --git a/usr.sbin/switchctl/Makefile b/usr.sbin/switchctl/Makefile index 4563831c148..83b28ccb824 100644 --- a/usr.sbin/switchctl/Makefile +++ b/usr.sbin/switchctl/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.3 2016/11/15 08:15:07 reyk Exp $ +# $OpenBSD: Makefile,v 1.4 2016/11/17 10:05:44 reyk Exp $ SWITCHD= ${.CURDIR}/../switchd @@ -7,7 +7,7 @@ SWITCHD= ${.CURDIR}/../switchd PROG= switchctl MAN= switchctl.8 SRCS= log.c ofpclient.c parser.c util.c imsg_util.c switchctl.c -SRCS+= ofp13.c ofp_common.c packet.c +SRCS+= ofp10.c ofp13.c ofp_common.c packet.c LDADD= -lutil DPADD= ${LIBUTIL} diff --git a/usr.sbin/switchd/ofp_common.c b/usr.sbin/switchd/ofp_common.c index 09047dd34b9..a2aa8446224 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.4 2016/11/17 09:42:11 rzalamena Exp $ */ +/* $OpenBSD: ofp_common.c,v 1.5 2016/11/17 10:05:44 reyk Exp $ */ /* * Copyright (c) 2013-2016 Reyk Floeter <reyk@openbsd.org> @@ -78,6 +78,23 @@ ofp_validate_header(struct switchd *sc, } int +ofp_validate(struct switchd *sc, + struct sockaddr_storage *src, struct sockaddr_storage *dst, + struct ofp_header *oh, struct ibuf *ibuf, uint8_t version) +{ + switch (version) { + case OFP_V_1_0: + return (ofp10_validate(sc, src, dst, oh, ibuf)); + case OFP_V_1_3: + return (ofp13_validate(sc, src, dst, oh, ibuf)); + default: + return (-1); + } + + /* NOTREACHED */ +} + +int ofp_output(struct switch_connection *con, struct ofp_header *oh, struct ibuf *obuf) { diff --git a/usr.sbin/switchd/switchd.h b/usr.sbin/switchd/switchd.h index 1665e509c0d..dfdc01c5d45 100644 --- a/usr.sbin/switchd/switchd.h +++ b/usr.sbin/switchd/switchd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: switchd.h,v 1.21 2016/11/17 09:42:11 rzalamena Exp $ */ +/* $OpenBSD: switchd.h,v 1.22 2016/11/17 10:05:44 reyk Exp $ */ /* * Copyright (c) 2013-2016 Reyk Floeter <reyk@openbsd.org> @@ -259,6 +259,9 @@ struct ofp_flow_mod * int ofp_validate_header(struct switchd *, struct sockaddr_storage *, struct sockaddr_storage *, struct ofp_header *, uint8_t); +int ofp_validate(struct switchd *, + struct sockaddr_storage *, struct sockaddr_storage *, + struct ofp_header *, struct ibuf *, uint8_t); int ofp_output(struct switch_connection *, struct ofp_header *, struct ibuf *); int ofp_multipart_add(struct switch_connection *, uint32_t, |