2 ==================================================================================
3 Copyright (c) 2019 Nokia
4 Copyright (c) 2018-2019 AT&T Intellectual Property.
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
10 http://www.apache.org/licenses/LICENSE-2.0
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 ==================================================================================
20 Mnemonic rmr_send_msg_man.xfm
21 Abstract The manual page for the rmr_send_msg function.
22 Author E. Scott Daniels
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
30 .im &{lib}/generic_ps.im
32 .gv e OUTPUT_RST use_rst
42 &h1(RMR Library Functions)
51 rmr_mbuf_t* rmr_send_msg( void* vctx, rmr_mbuf_t* msg );
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.)
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
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.
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.
85 The following values may be passed back in the &ital(state) field of the returned message
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.
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.
101 &di(ENOKEY) The header information in the message buffer was invalid.
104 &di(ENXIO) No known endpoint for the message could be found.
107 &di(EMSGSIZE) The underlying transport refused to accept the message because of a size value issue (message was not attempted to be sent).
110 &di(EFAULT) The message referenced by the message buffer is corrupt (NULL pointer or bad internal length).
113 &di(EBADF) Internal RMR error; information provided to the message transport environment was not valid.
116 &di(ENOTSUP) Sending was not supported by the underlying message transport.
119 &di(EFSM) The device is not in a state that can accept the message.
122 &di(EAGAIN) The device is not able to accept a message for sending. The user application should attempt to resend.
125 &di(EINTR) The operation was interrupted by delivery of a signal before the message was sent.
128 &di(ETIMEDOUT) The underlying message environment timed out during the send process.
131 &di(ETERM) The underlying message environment is in a shutdown state.
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.
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
145 if( send_msg == NULL ) {
146 send_msg = rmr_alloc_msg( mr, MAX_SIZE ); // new buffer to send
149 // reference payload and fill in message type
150 pm = (msg_t*) send_msg->payload;
151 send_msg->mtype = MT_ANSWER;
153 msg->len = generate_data( pm ); // something that fills the payload in
154 msg = rmr_send_msg( mr, send_msg );
158 if( msg->state != RMR_OK ) {
159 // check for eagain, and resend if needed