From 9eb7e775549526e6cf6a404bbba05b8ea656cbf6 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 28 Jun 2010 14:03:17 -0700 Subject: [PATCH] ofp-util: New functions hton_ofp_phy_port(), ntoh_ofp_phy_port(). The former is moved here from wdp-xflow, the latter is added just for completeness. --- lib/ofp-util.c | 20 ++++++++++++++++++++ lib/ofp-util.h | 3 +++ ofproto/wdp-xflow.c | 12 ------------ 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/lib/ofp-util.c b/lib/ofp-util.c index 4fc5ed41b..bc96240a3 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -754,3 +754,23 @@ normalize_match(struct ofp_match *m) m->wildcards = htonl(wc); } +/* Converts all of the fields in 'opp' from host to native byte-order. */ +void +hton_ofp_phy_port(struct ofp_phy_port *opp) +{ + opp->port_no = htons(opp->port_no); + opp->config = htonl(opp->config); + opp->state = htonl(opp->state); + opp->curr = htonl(opp->curr); + opp->advertised = htonl(opp->advertised); + opp->supported = htonl(opp->supported); + opp->peer = htonl(opp->peer); +} + +/* Converts all of the fields in 'opp' from native to host byte-order. */ +void +ntoh_ofp_phy_port(struct ofp_phy_port *opp) +{ + /* ntohX and htonX are really the same functions. */ + hton_ofp_phy_port(opp); +} diff --git a/lib/ofp-util.h b/lib/ofp-util.h index 2c6b2f919..e4927f6fe 100644 --- a/lib/ofp-util.h +++ b/lib/ofp-util.h @@ -82,6 +82,9 @@ bool action_outputs_to_port(const union ofp_action *, uint16_t port); void normalize_match(struct ofp_match *); +void hton_ofp_phy_port(struct ofp_phy_port *); +void ntoh_ofp_phy_port(struct ofp_phy_port *); + static inline int ofp_mkerr(uint16_t type, uint16_t code) { diff --git a/ofproto/wdp-xflow.c b/ofproto/wdp-xflow.c index 66b245a77..56067e641 100644 --- a/ofproto/wdp-xflow.c +++ b/ofproto/wdp-xflow.c @@ -1260,18 +1260,6 @@ wx_destroy(struct wdp *wdp) return xfif_delete(wx->xfif); } -static void -hton_ofp_phy_port(struct ofp_phy_port *opp) -{ - opp->port_no = htons(opp->port_no); - opp->config = htonl(opp->config); - opp->state = htonl(opp->state); - opp->curr = htonl(opp->curr); - opp->advertised = htonl(opp->advertised); - opp->supported = htonl(opp->supported); - opp->peer = htonl(opp->peer); -} - static int wx_get_features(const struct wdp *wdp, struct ofpbuf **featuresp) { -- 2.43.0