Merge branch "partner", to simplify partner integration.
[sliver-openvswitch.git] / lib / vconn-ssl.c
index bac39b5..2801c0c 100644 (file)
 #include <openssl/ssl.h>
 #include <poll.h>
 #include <unistd.h>
-#include "buffer.h"
+#include "ofpbuf.h"
 #include "socket-util.h"
 #include "util.h"
 #include "openflow.h"
 #include "packets.h"
 #include "poll-loop.h"
-#include "ofp-print.h"
 #include "socket-util.h"
 #include "vconn.h"
 #include "vconn-provider.h"
@@ -77,8 +76,8 @@ struct ssl_vconn
     enum session_type type;
     int fd;
     SSL *ssl;
-    struct buffer *rxbuf;
-    struct buffer *txbuf;
+    struct ofpbuf *rxbuf;
+    struct ofpbuf *txbuf;
     struct poll_waiter *tx_waiter;
 
     /* rx_want and tx_want record the result of the last call to SSL_read()
@@ -275,7 +274,7 @@ ssl_open(const char *name, char *suffix, struct vconn **vconnp)
     host_name = strtok_r(suffix, "::", &save_ptr);
     port_string = strtok_r(NULL, "::", &save_ptr);
     if (!host_name) {
-        error(0, "%s: bad peer name format", name);
+        ofp_error(0, "%s: bad peer name format", name);
         return EAFNOSUPPORT;
     }
 
@@ -440,16 +439,16 @@ interpret_ssl_error(const char *function, int ret, int error,
 }
 
 static int
-ssl_recv(struct vconn *vconn, struct buffer **bufferp)
+ssl_recv(struct vconn *vconn, struct ofpbuf **bufferp)
 {
     struct ssl_vconn *sslv = ssl_vconn_cast(vconn);
-    struct buffer *rx;
+    struct ofpbuf *rx;
     size_t want_bytes;
     int old_state;
     ssize_t ret;
 
     if (sslv->rxbuf == NULL) {
-        sslv->rxbuf = buffer_new(1564);
+        sslv->rxbuf = ofpbuf_new(1564);
     }
     rx = sslv->rxbuf;
 
@@ -471,13 +470,13 @@ again:
             return 0;
         }
     }
-    buffer_prealloc_tailroom(rx, want_bytes);
+    ofpbuf_prealloc_tailroom(rx, want_bytes);
 
     /* Behavior of zero-byte SSL_read is poorly defined. */
     assert(want_bytes > 0);
 
     old_state = SSL_get_state(sslv->ssl);
-    ret = SSL_read(sslv->ssl, buffer_tail(rx), want_bytes);
+    ret = SSL_read(sslv->ssl, ofpbuf_tail(rx), want_bytes);
     if (old_state != SSL_get_state(sslv->ssl)) {
         sslv->tx_want = SSL_NOTHING;
         if (sslv->tx_waiter) {
@@ -518,7 +517,7 @@ again:
 static void
 ssl_clear_txbuf(struct ssl_vconn *sslv)
 {
-    buffer_delete(sslv->txbuf);
+    ofpbuf_delete(sslv->txbuf);
     sslv->txbuf = NULL;
     sslv->tx_waiter = NULL;
 }
@@ -545,7 +544,7 @@ ssl_do_tx(struct vconn *vconn)
         }
         sslv->tx_want = SSL_NOTHING;
         if (ret > 0) {
-            buffer_pull(sslv->txbuf, ret);
+            ofpbuf_pull(sslv->txbuf, ret);
             if (sslv->txbuf->size == 0) {
                 return 0;
             }
@@ -576,7 +575,7 @@ ssl_tx_poll_callback(int fd UNUSED, short int revents UNUSED, void *vconn_)
 }
 
 static int
-ssl_send(struct vconn *vconn, struct buffer *buffer)
+ssl_send(struct vconn *vconn, struct ofpbuf *buffer)
 {
     struct ssl_vconn *sslv = ssl_vconn_cast(vconn);
 
@@ -652,13 +651,13 @@ ssl_wait(struct vconn *vconn, enum vconn_wait_type wait)
 }
 
 struct vconn_class ssl_vconn_class = {
-    .name = "ssl",
-    .open = ssl_open,
-    .close = ssl_close,
-    .connect = ssl_connect,
-    .recv = ssl_recv,
-    .send = ssl_send,
-    .wait = ssl_wait,
+    "ssl",                      /* name */
+    ssl_open,                   /* open */
+    ssl_close,                  /* close */
+    ssl_connect,                /* connect */
+    ssl_recv,                   /* recv */
+    ssl_send,                   /* send */
+    ssl_wait,                   /* wait */
 };
 \f
 /* Passive SSL. */
@@ -869,8 +868,8 @@ tmp_dh_callback(SSL *ssl, int is_export UNUSED, int keylength)
             if (!dh->dh) {
                 dh->dh = dh->constructor();
                 if (!dh->dh) {
-                    fatal(ENOMEM, "out of memory constructing "
-                          "Diffie-Hellman parameters");
+                    ofp_fatal(ENOMEM, "out of memory constructing "
+                              "Diffie-Hellman parameters");
                 }
             }
             return dh->dh;