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.)
68 .** pull in common retry text
69 .im &{lib}/man/retry.im
73 On success, a new message buffer, with an empty payload, is returned for the application
74 to use for the next send.
75 The state in this buffer will reflect the overall send operation state and should be
79 When the message cannot be successfully sent this function will return the unsent (original)
80 message buffer with the state set to indicate the reason for failure.
81 The value of &ital( errno ) may also be set to reflect a more detailed failure reason if it
85 In the event of extreme failure, a NULL pointer is returned. In this case the value of
86 &cw(errno) might be of some use, for documentation, but there will be little that the
87 user application can do other than to move on.
90 The following values may be passed back in the &ital(state) field of the returned message
94 &beg_dlist(.75i : ^&bold_font )
95 &di(RMR_RETRY) The message could not be sent, but the underlying transport mechanism
96 indicates that the failure is temporary. If the send operation is tried again
97 it might be successful.
98 &di(RMR_SEND_FAILED) The send operation was not successful and the underlying transport
99 mechanism indicates a permanent (hard) failure; retrying the send is not possible.
100 &di(RMR_ERR_BADARG) The message buffer pointer did not refer to a valid message.
101 &di(RMR_ERR_NOHDR) The header in the message buffer was not valid or corrupted.
102 &di(RMR_ERR_NOENDPT) The message type in the message buffer did not map to a known endpoint.
106 The following values may be assigned to &cw(errno) on failure.
107 &beg_dlist(.75i : ^&bold_font )
108 &di(INVAL) Parameter(s) passed to the function were not valid, or the underlying message processing environment was unable to interpret the message.
111 &di(ENOKEY) The header information in the message buffer was invalid.
114 &di(ENXIO) No known endpoint for the message could be found.
117 &di(EMSGSIZE) The underlying transport refused to accept the message because of a size value issue (message was not attempted to be sent).
120 &di(EFAULT) The message referenced by the message buffer is corrupt (NULL pointer or bad internal length).
123 &di(EBADF) Internal RMR error; information provided to the message transport environment was not valid.
126 &di(ENOTSUP) Sending was not supported by the underlying message transport.
129 &di(EFSM) The device is not in a state that can accept the message.
132 &di(EAGAIN) The device is not able to accept a message for sending. The user application should attempt to resend.
135 &di(EINTR) The operation was interrupted by delivery of a signal before the message was sent.
138 &di(ETIMEDOUT) The underlying message environment timed out during the send process.
141 &di(ETERM) The underlying message environment is in a shutdown state.
145 The following is a simple example of how the &cw(rmr_send_msg) function is called.
146 In this example, the send message buffer is saved between calls and reused
147 eliminating alloc/free cycles.
151 static rmr_mbuf_t* send_msg = NULL; // message to send; reused on each call
152 msg_t* send_pm; // payload for send
153 msg_t* pm; // our message format in the received payload
155 if( send_msg == NULL ) {
156 send_msg = rmr_alloc_msg( mr, MAX_SIZE ); // new buffer to send
159 // reference payload and fill in message type
160 pm = (msg_t*) send_msg->payload;
161 send_msg->mtype = MT_ANSWER;
163 msg->len = generate_data( pm ); // something that fills the payload in
164 msg = rmr_send_msg( mr, send_msg );
168 if( msg->state != RMR_OK ) {
169 // check for eagain, and resend if needed