aboutsummaryrefslogtreecommitdiff
path: root/lib/vconn.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2012-01-12 15:48:19 -0800
committerBen Pfaff <blp@nicira.com>2012-01-12 15:54:25 -0800
commit90bf1e0732ac9b11dd51ca856b635cac1f0269c1 (patch)
tree05e5852229f3b6f85218a74f9401b3b765459599 /lib/vconn.c
parente25c55d28f30b537aa657797c41483a9bab59b93 (diff)
Better abstract OpenFlow error codes.
This commit switches from using the actual protocol values of error codes internally in Open vSwitch, to using abstract values that are translated to and from protocol values at message parsing and serialization time. I believe that this makes the code easier to read and to write. This is also one step along the way toward OpenFlow 1.1 support because OpenFlow 1.1 renumbered a bunch of error codes. Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'lib/vconn.c')
-rw-r--r--lib/vconn.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/vconn.c b/lib/vconn.c
index 6ea93667..8e6374e7 100644
--- a/lib/vconn.c
+++ b/lib/vconn.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2009, 2010 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
#include "dynamic-string.h"
#include "fatal-signal.h"
#include "flow.h"
+#include "ofp-errors.h"
#include "ofp-print.h"
#include "ofp-util.h"
#include "ofpbuf.h"
@@ -442,7 +443,6 @@ vcs_recv_hello(struct vconn *vconn)
static void
vcs_send_error(struct vconn *vconn)
{
- struct ofp_error_msg *error;
struct ofpbuf *b;
char s[128];
int retval;
@@ -450,11 +450,8 @@ vcs_send_error(struct vconn *vconn)
snprintf(s, sizeof s, "We support versions 0x%02x to 0x%02x inclusive but "
"you support no later than version 0x%02"PRIx8".",
vconn->min_version, OFP_VERSION, vconn->version);
- error = make_openflow(sizeof *error, OFPT_ERROR, &b);
- error->type = htons(OFPET_HELLO_FAILED);
- error->code = htons(OFPHFC_INCOMPATIBLE);
- ofpbuf_put(b, s, strlen(s));
- update_openflow_length(b);
+ b = ofperr_encode_hello(OFPERR_OFPHFC_INCOMPATIBLE,
+ ofperr_domain_from_version(vconn->version), s);
retval = do_send(vconn, b);
if (retval) {
ofpbuf_delete(b);