2 * Copyright (c) 2022 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 #ifndef SRC_PLUGINS_HTTP_HTTP_BUFFER_H_
17 #define SRC_PLUGINS_HTTP_HTTP_BUFFER_H_
19 #include <svm/svm_fifo.h>
21 #define HTTP_BUFFER_DATA_SZ 32
23 typedef enum http_buffer_type_
29 typedef struct http_buffer_vft_ http_buffer_vft_t;
31 typedef struct http_buffer_
33 http_buffer_vft_t *vft;
34 u8 data[HTTP_BUFFER_DATA_SZ];
37 struct http_buffer_vft_
39 void (*init) (http_buffer_t *, void *data, u64 len);
40 void (*free) (http_buffer_t *);
41 svm_fifo_seg_t *(*get_segs) (http_buffer_t *, u32 max_len, u32 *n_segs);
42 u32 (*drain) (http_buffer_t *, u32 len);
43 u8 (*is_drained) (http_buffer_t *);
46 void http_buffer_init (http_buffer_t *hb, http_buffer_type_t type,
47 svm_fifo_t *f, u64 data_len);
50 http_buffer_free (http_buffer_t *hb)
56 static inline svm_fifo_seg_t *
57 http_buffer_get_segs (http_buffer_t *hb, u32 max_len, u32 *n_segs)
59 return hb->vft->get_segs (hb, max_len, n_segs);
63 http_buffer_drain (http_buffer_t *hb, u32 len)
65 return hb->vft->drain (hb, len);
69 http_buffer_is_drained (http_buffer_t *hb)
71 return hb->vft->is_drained (hb);
74 #endif /* SRC_PLUGINS_HTTP_HTTP_BUFFER_H_ */
77 * fd.io coding-style-patch-verification: ON
80 * eval: (c-set-style "gnu")