Initial commit of RMR Library
[ric-plt/lib/rmr.git] / doc / src / man / rmr_send_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_send_msg_man.xfm
21         Abstract        The manual page for the rmr_send_msg function.
22         Author          E. Scott Daniels
23         Date            28 January 2019
24 .fi
25
26 .** if formatting with tfm, the roff.im will cause roff output to be generated
27 .** if formatting with pfm, then pretty postscript will be generated
28 .gv e LIB lib
29 .if pfm
30         .im &{lib}/generic_ps.im
31 .ei
32         .gv e OUTPUT_RST use_rst
33         .if .ev &use_rst 1 = 
34                 .im &{lib}/rst.im
35         .ei
36                 .im &{lib}/roff.im
37         .fi
38 .fi
39
40 &line_len(6i)
41
42 &h1(RMR Library Functions)
43 &h2(NAME)
44         rmr_send_msg
45
46 &h2(SYNOPSIS )
47 &indent
48 &ex_start
49 #include <rmr/rmr.h>
50
51 rmr_mbuf_t* rmr_send_msg( void* vctx, rmr_mbuf_t* msg );
52 &ex_end
53 &uindent
54
55 &h2(DESCRIPTION)
56 The &cw(rmr_send_msg) function accepts a message buffer from the user application 
57 and attempts to send it.
58 The destination of the message is selected based on the message type specified
59 in the message buffer, and the matching information in the routing tables
60 which are currently in use by the RMR library. 
61 This may actually result in the sending of the message to multiple destinations
62 which could degrade expected overall performance of the user application. 
63 (Limiting excessive sending of messages is the responsibility of the application(s)
64 responsible for building the routing table used by the RMR library, and not the 
65 responsibility of the library.)
66
67
68 &h2(RETURN VALUE)
69 On success, a new message buffer, with an empty payload, is returned for the application
70 to use for the next send.
71 The state in this buffer will reflect the overall send operation state and should be
72 &cw(RMR_OK.)
73
74 &space
75 If the state in the returned buffer is anything other than &cw(UT_OK,) the user application 
76 may need to attempt a retransmission of the message, or take other action depending on the
77 setting of &cw(errno) as described below. 
78
79 &space
80 In the event of extreme failure, a NULL pointer is returned. In this case the value of 
81 &cw(errno) might be of some use, for documentation, but there will be little that the 
82 user application can do other than to move on.
83
84 &h2(ERRORS)
85 The following values may be passed back in the &ital(state) field of the returned message
86 buffer. 
87
88 &space
89 &beg_dlist(.75i : ^&bold_font )
90 &di(RMR_ERR_BADARG) The message buffer pointer did not refer to a valid message.
91 &di(RMR_ERR_NOHDR)  The header in the message buffer was not valid or corrupted.
92 &di(RMR_ERR_NOENDPT)  The message type in the message buffer did not map to a known endpoint.
93 &end_dlist
94
95 &space
96 The following values may be assigned to &cw(errno) on failure.
97 &beg_dlist(.75i : ^&bold_font )
98 &di(INVAL) Parameter(s) passed to the function were not valid, or the underlying message processing environment was unable to interpret the message.
99
100 &half_space
101 &di(ENOKEY) The header information in the message buffer was invalid.
102
103 &half_space
104 &di(ENXIO) No known endpoint for the message could be found.
105
106 &half_space
107 &di(EMSGSIZE) The underlying transport refused to accept the message because of a size value issue (message was not attempted to be sent).
108
109 &half_space
110 &di(EFAULT) The message referenced by the message buffer is corrupt (NULL pointer or bad internal length).
111
112 &half_space
113 &di(EBADF) Internal RMR error; information provided to the message transport environment was not valid.
114
115 &half_space
116 &di(ENOTSUP) Sending was not supported by the underlying message transport.
117
118 &half_space
119 &di(EFSM) The device is not in a state that can accept the message.
120
121 &half_space
122 &di(EAGAIN) The device is not able to accept a message for sending. The user application should attempt to resend.
123
124 &half_space
125 &di(EINTR) The operation was interrupted by delivery of a signal before the message was sent.
126
127 &half_space
128 &di(ETIMEDOUT) The underlying message environment timed out during the send process.
129
130 &half_space
131 &di(ETERM) The underlying message environment is in a shutdown state.
132 &end_dlist
133
134 &h2(EXAMPLE)
135 The following is a simple example of how the &cw(rmr_send_msg) function is called.
136 In this example, the send message buffer is saved between calls and reused
137 eliminating alloc/free cycles.
138
139 &space
140 &ex_start
141     static rmr_mbuf_t*  send_msg = NULL;        // message to send; reused on each call
142     msg_t*  send_pm;                            // payload for send
143     msg_t*  pm;                                 // our message format in the received payload
144
145         if( send_msg  == NULL ) {
146         send_msg = rmr_alloc_msg( mr, MAX_SIZE );       // new buffer to send
147         }
148
149         // reference payload and fill in message type
150     pm = (msg_t*) send_msg->payload;
151     send_msg->mtype = MT_ANSWER;                
152
153     msg->len = generate_data( pm );             // something that fills the payload in
154     msg = rmr_send_msg( mr, send_msg );
155         if( ! msg ) {
156                 return ERROR;
157         } else {
158                 if( msg->state != RMR_OK ) {
159                         // check for eagain, and resend if needed
160                         // else return error
161                 }
162         }
163
164         return OK;
165                         
166 &ex_end
167
168
169 &h2(SEE ALSO )
170 .ju off
171 rmr_alloc_msg(3),
172 rmr_call(3),
173 rmr_free_msg(3),
174 rmr_init(3),
175 rmr_payload_size(3),
176 rmr_rcv_msg(3),
177 rmr_rcv_specific(3),
178 rmr_rts_msg(3),
179 rmr_ready(3),
180 rmr_mk_ring(3),
181 rmr_ring_free(3),
182 rmr_torcv_rcv(3),
183 rmr_wh_send_msg(3)
184 .ju on
185
186
187 .qu
188