rconn: Fix null pointer dereference in rconn_add_monitor().
[sliver-openvswitch.git] / lib / vconn.h
1 /*
2  * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef VCONN_H
18 #define VCONN_H 1
19
20 #include <stdbool.h>
21 #include "openvswitch/types.h"
22 #include "openflow/openflow.h"
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 struct list;
29 struct ofpbuf;
30 struct pvconn;
31 struct vconn;
32
33 void vconn_usage(bool active, bool passive, bool bootstrap);
34
35 /* Active vconns: virtual connections to OpenFlow devices. */
36 int vconn_verify_name(const char *name);
37 int vconn_open(const char *name, uint32_t allowed_versions, uint8_t dscp,
38                struct vconn **vconnp);
39 void vconn_close(struct vconn *);
40 const char *vconn_get_name(const struct vconn *);
41
42 uint32_t vconn_get_allowed_versions(const struct vconn *vconn);
43 void vconn_set_allowed_versions(struct vconn *vconn,
44                                 uint32_t allowed_versions);
45 int vconn_get_version(const struct vconn *);
46 void vconn_set_recv_any_version(struct vconn *);
47
48 ovs_be32 vconn_get_remote_ip(const struct vconn *);
49 ovs_be16 vconn_get_remote_port(const struct vconn *);
50 ovs_be32 vconn_get_local_ip(const struct vconn *);
51 ovs_be16 vconn_get_local_port(const struct vconn *);
52
53 int vconn_connect(struct vconn *);
54 int vconn_recv(struct vconn *, struct ofpbuf **);
55 int vconn_send(struct vconn *, struct ofpbuf *);
56 int vconn_recv_xid(struct vconn *, ovs_be32 xid, struct ofpbuf **);
57 int vconn_transact(struct vconn *, struct ofpbuf *, struct ofpbuf **);
58 int vconn_transact_noreply(struct vconn *, struct ofpbuf *, struct ofpbuf **);
59 int vconn_transact_multiple_noreply(struct vconn *, struct list *requests,
60                                     struct ofpbuf **replyp);
61
62 void vconn_run(struct vconn *);
63 void vconn_run_wait(struct vconn *);
64
65 int vconn_open_block(const char *name, uint32_t allowed_versions, uint8_t dscp,
66                      struct vconn **);
67 int vconn_connect_block(struct vconn *);
68 int vconn_send_block(struct vconn *, struct ofpbuf *);
69 int vconn_recv_block(struct vconn *, struct ofpbuf **);
70
71 enum vconn_wait_type {
72     WAIT_CONNECT,
73     WAIT_RECV,
74     WAIT_SEND
75 };
76 void vconn_wait(struct vconn *, enum vconn_wait_type);
77 void vconn_connect_wait(struct vconn *);
78 void vconn_recv_wait(struct vconn *);
79 void vconn_send_wait(struct vconn *);
80
81 /* Passive vconns: virtual listeners for incoming OpenFlow connections. */
82 int pvconn_verify_name(const char *name);
83 int pvconn_open(const char *name, uint32_t allowed_versions, uint8_t dscp,
84                 struct pvconn **pvconnp);
85 const char *pvconn_get_name(const struct pvconn *);
86 void pvconn_close(struct pvconn *);
87 int pvconn_accept(struct pvconn *, struct vconn **);
88 void pvconn_wait(struct pvconn *);
89
90 #ifdef __cplusplus
91 }
92 #endif
93
94 #endif /* vconn.h */