Motr  M0
packet_internal.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2012-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
23 #pragma once
24 
25 #ifndef __MOTR_RPC_PACKET_INT_H__
26 #define __MOTR_RPC_PACKET_INT_H__
27 
28 #include "lib/vec.h"
29 #include "lib/tlist.h"
30 #include "rpc/onwire.h"
31 
37 /* Imports */
38 struct m0_rpc_item;
39 struct m0_rpc_frm;
40 
45 struct m0_rpc_packet {
46 
48 
51 
56  struct m0_tl rp_items;
57 
61  int rp_status;
62 
63  struct m0_rpc_frm *rp_frm;
64 
66 };
67 
70 
71 M0_TL_DESCR_DECLARE(packet_item, M0_EXTERN);
72 M0_TL_DECLARE(packet_item, M0_INTERNAL, struct m0_rpc_item);
73 
74 #define for_each_item_in_packet(item, packet) \
75  m0_tl_for(packet_item, &packet->rp_items, item)
76 
77 #define end_for_each_item_in_packet m0_tl_endfor
78 
79 M0_INTERNAL bool m0_rpc_packet_invariant(const struct m0_rpc_packet *packet);
80 M0_INTERNAL void m0_rpc_packet_init(struct m0_rpc_packet *packet,
81  struct m0_rpc_machine *rmach);
82 M0_INTERNAL void m0_rpc_packet_fini(struct m0_rpc_packet *packet);
83 
85 M0_INTERNAL void m0_rpc_packet_discard(struct m0_rpc_packet *packet);
86 
91 M0_INTERNAL void m0_rpc_packet_add_item(struct m0_rpc_packet *packet,
92  struct m0_rpc_item *item);
93 
98 M0_INTERNAL void m0_rpc_packet_remove_item(struct m0_rpc_packet *packet,
99  struct m0_rpc_item *item);
100 
104 M0_INTERNAL void m0_rpc_packet_remove_all_items(struct m0_rpc_packet *packet);
105 
106 M0_INTERNAL bool m0_rpc_packet_is_empty(const struct m0_rpc_packet *packet);
107 
111 M0_INTERNAL bool m0_rpc_packet_is_carrying_item(const struct m0_rpc_packet
112  *packet,
113  const struct m0_rpc_item *item);
114 
120 M0_INTERNAL int m0_rpc_packet_encode(struct m0_rpc_packet *packet,
121  struct m0_bufvec *bufvec);
122 
129  struct m0_bufvec_cursor
130  *cursor);
131 
135 M0_INTERNAL int m0_rpc_packet_decode(struct m0_rpc_packet *packet,
136  struct m0_bufvec *bufvec,
137  m0_bindex_t off, m0_bcount_t len);
138 
143  struct m0_bufvec_cursor
144  *cursor, m0_bcount_t len);
145 
146 typedef void item_visit_fn(struct m0_rpc_packet *packet,
147  struct m0_rpc_item *item, int data);
148 
153 M0_INTERNAL void m0_rpc_packet_traverse_items(struct m0_rpc_packet *p,
154  item_visit_fn * visit,
155  int opaque_data);
156 
158 #endif /* __MOTR_RPC_PACKET_INT_H__ */
159 
160 /*
161  * Local variables:
162  * c-indentation-style: "K&R"
163  * c-basic-offset: 8
164  * tab-width: 8
165  * fill-column: 80
166  * scroll-step: 1
167  * End:
168  */
static struct m0_addb2_philter p
Definition: consumer.c:40
M0_INTERNAL int m0_rpc_packet_decode(struct m0_rpc_packet *p, struct m0_bufvec *bufvec, m0_bindex_t off, m0_bcount_t len)
Definition: packet.c:367
m0_bcount_t rp_size
M0_INTERNAL void m0_rpc_packet_traverse_items(struct m0_rpc_packet *p, item_visit_fn *visit, int opaque_data)
Definition: packet.c:524
struct m0_bufvec data
Definition: di.c:40
uint64_t m0_bindex_t
Definition: types.h:80
uint64_t m0_bcount_t
Definition: types.h:77
M0_INTERNAL void m0_rpc_packet_add_item(struct m0_rpc_packet *p, struct m0_rpc_item *item)
Definition: packet.c:141
static struct m0_rpc_item * item
Definition: item.c:56
M0_INTERNAL bool m0_rpc_packet_invariant(const struct m0_rpc_packet *p)
Definition: packet.c:82
M0_INTERNAL void m0_rpc_packet_init(struct m0_rpc_packet *p, struct m0_rpc_machine *rmach)
Definition: packet.c:103
M0_INTERNAL void m0_rpc_packet_fini(struct m0_rpc_packet *p)
Definition: packet.c:122
M0_INTERNAL int m0_rpc_packet_decode_using_cursor(struct m0_rpc_packet *p, struct m0_bufvec_cursor *cursor, m0_bcount_t len)
Definition: packet.c:448
M0_INTERNAL int m0_rpc_packet_encode_using_cursor(struct m0_rpc_packet *packet, struct m0_bufvec_cursor *cursor)
Definition: packet.c:317
Definition: tlist.h:251
Definition: xcode.h:95
struct m0_rpc_packet_onwire_header rp_ow
M0_INTERNAL int m0_rpc_packet_encode(struct m0_rpc_packet *p, struct m0_bufvec *bufvec)
Definition: packet.c:221
void item_visit_fn(struct m0_rpc_packet *packet, struct m0_rpc_item *item, int data)
M0_TL_DECLARE(packet_item, M0_INTERNAL, struct m0_rpc_item)
M0_INTERNAL bool m0_rpc_packet_is_carrying_item(const struct m0_rpc_packet *p, const struct m0_rpc_item *item)
Definition: packet.c:208
struct m0_rpc_machine * rp_rmachine
M0_INTERNAL m0_bcount_t m0_rpc_packet_onwire_footer_size(void)
Definition: packet.c:68
M0_INTERNAL void m0_rpc_packet_discard(struct m0_rpc_packet *packet)
Definition: packet.c:134
struct m0_rpc_frm * rp_frm
M0_INTERNAL void m0_rpc_packet_remove_item(struct m0_rpc_packet *p, struct m0_rpc_item *item)
Definition: packet.c:165
struct m0_tl rp_items
M0_TL_DESCR_DECLARE(packet_item, M0_EXTERN)
M0_INTERNAL void m0_rpc_packet_remove_all_items(struct m0_rpc_packet *p)
Definition: packet.c:190
M0_INTERNAL bool m0_rpc_packet_is_empty(const struct m0_rpc_packet *p)
Definition: packet.c:214
M0_INTERNAL m0_bcount_t m0_rpc_packet_onwire_header_size(void)
Definition: packet.c:54
Definition: vec.h:145