5377871ae099ec20f22338056be954f1cbc80d26
[ric-plt/lib/rmr.git] / doc / src / man / rmr_alloc_msg.3.xfm
1 .if false
2 ==================================================================================
3         Copyright (c) 2019 Nokia
4         Copyright (c) 2018-2019 AT&T Intellectual Property.
5
6    Licensed under the Apache License, Version 2.0 (the "License");
7    you may not use this file except in compliance with the License.
8    You may obtain a copy of the License at
9
10        http://www.apache.org/licenses/LICENSE-2.0
11
12    Unless required by applicable law or agreed to in writing, software
13    distributed under the License is distributed on an "AS IS" BASIS,
14    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15    See the License for the specific language governing permissions and
16    limitations under the License.
17 ==================================================================================
18 .fi
19 .if false
20         Mnemonic        rmr_alloc_msg.xfm
21         Abstract        The manual page for the rmr_alloc_msg function.
22         Author          E. Scott Daniels
23         Date            28 January 2019
24 .fi
25
26 .gv e LIB lib
27 .im &{lib}/man/setup.im
28
29 &line_len(6i)
30 &h1(RMR Library Functions)
31 &h2(NAME)
32         rmr_alloc_msg
33
34 &h2(SYNOPSIS )
35 &indent
36 &ex_start
37 #include <rmr/rmr.h>
38
39 rmr_mbuf_t* rmr_alloc_msg( void* ctx, int size );
40 &ex_end
41 &uindent
42
43 &h2(DESCRIPTION)
44 The &cw(rmr_alloc_msg) function is used to allocate a buffer which the user
45 programme can write into and then send through the RMR library.
46 The buffer is allocated such that sending it requires no additional copying
47 out of the buffer.
48 If the value passed in &cw(size) is 0, then the default size supplied on the
49 &ital(rmr_init) call will be used.
50 The &ital(ctx) parameter is the void context pointer that was returned by
51 the &ital(rmr_init) function.
52
53 &space
54 The pointer to the message buffer returned is a structure which has some
55 user application visible fields; the structure is described in &cw(rmr.h,)
56 and is illustrated below.
57
58 &space
59 &ex_start
60 typedef struct {
61     int state;
62     int mtype;
63     int len;
64     unsigned char* payload;
65     unsigned char* xaction;
66         int sub_id;
67         int tp_state;
68 } rmr_mbuf_t;
69 &ex_end
70
71 &space
72 &beg_dlist(.75i : ^&bold_font )
73 &ditem(state)  Is the current buffer state.  Following a call to &cw(rmr_send_msg)
74 the state indicates whether the buffer was successfully sent which determines
75 exactly what the payload points to.  If the send failed, the payload referenced
76 by the buffer is the message that failed to send (allowing the application to
77 attempt a retransmission).
78 When the state is &cw(RMR_OK) the buffer represents an empty buffer that the application
79 may fill in in preparation to send.
80
81 &half_space
82 &ditem(mtype)  When sending a message, the application is expected to set this field
83 to the appropriate message type value (as determined by the user programme). Upon send
84 this value determines how the RMR library will route the message.
85 For a buffer which has been received, this field will contain the message type that was
86 set by the sending application.
87
88 &half_space
89 &ditem(len) The application using a buffer to send a message is expected to set the
90 length value to the actual number of bytes that it placed into the message. This
91 is likely less than the total number of bytes that the message can carry.
92 For a message buffer that is passed to the application as the result of a receive
93 call, this will be the value that the sending application supplied and should
94 indicate the number of bytes in the payload which are valid.
95
96 &half_space
97 &ditem(payload) The payload is a pointer to the actual received data.  The
98 user programme may read and write from/to the memory referenced by the payload
99 up until the point in time that the buffer is used on a &cw(rmr_send, rmr_call)
100 or &cw(rmr_reply) function call.
101 Once the buffer has been passed back to a RMR library function the user programme
102 should &bold(NOT) make use of the payload pointer.
103
104
105 &half_space
106 &ditem(xaction) The &ital(xaction) field is a pointer to a fixed sized area in
107 the message into which the user may write a transaction ID.
108 The ID is optional with the exception of when the user application uses the &cw(rmr_call)
109 function to send a message and wait for the reply; the underlying RMR processing
110 expects that the matching reply message will also contain the same data in the
111 &ital(xaction) field.
112 &end_dlist
113
114 &half_space
115 &ditem(sub_id)
116 This value is the subscription ID. It, in combination with the message type is used
117 by rmr to determine the target endpoint when sending a message.
118 If the application to application protocol does not warrant the use of a subscription
119 ID, the RMR constant RMR_VOID_SUBID should be placed in this field.
120 When an application is forwarding or returning a buffer to the sender, it is the
121 application's responsibility to set/reset this value.
122
123 &half_space
124 &ditem(tp_state)
125 For C applications making use of RMR, the state of a transport based failure will
126 often be available via &cw(errno.)
127 However, some wrapper environments may not have direct access to the C-lib &cw(errno)
128 value.
129 RMR send and receive operations will place the current value of &cw(errno) into this
130 field which should make it available to wrapper functions.
131 User applications are strongly cautioned against relying on the value of errno as
132 some transport mechanisms may not set this value on all calls.
133 This value should also be ignored any time the message status is &cw(RMR_OK.)
134
135 &h2(RETURN VALUE)
136 The function returns a pointer to a &cw(rmr_mbuf) structure, or NULL on error.
137
138 &h2(ERRORS)
139 &beg_dlist(.75i : ^&bold_font )
140 &di(ENOMEM) Unable to allocate memory.
141 &end_dlist
142
143 .** &h2(EXAMPLE)
144
145 &h2(SEE ALSO )
146 rmr_tralloc_msg(3),
147 rmr_call(3),
148 rmr_free_msg(3),
149 rmr_init(3),
150 rmr_init_trace(3),
151 rmr_get_trace(3),
152 rmr_get_trlen(3),
153 rmr_payload_size(3),
154 rmr_send_msg(3),
155 rmr_rcv_msg(3),
156 rmr_rcv_specific(3),
157 rmr_rts_msg(3),
158 rmr_ready(3),
159 rmr_fib(3),
160 rmr_has_str(3),
161 rmr_tokenise(3),
162 rmr_mk_ring(3),
163 rmr_ring_free(3),
164 rmr_set_trace(3)
165
166 .qu
167