/src/openvswitch/include/openvswitch/ofpbuf.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2015, 2016 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 OPENVSWITCH_OFPBUF_H |
18 | | #define OPENVSWITCH_OFPBUF_H 1 |
19 | | |
20 | | #include <stddef.h> |
21 | | #include <stdint.h> |
22 | | #include <stdlib.h> |
23 | | #include <string.h> |
24 | | #include "openvswitch/dynamic-string.h" |
25 | | #include "openvswitch/list.h" |
26 | | #include "openvswitch/util.h" |
27 | | |
28 | | #ifdef __cplusplus |
29 | | extern "C" { |
30 | | #endif |
31 | | |
32 | | enum OVS_PACKED_ENUM ofpbuf_source { |
33 | | OFPBUF_MALLOC, /* Obtained via malloc(). */ |
34 | | OFPBUF_STACK, /* Un-movable stack space or static buffer. */ |
35 | | OFPBUF_STUB, /* Starts on stack, may expand into heap. */ |
36 | | }; |
37 | | |
38 | | /* Buffer for holding arbitrary data. An ofpbuf is automatically reallocated |
39 | | * as necessary if it grows too large for the available memory. |
40 | | * |
41 | | * 'header' and 'msg' conventions: |
42 | | * |
43 | | * OpenFlow messages: 'header' points to the start of the OpenFlow |
44 | | * header, while 'msg' is the OpenFlow msg body. |
45 | | * When parsing, the 'data' will move past these, as data is being |
46 | | * pulled from the OpenFlow message. |
47 | | * |
48 | | * Caution: buffer manipulation of 'struct ofpbuf' must always update |
49 | | * the 'header' and 'msg' pointers. |
50 | | * |
51 | | * |
52 | | * Actions: When encoding OVS action lists, the 'header' is used |
53 | | * as a pointer to the beginning of the current action (see ofpact_put()). |
54 | | * |
55 | | * rconn: Reuses 'header' as a private pointer while queuing. |
56 | | */ |
57 | | struct ofpbuf { |
58 | | void *base; /* First byte of allocated space. */ |
59 | | void *data; /* First byte actually in use. */ |
60 | | uint32_t size; /* Number of bytes in use. */ |
61 | | uint32_t allocated; /* Number of bytes allocated. */ |
62 | | |
63 | | void *header; /* OpenFlow header. */ |
64 | | void *msg; /* message's body */ |
65 | | struct ovs_list list_node; /* Private list element for use by owner. */ |
66 | | enum ofpbuf_source source; /* Source of memory allocated as 'base'. */ |
67 | | }; |
68 | | |
69 | | /* An initializer for a struct ofpbuf that will be initially empty and uses the |
70 | | * space in STUB (which should be an array) as a stub. This is the initializer |
71 | | * form of ofpbuf_use_stub(). |
72 | | * |
73 | | * Usage example: |
74 | | * |
75 | | * uint64_t stub[1024 / 8]; <-- 1 kB stub aligned for 64-bit data. |
76 | | * struct ofpbuf ofpbuf = OFPBUF_STUB_INITIALIZER(stub); |
77 | | */ |
78 | | #define OFPBUF_STUB_INITIALIZER(STUB) { \ |
79 | | .base = (STUB), \ |
80 | | .data = (STUB), \ |
81 | | .size = 0, \ |
82 | | .allocated = sizeof (STUB), \ |
83 | | .header = NULL, \ |
84 | | .msg = NULL, \ |
85 | | .list_node = OVS_LIST_POISON, \ |
86 | | .source = OFPBUF_STUB, \ |
87 | | } |
88 | | |
89 | | /* An initializer for a struct ofpbuf whose data starts at DATA and continues |
90 | | * for SIZE bytes. This is appropriate for an ofpbuf that will be used to |
91 | | * inspect existing data, without moving it around or reallocating it, and |
92 | | * generally without modifying it at all. This is the initializer form of |
93 | | * ofpbuf_use_const(). |
94 | | */ |
95 | | static inline struct ofpbuf |
96 | | ofpbuf_const_initializer(const void *data, uint32_t size) |
97 | 0 | { |
98 | 0 | return (struct ofpbuf) { |
99 | 0 | .base = CONST_CAST(void *, data), |
100 | 0 | .data = CONST_CAST(void *, data), |
101 | 0 | .size = size, |
102 | 0 | .allocated = size, |
103 | 0 | .header = NULL, |
104 | 0 | .msg = NULL, |
105 | 0 | .list_node = OVS_LIST_POISON, |
106 | 0 | .source = OFPBUF_STACK, |
107 | 0 | }; |
108 | 0 | } Unexecuted instantiation: jsonrpc.c:ofpbuf_const_initializer Unexecuted instantiation: ofpbuf.c:ofpbuf_const_initializer Unexecuted instantiation: socket-util.c:ofpbuf_const_initializer Unexecuted instantiation: stream.c:ofpbuf_const_initializer Unexecuted instantiation: vlog.c:ofpbuf_const_initializer Unexecuted instantiation: stream-unix.c:ofpbuf_const_initializer Unexecuted instantiation: stream-ssl.c:ofpbuf_const_initializer Unexecuted instantiation: packets.c:ofpbuf_const_initializer Unexecuted instantiation: stream-tcp.c:ofpbuf_const_initializer Unexecuted instantiation: dp-packet.c:ofpbuf_const_initializer |
109 | | |
110 | | void ofpbuf_use_ds(struct ofpbuf *, const struct ds *); |
111 | | void ofpbuf_use_stack(struct ofpbuf *, void *, size_t); |
112 | | void ofpbuf_use_stub(struct ofpbuf *, void *, size_t); |
113 | | void ofpbuf_use_const(struct ofpbuf *, const void *, size_t); |
114 | | void ofpbuf_use_data(struct ofpbuf *, const void *, size_t); |
115 | | |
116 | | void ofpbuf_init(struct ofpbuf *, size_t); |
117 | | void ofpbuf_uninit(struct ofpbuf *); |
118 | | void ofpbuf_reinit(struct ofpbuf *, size_t); |
119 | | |
120 | | struct ofpbuf *ofpbuf_new(size_t); |
121 | | struct ofpbuf *ofpbuf_new_with_headroom(size_t, size_t headroom); |
122 | | struct ofpbuf *ofpbuf_clone(const struct ofpbuf *); |
123 | | struct ofpbuf *ofpbuf_clone_with_headroom(const struct ofpbuf *, |
124 | | size_t headroom); |
125 | | struct ofpbuf *ofpbuf_clone_data(const void *, size_t); |
126 | | struct ofpbuf *ofpbuf_clone_data_with_headroom(const void *, size_t, |
127 | | size_t headroom); |
128 | | static inline void ofpbuf_delete(struct ofpbuf *); |
129 | | |
130 | | static inline void *ofpbuf_at(const struct ofpbuf *, size_t offset, |
131 | | size_t size); |
132 | | static inline void *ofpbuf_at_assert(const struct ofpbuf *, size_t offset, |
133 | | size_t size); |
134 | | static inline void *ofpbuf_tail(const struct ofpbuf *); |
135 | | static inline void *ofpbuf_end(const struct ofpbuf *); |
136 | | |
137 | | void *ofpbuf_put_uninit(struct ofpbuf *, size_t); |
138 | | void *ofpbuf_put_zeros(struct ofpbuf *, size_t); |
139 | | void *ofpbuf_put(struct ofpbuf *, const void *, size_t); |
140 | | char *ofpbuf_put_hex(struct ofpbuf *, const char *s, size_t *n); |
141 | | void ofpbuf_reserve(struct ofpbuf *, size_t); |
142 | | void *ofpbuf_push_uninit(struct ofpbuf *b, size_t); |
143 | | void *ofpbuf_push_zeros(struct ofpbuf *, size_t); |
144 | | void *ofpbuf_push(struct ofpbuf *b, const void *, size_t); |
145 | | void ofpbuf_insert(struct ofpbuf *b, size_t offset, const void *data, size_t); |
146 | | |
147 | | static inline size_t ofpbuf_headroom(const struct ofpbuf *); |
148 | | static inline size_t ofpbuf_tailroom(const struct ofpbuf *); |
149 | | static inline size_t ofpbuf_msgsize(const struct ofpbuf *); |
150 | | void ofpbuf_prealloc_headroom(struct ofpbuf *, size_t); |
151 | | void ofpbuf_prealloc_tailroom(struct ofpbuf *, size_t); |
152 | | void ofpbuf_trim(struct ofpbuf *); |
153 | | void ofpbuf_align(struct ofpbuf *); |
154 | | void ofpbuf_padto(struct ofpbuf *, size_t); |
155 | | void ofpbuf_shift(struct ofpbuf *, int); |
156 | | |
157 | | static inline void ofpbuf_clear(struct ofpbuf *); |
158 | | static inline void *ofpbuf_pull(struct ofpbuf *, size_t); |
159 | | static inline void *ofpbuf_try_pull(struct ofpbuf *, size_t); |
160 | | |
161 | | void *ofpbuf_steal_data(struct ofpbuf *); |
162 | | |
163 | | char *ofpbuf_to_string(const struct ofpbuf *, size_t maxbytes); |
164 | | static inline struct ofpbuf *ofpbuf_from_list(const struct ovs_list *); |
165 | | void ofpbuf_list_delete(struct ovs_list *); |
166 | | static inline bool ofpbuf_equal(const struct ofpbuf *, const struct ofpbuf *); |
167 | | static inline bool ofpbuf_oversized(const struct ofpbuf *ofpacts); |
168 | | |
169 | | |
170 | | /* Frees memory that 'b' points to, as well as 'b' itself. */ |
171 | | static inline void ofpbuf_delete(struct ofpbuf *b) |
172 | 0 | { |
173 | 0 | if (b) { |
174 | 0 | ofpbuf_uninit(b); |
175 | 0 | free(b); |
176 | 0 | } |
177 | 0 | } Unexecuted instantiation: jsonrpc.c:ofpbuf_delete Unexecuted instantiation: ofpbuf.c:ofpbuf_delete Unexecuted instantiation: socket-util.c:ofpbuf_delete Unexecuted instantiation: stream.c:ofpbuf_delete Unexecuted instantiation: vlog.c:ofpbuf_delete Unexecuted instantiation: stream-unix.c:ofpbuf_delete Unexecuted instantiation: stream-ssl.c:ofpbuf_delete Unexecuted instantiation: packets.c:ofpbuf_delete Unexecuted instantiation: stream-tcp.c:ofpbuf_delete Unexecuted instantiation: dp-packet.c:ofpbuf_delete |
178 | | |
179 | | /* If 'b' contains at least 'offset + size' bytes of data, returns a pointer to |
180 | | * byte 'offset'. Otherwise, returns a null pointer. */ |
181 | | static inline void *ofpbuf_at(const struct ofpbuf *b, size_t offset, |
182 | | size_t size) |
183 | 0 | { |
184 | 0 | if (offset + size <= b->size) { |
185 | 0 | ovs_assert(b->data); |
186 | 0 | return (char *) b->data + offset; |
187 | 0 | } |
188 | 0 | return NULL; |
189 | 0 | } Unexecuted instantiation: jsonrpc.c:ofpbuf_at Unexecuted instantiation: ofpbuf.c:ofpbuf_at Unexecuted instantiation: socket-util.c:ofpbuf_at Unexecuted instantiation: stream.c:ofpbuf_at Unexecuted instantiation: vlog.c:ofpbuf_at Unexecuted instantiation: stream-unix.c:ofpbuf_at Unexecuted instantiation: stream-ssl.c:ofpbuf_at Unexecuted instantiation: packets.c:ofpbuf_at Unexecuted instantiation: stream-tcp.c:ofpbuf_at Unexecuted instantiation: dp-packet.c:ofpbuf_at |
190 | | |
191 | | /* Returns a pointer to byte 'offset' in 'b', which must contain at least |
192 | | * 'offset + size' bytes of data. */ |
193 | | static inline void *ofpbuf_at_assert(const struct ofpbuf *b, size_t offset, |
194 | | size_t size) |
195 | 0 | { |
196 | 0 | ovs_assert(offset + size <= b->size); |
197 | 0 | ovs_assert(b->data); |
198 | 0 | return (char *) b->data + offset; |
199 | 0 | } Unexecuted instantiation: jsonrpc.c:ofpbuf_at_assert Unexecuted instantiation: ofpbuf.c:ofpbuf_at_assert Unexecuted instantiation: socket-util.c:ofpbuf_at_assert Unexecuted instantiation: stream.c:ofpbuf_at_assert Unexecuted instantiation: vlog.c:ofpbuf_at_assert Unexecuted instantiation: stream-unix.c:ofpbuf_at_assert Unexecuted instantiation: stream-ssl.c:ofpbuf_at_assert Unexecuted instantiation: packets.c:ofpbuf_at_assert Unexecuted instantiation: stream-tcp.c:ofpbuf_at_assert Unexecuted instantiation: dp-packet.c:ofpbuf_at_assert |
200 | | |
201 | | /* Returns a pointer to byte following the last byte of data in use in 'b'. */ |
202 | | static inline void *ofpbuf_tail(const struct ofpbuf *b) |
203 | 0 | { |
204 | 0 | ovs_assert(b->data || !b->size); |
205 | 0 | return b->data ? (char *) b->data + b->size : NULL; |
206 | 0 | } Unexecuted instantiation: jsonrpc.c:ofpbuf_tail Unexecuted instantiation: ofpbuf.c:ofpbuf_tail Unexecuted instantiation: socket-util.c:ofpbuf_tail Unexecuted instantiation: stream.c:ofpbuf_tail Unexecuted instantiation: vlog.c:ofpbuf_tail Unexecuted instantiation: stream-unix.c:ofpbuf_tail Unexecuted instantiation: stream-ssl.c:ofpbuf_tail Unexecuted instantiation: packets.c:ofpbuf_tail Unexecuted instantiation: stream-tcp.c:ofpbuf_tail Unexecuted instantiation: dp-packet.c:ofpbuf_tail |
207 | | |
208 | | /* Returns a pointer to byte following the last byte allocated for use (but |
209 | | * not necessarily in use) in 'b'. */ |
210 | | static inline void *ofpbuf_end(const struct ofpbuf *b) |
211 | 0 | { |
212 | 0 | ovs_assert(b->base || !b->allocated); |
213 | 0 | return b->base ? (char *) b->base + b->allocated : NULL; |
214 | 0 | } Unexecuted instantiation: jsonrpc.c:ofpbuf_end Unexecuted instantiation: ofpbuf.c:ofpbuf_end Unexecuted instantiation: socket-util.c:ofpbuf_end Unexecuted instantiation: stream.c:ofpbuf_end Unexecuted instantiation: vlog.c:ofpbuf_end Unexecuted instantiation: stream-unix.c:ofpbuf_end Unexecuted instantiation: stream-ssl.c:ofpbuf_end Unexecuted instantiation: packets.c:ofpbuf_end Unexecuted instantiation: stream-tcp.c:ofpbuf_end Unexecuted instantiation: dp-packet.c:ofpbuf_end |
215 | | |
216 | | /* Returns the number of bytes of headroom in 'b', that is, the number of bytes |
217 | | * of unused space in ofpbuf 'b' before the data that is in use. (Most |
218 | | * commonly, the data in a ofpbuf is at its beginning, and thus the ofpbuf's |
219 | | * headroom is 0.) */ |
220 | | static inline size_t ofpbuf_headroom(const struct ofpbuf *b) |
221 | 0 | { |
222 | 0 | return (char*)b->data - (char*)b->base; |
223 | 0 | } Unexecuted instantiation: jsonrpc.c:ofpbuf_headroom Unexecuted instantiation: ofpbuf.c:ofpbuf_headroom Unexecuted instantiation: socket-util.c:ofpbuf_headroom Unexecuted instantiation: stream.c:ofpbuf_headroom Unexecuted instantiation: vlog.c:ofpbuf_headroom Unexecuted instantiation: stream-unix.c:ofpbuf_headroom Unexecuted instantiation: stream-ssl.c:ofpbuf_headroom Unexecuted instantiation: packets.c:ofpbuf_headroom Unexecuted instantiation: stream-tcp.c:ofpbuf_headroom Unexecuted instantiation: dp-packet.c:ofpbuf_headroom |
224 | | |
225 | | /* Returns the number of bytes that may be appended to the tail end of ofpbuf |
226 | | * 'b' before the ofpbuf must be reallocated. */ |
227 | | static inline size_t ofpbuf_tailroom(const struct ofpbuf *b) |
228 | 0 | { |
229 | 0 | return (char*)ofpbuf_end(b) - (char*)ofpbuf_tail(b); |
230 | 0 | } Unexecuted instantiation: jsonrpc.c:ofpbuf_tailroom Unexecuted instantiation: ofpbuf.c:ofpbuf_tailroom Unexecuted instantiation: socket-util.c:ofpbuf_tailroom Unexecuted instantiation: stream.c:ofpbuf_tailroom Unexecuted instantiation: vlog.c:ofpbuf_tailroom Unexecuted instantiation: stream-unix.c:ofpbuf_tailroom Unexecuted instantiation: stream-ssl.c:ofpbuf_tailroom Unexecuted instantiation: packets.c:ofpbuf_tailroom Unexecuted instantiation: stream-tcp.c:ofpbuf_tailroom Unexecuted instantiation: dp-packet.c:ofpbuf_tailroom |
231 | | |
232 | | /* Returns the number of bytes from 'b->header' to 'b->msg', that is, the |
233 | | * length of 'b''s header. */ |
234 | | static inline size_t |
235 | | ofpbuf_headersize(const struct ofpbuf *b) |
236 | 0 | { |
237 | 0 | return (char *)b->msg - (char *)b->header; |
238 | 0 | } Unexecuted instantiation: jsonrpc.c:ofpbuf_headersize Unexecuted instantiation: ofpbuf.c:ofpbuf_headersize Unexecuted instantiation: socket-util.c:ofpbuf_headersize Unexecuted instantiation: stream.c:ofpbuf_headersize Unexecuted instantiation: vlog.c:ofpbuf_headersize Unexecuted instantiation: stream-unix.c:ofpbuf_headersize Unexecuted instantiation: stream-ssl.c:ofpbuf_headersize Unexecuted instantiation: packets.c:ofpbuf_headersize Unexecuted instantiation: stream-tcp.c:ofpbuf_headersize Unexecuted instantiation: dp-packet.c:ofpbuf_headersize |
239 | | |
240 | | /* Returns the number of bytes from 'b->msg' to 'b->data + b->size', that is, |
241 | | * the length of the used space in 'b' starting from 'msg'. */ |
242 | | static inline size_t |
243 | | ofpbuf_msgsize(const struct ofpbuf *b) |
244 | 0 | { |
245 | 0 | return (char *)ofpbuf_tail(b) - (char *)b->msg; |
246 | 0 | } Unexecuted instantiation: jsonrpc.c:ofpbuf_msgsize Unexecuted instantiation: ofpbuf.c:ofpbuf_msgsize Unexecuted instantiation: socket-util.c:ofpbuf_msgsize Unexecuted instantiation: stream.c:ofpbuf_msgsize Unexecuted instantiation: vlog.c:ofpbuf_msgsize Unexecuted instantiation: stream-unix.c:ofpbuf_msgsize Unexecuted instantiation: stream-ssl.c:ofpbuf_msgsize Unexecuted instantiation: packets.c:ofpbuf_msgsize Unexecuted instantiation: stream-tcp.c:ofpbuf_msgsize Unexecuted instantiation: dp-packet.c:ofpbuf_msgsize |
247 | | |
248 | | /* Clears any data from 'b'. */ |
249 | | static inline void ofpbuf_clear(struct ofpbuf *b) |
250 | 0 | { |
251 | 0 | b->data = b->base; |
252 | 0 | b->size = 0; |
253 | 0 | } Unexecuted instantiation: jsonrpc.c:ofpbuf_clear Unexecuted instantiation: ofpbuf.c:ofpbuf_clear Unexecuted instantiation: socket-util.c:ofpbuf_clear Unexecuted instantiation: stream.c:ofpbuf_clear Unexecuted instantiation: vlog.c:ofpbuf_clear Unexecuted instantiation: stream-unix.c:ofpbuf_clear Unexecuted instantiation: stream-ssl.c:ofpbuf_clear Unexecuted instantiation: packets.c:ofpbuf_clear Unexecuted instantiation: stream-tcp.c:ofpbuf_clear Unexecuted instantiation: dp-packet.c:ofpbuf_clear |
254 | | |
255 | | /* Removes 'size' bytes from the head end of 'b', which must contain at least |
256 | | * 'size' bytes of data. Returns the first byte of data removed. */ |
257 | | static inline void *ofpbuf_pull(struct ofpbuf *b, size_t size) |
258 | 0 | { |
259 | 0 | ovs_assert(b->size >= size); |
260 | 0 | void *data = b->data; |
261 | |
|
262 | 0 | if (!size) { |
263 | 0 | return data; |
264 | 0 | } |
265 | | |
266 | 0 | b->data = (char*)b->data + size; |
267 | 0 | b->size = b->size - size; |
268 | 0 | return data; |
269 | 0 | } Unexecuted instantiation: jsonrpc.c:ofpbuf_pull Unexecuted instantiation: ofpbuf.c:ofpbuf_pull Unexecuted instantiation: socket-util.c:ofpbuf_pull Unexecuted instantiation: stream.c:ofpbuf_pull Unexecuted instantiation: vlog.c:ofpbuf_pull Unexecuted instantiation: stream-unix.c:ofpbuf_pull Unexecuted instantiation: stream-ssl.c:ofpbuf_pull Unexecuted instantiation: packets.c:ofpbuf_pull Unexecuted instantiation: stream-tcp.c:ofpbuf_pull Unexecuted instantiation: dp-packet.c:ofpbuf_pull |
270 | | |
271 | | /* If 'b' has at least 'size' bytes of data, removes that many bytes from the |
272 | | * head end of 'b' and returns the first byte removed. Otherwise, returns a |
273 | | * null pointer without modifying 'b'. */ |
274 | | static inline void *ofpbuf_try_pull(struct ofpbuf *b, size_t size) |
275 | 0 | { |
276 | 0 | return b->size >= size ? ofpbuf_pull(b, size) : NULL; |
277 | 0 | } Unexecuted instantiation: jsonrpc.c:ofpbuf_try_pull Unexecuted instantiation: ofpbuf.c:ofpbuf_try_pull Unexecuted instantiation: socket-util.c:ofpbuf_try_pull Unexecuted instantiation: stream.c:ofpbuf_try_pull Unexecuted instantiation: vlog.c:ofpbuf_try_pull Unexecuted instantiation: stream-unix.c:ofpbuf_try_pull Unexecuted instantiation: stream-ssl.c:ofpbuf_try_pull Unexecuted instantiation: packets.c:ofpbuf_try_pull Unexecuted instantiation: stream-tcp.c:ofpbuf_try_pull Unexecuted instantiation: dp-packet.c:ofpbuf_try_pull |
278 | | |
279 | | static inline struct ofpbuf *ofpbuf_from_list(const struct ovs_list *list) |
280 | 0 | { |
281 | 0 | return CONTAINER_OF(list, struct ofpbuf, list_node); |
282 | 0 | } Unexecuted instantiation: jsonrpc.c:ofpbuf_from_list Unexecuted instantiation: ofpbuf.c:ofpbuf_from_list Unexecuted instantiation: socket-util.c:ofpbuf_from_list Unexecuted instantiation: stream.c:ofpbuf_from_list Unexecuted instantiation: vlog.c:ofpbuf_from_list Unexecuted instantiation: stream-unix.c:ofpbuf_from_list Unexecuted instantiation: stream-ssl.c:ofpbuf_from_list Unexecuted instantiation: packets.c:ofpbuf_from_list Unexecuted instantiation: stream-tcp.c:ofpbuf_from_list Unexecuted instantiation: dp-packet.c:ofpbuf_from_list |
283 | | |
284 | | static inline bool ofpbuf_equal(const struct ofpbuf *a, const struct ofpbuf *b) |
285 | 0 | { |
286 | 0 | return a->size == b->size && |
287 | 0 | (a->size == 0 || memcmp(a->data, b->data, a->size) == 0); |
288 | 0 | } Unexecuted instantiation: jsonrpc.c:ofpbuf_equal Unexecuted instantiation: ofpbuf.c:ofpbuf_equal Unexecuted instantiation: socket-util.c:ofpbuf_equal Unexecuted instantiation: stream.c:ofpbuf_equal Unexecuted instantiation: vlog.c:ofpbuf_equal Unexecuted instantiation: stream-unix.c:ofpbuf_equal Unexecuted instantiation: stream-ssl.c:ofpbuf_equal Unexecuted instantiation: packets.c:ofpbuf_equal Unexecuted instantiation: stream-tcp.c:ofpbuf_equal Unexecuted instantiation: dp-packet.c:ofpbuf_equal |
289 | | |
290 | | static inline bool ofpbuf_oversized(const struct ofpbuf *ofpacts) |
291 | 0 | { |
292 | 0 | return (char *)ofpbuf_tail(ofpacts) - (char *)ofpacts->header > UINT16_MAX; |
293 | 0 | } Unexecuted instantiation: jsonrpc.c:ofpbuf_oversized Unexecuted instantiation: ofpbuf.c:ofpbuf_oversized Unexecuted instantiation: socket-util.c:ofpbuf_oversized Unexecuted instantiation: stream.c:ofpbuf_oversized Unexecuted instantiation: vlog.c:ofpbuf_oversized Unexecuted instantiation: stream-unix.c:ofpbuf_oversized Unexecuted instantiation: stream-ssl.c:ofpbuf_oversized Unexecuted instantiation: packets.c:ofpbuf_oversized Unexecuted instantiation: stream-tcp.c:ofpbuf_oversized Unexecuted instantiation: dp-packet.c:ofpbuf_oversized |
294 | | |
295 | | /* Truncates the buffer to 'new_size' bytes from the tail end of 'b'. */ |
296 | | static inline void ofpbuf_truncate(struct ofpbuf *b, size_t new_size) |
297 | 0 | { |
298 | 0 | ovs_assert(b->size >= new_size); |
299 | 0 | b->size = new_size; |
300 | 0 | } Unexecuted instantiation: jsonrpc.c:ofpbuf_truncate Unexecuted instantiation: ofpbuf.c:ofpbuf_truncate Unexecuted instantiation: socket-util.c:ofpbuf_truncate Unexecuted instantiation: stream.c:ofpbuf_truncate Unexecuted instantiation: vlog.c:ofpbuf_truncate Unexecuted instantiation: stream-unix.c:ofpbuf_truncate Unexecuted instantiation: stream-ssl.c:ofpbuf_truncate Unexecuted instantiation: packets.c:ofpbuf_truncate Unexecuted instantiation: stream-tcp.c:ofpbuf_truncate Unexecuted instantiation: dp-packet.c:ofpbuf_truncate |
301 | | |
302 | | #ifdef __cplusplus |
303 | | } |
304 | | #endif |
305 | | |
306 | | #endif /* ofpbuf.h */ |