+ unsigned int port32;
+
+ if (str_to_uint(s, 10, &port32)) {
+ if (port32 == 0) {
+ VLOG_WARN("port 0 is not a valid OpenFlow port number");
+ return 0;
+ } else if (port32 < OFPP_MAX) {
+ return port32;
+ } else if (port32 < OFPP_FIRST_RESV) {
+ VLOG_WARN("port %u is a reserved OF1.0 port number that will "
+ "be translated to %u when talking to an OF1.1 or "
+ "later controller", port32, port32 + OFPP11_OFFSET);
+ return port32;
+ } else if (port32 <= OFPP_LAST_RESV) {
+ struct ds s;
+
+ ds_init(&s);
+ ofputil_format_port(port32, &s);
+ VLOG_WARN("port %u is better referred to as %s, for compatibility "
+ "with future versions of OpenFlow",
+ port32, ds_cstr(&s));
+ ds_destroy(&s);
+
+ return port32;
+ } else if (port32 < OFPP11_MAX) {
+ VLOG_WARN("port %u is outside the supported range 0 through "
+ "%"PRIx16"or 0x%x through 0x%"PRIx32, port32,
+ UINT16_MAX, (unsigned int) OFPP11_MAX, UINT32_MAX);
+ return 0;
+ } else {
+ return port32 - OFPP11_OFFSET;
+ }
+ } else {
+ struct pair {
+ const char *name;
+ uint16_t value;
+ };
+ static const struct pair pairs[] = {