bfin: remove inline keyword
[xenomai-head.git] / include / rtdm / rtipc.h
blobfa0083879966be9c8f5ea4e51250339314671cb6
1 /**
2 * @file
3 * This file is part of the Xenomai project.
5 * @note Copyright (C) 2009 Philippe Gerum <rpm@xenomai.org>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 * @ingroup rtipc
24 /**
25 * @ingroup profiles
26 * @defgroup rtipc Real-time IPC protocols
28 * @b Profile @b Revision: 1
29 * @n
30 * @n
31 * @par Device Characteristics
32 * @n
33 * @ref rtdm_device.device_flags "Device Flags": @c RTDM_PROTOCOL_DEVICE @n
34 * @n
35 * @ref rtdm_device.protocol_family "Protocol Family": @c PF_RTIPC @n
36 * @n
37 * @ref rtdm_device.socket_type "Socket Type": @c SOCK_DGRAM @n
38 * @n
39 * @ref rtdm_device.device_class "Device Class": @c RTDM_CLASS_RTIPC @n
40 * @n
41 * @{
44 /**
45 * @anchor rtipc_operations @name Supported operations
46 * Standard socket operations supported by the RTIPC protocols.
47 * @{ */
48 /**
49 * Create an endpoint for communication in the AF_RTIPC domain.
51 * @param [in] protocol Any of @ref IPCPROTO_XDDP, @ref IPCPROTO_IDDP,
52 * or @ref IPCPROTO_BUFP. @ref IPCPROTO_IPC is also valid, and refers
53 * to the default RTIPC protocol, namely @ref IPCPROTO_IDDP.
55 * @return In addition to the standard error codes for @c socket(2),
56 * the following specific error code may be returned:
57 * - -ENOPROTOOPT (Protocol is known, but not compiled in the RTIPC driver).
58 * See @ref RTIPC_PROTO "RTIPC protocols"
59 * for available protocols.
60 * .
62 * @par Calling context:
63 * non-RT
65 #ifdef DOXYGEN_CPP
66 int socket__AF_RTIPC(int domain =AF_RTIPC, int type =SOCK_DGRAM, int protocol);
67 #endif
69 /**
70 * Close a RTIPC socket descriptor.
72 * Blocking calls to any of the @ref sendmsg__AF_RTIPC "sendmsg" or @ref
73 * recvmsg__AF_RTIPC "recvmsg" functions will be unblocked when the socket
74 * is closed and return with an error.
76 * @return In addition to the standard error codes for @c close(2),
77 * the following specific error code may be returned:
78 * none
80 * @par Calling context:
81 * non-RT
83 #ifdef DOXYGEN_CPP
84 int close__AF_RTIPC(int sockfd);
85 #endif
87 /**
88 * Bind a RTIPC socket to a port.
90 * Bind the socket to a destination port.
92 * @param [in] addr The address to bind the socket to (see struct
93 * sockaddr_ipc). The meaning of such address depends on the RTIPC
94 * protocol in use for the socket:
96 * - IPCPROTO_XDDP
98 * This action creates an endpoint for channelling traffic between
99 * the Xenomai and Linux domains.
101 * @em sipc_family must be AF_RTIPC, @em sipc_port is either -1,
102 * or a valid free port number between 0 and
103 * CONFIG_XENO_OPT_PIPE_NRDEV-1.
105 * If @em sipc_port is -1, a free port will be assigned automatically.
107 * Upon success, the pseudo-device /dev/rtp@em N will be reserved
108 * for this communication channel, where @em N is the assigned port
109 * number. The non real-time side shall open this device to exchange
110 * data over the bound socket.
112 * @anchor xddp_label_binding
113 * If a label was assigned (see @ref XDDP_LABEL) prior to
114 * binding the socket to a port, a registry link referring to the
115 * created pseudo-device will be automatically set up as
116 * @c /proc/xenomai/registry/rtipc/xddp/@em label, where @em label is the
117 * label string passed to setsockopt() for the @ref XDDP_LABEL option.
119 * - IPCPROTO_IDDP
121 * This action creates an endpoint for exchanging datagrams within
122 * the Xenomai domain.
124 * @em sipc_family must be AF_RTIPC, @em sipc_port is either -1,
125 * or a valid free port number between 0 and
126 * CONFIG_XENO_OPT_IDDP_NRPORT-1.
128 * If @em sipc_port is -1, a free port will be assigned
129 * automatically. The real-time peer shall connect to the same port
130 * for exchanging data over the bound socket.
132 * @anchor iddp_label_binding
133 * If a label was assigned (see @ref IDDP_LABEL) prior to binding
134 * the socket to a port, a registry link referring to the assigned
135 * port number will be automatically set up as @c
136 * /proc/xenomai/registry/rtipc/iddp/@em label, where @em label is
137 * the label string passed to setsockopt() for the @ref IDDP_LABEL
138 * option.
140 * - IPCPROTO_BUFP
142 * This action creates an endpoint for a one-way byte
143 * stream within the Xenomai domain.
145 * @em sipc_family must be AF_RTIPC, @em sipc_port is either -1,
146 * or a valid free port number between 0 and CONFIG_XENO_OPT_BUFP_NRPORT-1.
148 * If @em sipc_port is -1, an available port will be assigned
149 * automatically. The real-time peer shall connect to the same port
150 * for exchanging data over the bound socket.
152 * @anchor bufp_label_binding
153 * If a label was assigned (see @ref BUFP_LABEL) prior to binding
154 * the socket to a port, a registry link referring to the assigned
155 * port number will be automatically set up as @c
156 * /proc/xenomai/registry/rtipc/bufp/@em label, where @em label is
157 * the label string passed to setsockopt() for the @a BUFP_LABEL
158 * option.
160 * @return In addition to the standard error codes for @c
161 * bind(2), the following specific error code may be returned:
162 * - -EFAULT (Invalid data address given)
163 * - -ENOMEM (Not enough memory)
164 * - -EINVAL (Invalid parameter)
165 * - -EADDRINUSE (Socket already bound to a port, or no port available)
168 * @par Calling context:
169 * non-RT
171 #ifdef DOXYGEN_CPP
172 int bind__AF_RTIPC(int sockfd, const struct sockaddr_ipc *addr,
173 socklen_t addrlen);
174 #endif
177 * Initiate a connection on a RTIPC socket.
179 * @param [in] addr The address to connect the socket to (see struct
180 * sockaddr_ipc).
182 * - If sipc_port is a valid port for the protocol, it is used
183 * verbatim and the connection succeeds immediately, regardless of
184 * whether the destination is bound at the time of the call.
186 * - If sipc_port is -1 and a label was assigned to the socket,
187 * connect() blocks for the requested amount of time (see @ref
188 * SO_RCVTIMEO) until a socket is bound to the same label via @c
189 * bind(2) (see @ref XDDP_LABEL, @ref IDDP_LABEL, @ref BUFP_LABEL), in
190 * which case a connection is established between both endpoints.
192 * - If sipc_port is -1 and no label was assigned to the socket, the
193 * default destination address is cleared, meaning that any subsequent
194 * write to the socket will return -EDESTADDRREQ, until a valid
195 * destination address is set via @c connect(2) or @c bind(2).
197 * @return In addition to the standard error codes for @c connect(2),
198 * the following specific error code may be returned:
199 * none.
201 * @par Calling context:
202 * RT/non-RT
204 #ifdef DOXYGEN_CPP
205 int connect__AF_RTIPC(int sockfd, const struct sockaddr_ipc *addr,
206 socklen_t addrlen);
207 #endif
210 * Set options on RTIPC sockets.
212 * These functions allow to set various socket options.
213 * Supported Levels and Options:
215 * - Level @ref sockopts_socket "SOL_SOCKET"
216 * - Level @ref sockopts_xddp "SOL_XDDP"
217 * - Level @ref sockopts_iddp "SOL_IDDP"
218 * - Level @ref sockopts_bufp "SOL_BUFP"
221 * @return In addition to the standard error codes for @c
222 * setsockopt(2), the following specific error code may
223 * be returned:
224 * follow the option links above.
226 * @par Calling context:
227 * non-RT
229 #ifdef DOXYGEN_CPP
230 int setsockopt__AF_RTIPC(int sockfd, int level, int optname,
231 const void *optval, socklen_t optlen);
232 #endif
234 * Get options on RTIPC sockets.
236 * These functions allow to get various socket options.
237 * Supported Levels and Options:
239 * - Level @ref sockopts_socket "SOL_SOCKET"
240 * - Level @ref sockopts_xddp "SOL_XDDP"
241 * - Level @ref sockopts_iddp "SOL_IDDP"
242 * - Level @ref sockopts_bufp "SOL_BUFP"
245 * @return In addition to the standard error codes for @c
246 * getsockopt(2), the following specific error code may
247 * be returned:
248 * follow the option links above.
250 * @par Calling context:
251 * RT/non-RT
253 #ifdef DOXYGEN_CPP
254 int getsockopt__AF_RTIPC(int sockfd, int level, int optname,
255 void *optval, socklen_t *optlen);
256 #endif
259 * Send a message on a RTIPC socket.
261 * @param [in] flags Operation flags:
263 * - MSG_OOB Send out-of-band message. For all RTIPC protocols except
264 * @ref IPCPROTO_BUFP, sending out-of-band data actually means
265 * pushing them to the head of the receiving queue, so that the
266 * reader will always receive them before normal messages. @ref
267 * IPCPROTO_BUFP does not support out-of-band sending.
269 * - MSG_DONTWAIT Non-blocking I/O operation. The caller will not be
270 * blocked whenever the message cannot be sent immediately at the
271 * time of the call (e.g. memory shortage), but will rather return
272 * with -EWOULDBLOCK. Unlike other RTIPC protocols, @ref
273 * IPCPROTO_XDDP accepts but never considers MSG_DONTWAIT since
274 * writing to a real-time XDDP endpoint is inherently a non-blocking
275 * operation.
277 * - MSG_MORE Accumulate data before sending. This flag is accepted by
278 * the @ref IPCPROTO_XDDP protocol only, and tells the send service
279 * to accumulate the outgoing data into an internal streaming
280 * buffer, instead of issuing a datagram immediately for it. See
281 * @ref XDDP_BUFSZ for more.
283 * @note No RTIPC protocol allows for short writes, and only complete
284 * messages are sent to the peer.
286 * @return In addition to the standard error codes for @c sendmsg(2),
287 * the following specific error code may be returned:
288 * none.
290 * @par Calling context:
291 * RT
293 #ifdef DOXYGEN_CPP
294 ssize_t sendmsg__AF_RTIPC(int sockfd, const struct user_msghdr *msg, int flags);
295 #endif
298 * Receive a message from a RTIPC socket.
300 * @param [in] flags Operation flags:
302 * - MSG_DONTWAIT Non-blocking I/O operation. The caller will not be
303 * blocked whenever no message is immediately available for receipt
304 * at the time of the call, but will rather return with
305 * -EWOULDBLOCK.
307 * @note @ref IPCPROTO_BUFP does not allow for short reads and always
308 * returns the requested amount of bytes, except in one situation:
309 * whenever some writer is waiting for sending data upon a buffer full
310 * condition, while the caller would have to wait for receiving a
311 * complete message. This is usually the sign of a pathological use
312 * of the BUFP socket, like defining an incorrect buffer size via @ref
313 * BUFP_BUFSZ. In that case, a short read is allowed to prevent a
314 * deadlock.
316 * @return In addition to the standard error codes for @c recvmsg(2),
317 * the following specific error code may be returned:
318 * none.
320 * @par Calling context:
321 * RT
323 #ifdef DOXYGEN_CPP
324 ssize_t recvmsg__AF_RTIPC(int sockfd, struct user_msghdr *msg, int flags);
325 #endif
328 * Get socket name.
330 * The name of the local endpoint for the socket is copied back (see
331 * struct sockaddr_ipc).
333 * @return In addition to the standard error codes for @c getsockname(2),
334 * the following specific error code may be returned:
335 * none.
337 * @par Calling context:
338 * RT/non-RT
340 #ifdef DOXYGEN_CPP
341 int getsockname__AF_RTIPC(int sockfd, struct sockaddr_ipc *addr, socklen_t *addrlen);
342 #endif
345 * Get socket peer.
347 * The name of the remote endpoint for the socket is copied back (see
348 * struct sockaddr_ipc). This is the default destination address for
349 * messages sent on the socket. It can be set either explicitly via @c
350 * connect(2), or implicitly via @c bind(2) if no @c connect(2) was
351 * called prior to binding the socket to a port, in which case both
352 * the local and remote names are equal.
354 * @return In addition to the standard error codes for @c getpeername(2),
355 * the following specific error code may be returned:
356 * none.
358 * @par Calling context:
359 * RT/non-RT
361 #ifdef DOXYGEN_CPP
362 int getpeername__AF_RTIPC(int sockfd, struct sockaddr_ipc *addr, socklen_t *addrlen);
363 #endif
365 /** @} */
367 #ifndef _RTIPC_H
369 #ifdef __KERNEL__
370 #include <linux/net.h>
371 #include <linux/socket.h>
372 #include <linux/if.h>
373 #else /* !__KERNEL__ */
374 #include <sys/types.h>
375 #include <sys/socket.h>
376 #endif /* !__KERNEL__ */
377 #include <nucleus/types.h>
378 #include <rtdm/rtdm.h>
380 /* Address family */
381 #define AF_RTIPC 111
383 /* Protocol family */
384 #define PF_RTIPC AF_RTIPC
387 * @anchor RTIPC_PROTO @name RTIPC protocol list
388 * protocols for the PF_RTIPC protocol family
390 * @{ */
391 enum {
392 /** Default protocol (IDDP) */
393 IPCPROTO_IPC = 0,
395 * Cross-domain datagram protocol (RT <-> non-RT).
397 * Real-time Xenomai threads and regular Linux threads may want to
398 * exchange data in a way that does not require the former to leave
399 * the real-time domain (i.e. primary mode). The RTDM-based XDDP
400 * protocol is available for this purpose.
402 * On the Linux domain side, pseudo-device files named /dev/rtp@em \<minor\>
403 * give regular POSIX threads access to non real-time communication
404 * endpoints, via the standard character-based I/O interface. On the
405 * Xenomai domain side, sockets may be bound to XDDP ports, which act
406 * as proxies to send and receive data to/from the associated
407 * pseudo-device files. Ports and pseudo-device minor numbers are
408 * paired, meaning that e.g. socket port 7 will proxy the traffic to/from
409 * /dev/rtp7.
411 * All data sent through a bound/connected XDDP socket via @c
412 * sendto(2) or @c write(2) will be passed to the peer endpoint in the
413 * Linux domain, and made available for reading via the standard @c
414 * read(2) system call. Conversely, all data sent using @c write(2)
415 * through the non real-time endpoint will be conveyed to the
416 * real-time socket endpoint, and made available to the @c recvfrom(2)
417 * or @c read(2) system calls.
419 IPCPROTO_XDDP = 1,
421 * Intra-domain datagram protocol (RT <-> RT).
423 * The RTDM-based IDDP protocol enables real-time threads to exchange
424 * datagrams within the Xenomai domain, via socket endpoints.
426 IPCPROTO_IDDP = 2,
428 * Buffer protocol (RT <-> RT, byte-oriented).
430 * The RTDM-based BUFP protocol implements a lightweight,
431 * byte-oriented, one-way Producer-Consumer data path. All messages
432 * written are buffered into a single memory area in strict FIFO
433 * order, until read by the consumer.
435 * This protocol always prevents short writes, and only allows short
436 * reads when a potential deadlock situation arises (i.e. readers and
437 * writers waiting for each other indefinitely).
439 IPCPROTO_BUFP = 3,
440 IPCPROTO_MAX
442 /** @} */
445 * Port number type for the RTIPC address family.
447 typedef int16_t rtipc_port_t;
450 * Port label information structure.
452 struct rtipc_port_label {
453 /** Port label string, null-terminated. */
454 char label[XNOBJECT_NAME_LEN];
458 * Socket address structure for the RTIPC address family.
460 struct sockaddr_ipc {
461 /** RTIPC address family, must be @c AF_RTIPC */
462 sa_family_t sipc_family;
463 /** Port number. */
464 rtipc_port_t sipc_port;
467 #define SOL_XDDP 311
469 * @anchor sockopts_xddp @name XDDP socket options
470 * Setting and getting XDDP socket options.
471 * @{ */
473 * XDDP label assignment
475 * ASCII label strings can be attached to XDDP ports, so that opening
476 * the non-RT endpoint can be done by specifying this symbolic device
477 * name rather than referring to a raw pseudo-device entry
478 * (i.e. /dev/rtp@em N).
480 * When available, this label will be registered when binding, in
481 * addition to the port number (see @ref xddp_label_binding
482 * "XDDP port binding").
484 * It is not allowed to assign a label after the socket was
485 * bound. However, multiple assignment calls are allowed prior to the
486 * binding; the last label set will be used.
488 * @param [in] level @ref sockopts_xddp "SOL_XDDP"
489 * @param [in] optname @b XDDP_LABEL
490 * @param [in] optval Pointer to struct rtipc_port_label
491 * @param [in] optlen sizeof(struct rtipc_port_label)
493 * @return 0 is returned upon success. Otherwise:
495 * - -EFAULT (Invalid data address given)
496 * - -EALREADY (socket already bound)
497 * - -EINVAL (@a optlen invalid)
500 * @par Calling context:
501 * RT/non-RT
503 #define XDDP_LABEL 1
505 * XDDP local pool size configuration
507 * By default, the memory needed to convey the data is pulled from
508 * Xenomai's system pool. Setting a local pool size overrides this
509 * default for the socket.
511 * If a non-zero size was configured, a local pool is allocated at
512 * binding time. This pool will provide storage for pending datagrams.
514 * It is not allowed to configure a local pool size after the socket
515 * was bound. However, multiple configuration calls are allowed prior
516 * to the binding; the last value set will be used.
518 * @note: the pool memory is obtained from the host allocator by the
519 * @ref bind__AF_RTIPC "bind call".
521 * @param [in] level @ref sockopts_xddp "SOL_XDDP"
522 * @param [in] optname @b XDDP_POOLSZ
523 * @param [in] optval Pointer to a variable of type size_t, containing
524 * the required size of the local pool to reserve at binding time
525 * @param [in] optlen sizeof(size_t)
527 * @return 0 is returned upon success. Otherwise:
529 * - -EFAULT (Invalid data address given)
530 * - -EALREADY (socket already bound)
531 * - -EINVAL (@a optlen invalid or *@a optval is zero)
534 * @par Calling context:
535 * RT/non-RT
537 #define XDDP_POOLSZ 2
539 * XDDP streaming buffer size configuration
541 * In addition to sending datagrams, real-time threads may stream data
542 * in a byte-oriented mode through the port as well. This increases
543 * the bandwidth and reduces the overhead, when the overall data to
544 * send to the Linux domain is collected by bits, and keeping the
545 * message boundaries is not required.
547 * This feature is enabled when a non-zero buffer size is set for the
548 * socket. In that case, the real-time data accumulates into the
549 * streaming buffer when MSG_MORE is passed to any of the @ref
550 * sendmsg__AF_RTIPC "send functions", until:
552 * - the receiver from the Linux domain wakes up and consumes it,
553 * - a different source port attempts to send data to the same
554 * destination port,
555 * - MSG_MORE is absent from the send flags,
556 * - the buffer is full,
558 * whichever comes first.
560 * Setting *@a optval to zero disables the streaming buffer, in which
561 * case all sendings are conveyed in separate datagrams, regardless of
562 * MSG_MORE.
564 * @note only a single streaming buffer exists per socket. When this
565 * buffer is full, the real-time data stops accumulating and sending
566 * operations resume in mere datagram mode. Accumulation may happen
567 * again after some or all data in the streaming buffer is consumed
568 * from the Linux domain endpoint.
570 * The streaming buffer size may be adjusted multiple times during the
571 * socket lifetime; the latest configuration change will take effect
572 * when the accumulation resumes after the previous buffer was
573 * flushed.
575 * @param [in] level @ref sockopts_xddp "SOL_XDDP"
576 * @param [in] optname @b XDDP_BUFSZ
577 * @param [in] optval Pointer to a variable of type size_t, containing
578 * the required size of the streaming buffer
579 * @param [in] optlen sizeof(size_t)
581 * @return 0 is returned upon success. Otherwise:
583 * - -EFAULT (Invalid data address given)
584 * - -ENOMEM (Not enough memory)
585 * - -EINVAL (@a optlen is invalid)
588 * @par Calling context:
589 * RT/non-RT
591 #define XDDP_BUFSZ 3
593 * XDDP monitoring callback
595 * Other RTDM drivers may install a user-defined callback via the @ref
596 * rtdm_setsockopt call from the inter-driver API, in order to collect
597 * particular events occurring on the channel.
599 * This notification mechanism is particularly useful to monitor a
600 * channel asynchronously while performing other tasks.
602 * The user-provided routine will be passed the RTDM file descriptor
603 * of the socket receiving the event, the event code, and an optional
604 * argument. Four events are currently defined, see @ref XDDP_EVENTS.
606 * The XDDP_EVTIN and XDDP_EVTOUT events are fired on behalf of a
607 * fully atomic context; therefore, care must be taken to keep their
608 * overhead low. In those cases, the Xenomai services that may be
609 * called from the callback are restricted to the set allowed to a
610 * real-time interrupt handler.
612 * @param [in] level @ref sockopts_xddp "SOL_XDDP"
613 * @param [in] optname @b XDDP_MONITOR
614 * @param [in] optval Pointer to a pointer to function of type int
615 * (*)(int fd, int event, long arg), containing the address of the
616 * user-defined callback.Passing a NULL callback pointer
617 * in @a optval disables monitoring.
618 * @param [in] optlen sizeof(int (*)(int fd, int event, long arg))
620 * @return 0 is returned upon success. Otherwise:
622 * - -EFAULT (Invalid data address given)
623 * - -EPERM (Operation not allowed from user-space)
624 * - -EINVAL (@a optlen is invalid)
627 * @par Calling context:
628 * RT/non-RT, kernel space only
630 #define XDDP_MONITOR 4
631 /** @} */
634 * @anchor XDDP_EVENTS @name XDDP events
635 * Specific events occurring on XDDP channels, which can be monitored
636 * via the @ref XDDP_MONITOR socket option.
638 * @{ */
640 * @ref XDDP_MONITOR "Monitor" writes to the non real-time endpoint.
642 * XDDP_EVTIN is sent when data is written to the non real-time
643 * endpoint the socket is bound to (i.e. via /dev/rtp@em N), which
644 * means that some input is pending for the real-time endpoint. The
645 * argument is the size of the incoming message.
647 #define XDDP_EVTIN 1
649 * @ref XDDP_MONITOR "Monitor" reads from the non real-time endpoint.
651 * XDDP_EVTOUT is sent when the non real-time endpoint successfully
652 * reads a complete message (i.e. via /dev/rtp@em N). The argument is
653 * the size of the outgoing message.
655 #define XDDP_EVTOUT 2
657 * @ref XDDP_MONITOR "Monitor" close from the non real-time endpoint.
659 * XDDP_EVTDOWN is sent when the non real-time endpoint is closed. The
660 * argument is always 0.
662 #define XDDP_EVTDOWN 3
664 * @ref XDDP_MONITOR "Monitor" memory shortage for non real-time
665 * datagrams.
667 * XDDP_EVTNOBUF is sent when no memory is available from the pool to
668 * hold the message currently sent from the non real-time
669 * endpoint. The argument is the size of the failed allocation. Upon
670 * return from the callback, the caller will block and retry until
671 * enough space is available from the pool; during that process, the
672 * callback might be invoked multiple times, each time a new attempt
673 * to get the required memory fails.
675 #define XDDP_EVTNOBUF 4
676 /** @} */
678 #define SOL_IDDP 312
680 * @anchor sockopts_iddp @name IDDP socket options
681 * Setting and getting IDDP socket options.
682 * @{ */
684 * IDDP label assignment
686 * ASCII label strings can be attached to IDDP ports, in order to
687 * connect sockets to them in a more descriptive way than using plain
688 * numeric port values.
690 * When available, this label will be registered when binding, in
691 * addition to the port number (see @ref iddp_label_binding
692 * "IDDP port binding").
694 * It is not allowed to assign a label after the socket was
695 * bound. However, multiple assignment calls are allowed prior to the
696 * binding; the last label set will be used.
698 * @param [in] level @ref sockopts_iddp "SOL_IDDP"
699 * @param [in] optname @b IDDP_LABEL
700 * @param [in] optval Pointer to struct rtipc_port_label
701 * @param [in] optlen sizeof(struct rtipc_port_label)
703 * @return 0 is returned upon success. Otherwise:
705 * - -EFAULT (Invalid data address given)
706 * - -EALREADY (socket already bound)
707 * - -EINVAL (@a optlen is invalid)
710 * @par Calling context:
711 * RT/non-RT
713 #define IDDP_LABEL 1
715 * IDDP local pool size configuration
717 * By default, the memory needed to convey the data is pulled from
718 * Xenomai's system pool. Setting a local pool size overrides this
719 * default for the socket.
721 * If a non-zero size was configured, a local pool is allocated at
722 * binding time. This pool will provide storage for pending datagrams.
724 * It is not allowed to configure a local pool size after the socket
725 * was bound. However, multiple configuration calls are allowed prior
726 * to the binding; the last value set will be used.
728 * @note: the pool memory is obtained from the host allocator by the
729 * @ref bind__AF_RTIPC "bind call".
731 * @param [in] level @ref sockopts_iddp "SOL_IDDP"
732 * @param [in] optname @b IDDP_POOLSZ
733 * @param [in] optval Pointer to a variable of type size_t, containing
734 * the required size of the local pool to reserve at binding time
735 * @param [in] optlen sizeof(size_t)
737 * @return 0 is returned upon success. Otherwise:
739 * - -EFAULT (Invalid data address given)
740 * - -EALREADY (socket already bound)
741 * - -EINVAL (@a optlen is invalid or *@a optval is zero)
744 * @par Calling context:
745 * RT/non-RT
747 #define IDDP_POOLSZ 2
748 /** @} */
750 #define SOL_BUFP 313
752 * @anchor sockopts_bufp @name BUFP socket options
753 * Setting and getting BUFP socket options.
754 * @{ */
756 * BUFP label assignment
758 * ASCII label strings can be attached to BUFP ports, in order to
759 * connect sockets to them in a more descriptive way than using plain
760 * numeric port values.
762 * When available, this label will be registered when binding, in
763 * addition to the port number (see @ref bufp_label_binding
764 * "BUFP port binding").
766 * It is not allowed to assign a label after the socket was
767 * bound. However, multiple assignment calls are allowed prior to the
768 * binding; the last label set will be used.
770 * @param [in] level @ref sockopts_bufp "SOL_BUFP"
771 * @param [in] optname @b BUFP_LABEL
772 * @param [in] optval Pointer to struct rtipc_port_label
773 * @param [in] optlen sizeof(struct rtipc_port_label)
775 * @return 0 is returned upon success. Otherwise:
777 * - -EFAULT (Invalid data address given)
778 * - -EALREADY (socket already bound)
779 * - -EINVAL (@a optlen is invalid)
782 * @par Calling context:
783 * RT/non-RT
785 #define BUFP_LABEL 1
787 * BUFP buffer size configuration
789 * All messages written to a BUFP socket are buffered in a single
790 * per-socket memory area. Configuring the size of such buffer prior
791 * to binding the socket to a destination port is mandatory.
793 * It is not allowed to configure a buffer size after the socket was
794 * bound. However, multiple configuration calls are allowed prior to
795 * the binding; the last value set will be used.
797 * @note: the buffer memory is obtained from the host allocator by the
798 * @ref bind__AF_RTIPC "bind call".
800 * @param [in] level @ref sockopts_bufp "SOL_BUFP"
801 * @param [in] optname @b BUFP_BUFSZ
802 * @param [in] optval Pointer to a variable of type size_t, containing
803 * the required size of the buffer to reserve at binding time
804 * @param [in] optlen sizeof(size_t)
806 * @return 0 is returned upon success. Otherwise:
808 * - -EFAULT (Invalid data address given)
809 * - -EALREADY (socket already bound)
810 * - -EINVAL (@a optlen is invalid or *@a optval is zero)
813 * @par Calling context:
814 * RT/non-RT
816 #define BUFP_BUFSZ 2
817 /** @} */
820 * @anchor sockopts_socket @name Socket level options
821 * Setting and getting supported standard socket level options.
822 * @{ */
825 * @ref IPCPROTO_IDDP and @ref IPCPROTO_BUFP protocols support the
826 * standard SO_SNDTIMEO socket option, from the @c SOL_SOCKET level.
828 * @see @c setsockopt(), @c getsockopt() in IEEE Std 1003.1,
829 * http://www.opengroup.org/onlinepubs/009695399/
831 #ifdef DOXYGEN_CPP
832 #define SO_SNDTIMEO defined_by_kernel_header_file
833 #endif
836 * All RTIPC protocols support the standard SO_RCVTIMEO socket option,
837 * from the @c SOL_SOCKET level.
839 * @see @c setsockopt(), @c getsockopt() in IEEE Std 1003.1,
840 * http://www.opengroup.org/onlinepubs/009695399/
842 #ifdef DOXYGEN_CPP
843 #define SO_RCVTIMEO defined_by_kernel_header_file
844 #endif
845 /** @} */
848 * @anchor rtipc_examples @name RTIPC examples
849 * @{ */
850 /** @example bufp-readwrite.c */
851 /** @example bufp-label.c */
852 /** @example iddp-label.c */
853 /** @example iddp-sendrecv.c */
854 /** @example xddp-echo.c */
855 /** @example xddp-label.c */
856 /** @example xddp-stream.c */
857 /** @} */
859 /** @} */
861 #endif /* !_RTIPC_H */