MESGLD(4) MESGLD(4) NAME mesg_ld, rmesg_ld - message line discipline modules SYNOPSIS #include <sys/types.h> #include <sys/stream.h> DESCRIPTION Mesg_ld and rmesg_ld turn internal stream messages into ordinary data and vice versa. They supply a way to splice a stream connection together through a process or across a network connection. The messages represent ordinary data and various control operations. After mesg_ld has been pushed on a stream, read(2) on the stream returns encoded messages; write is expected to supply messages in the same coding. An encoded message consists of a header followed by zero or more bytes of associated data. The header, as defined in <sys/stream.h>, is of the form struct mesg { char type; unsigned char magic; unsigned char losize, hisize; }; #define MSGMAGIC 0345 #define MSGHLEN 4 /* true length of struct mesg in bytes */ The header is MSGHLEN bytes long; beware that this is not always the same as `sizeof(struct mesg)'. The magic field contains the constant MSGMAGIC, to help prevent interpreting bad data as a message header. There are losize+(hisize<<8) bytes of associated data. Messages may be written in pieces, or several messages may be written at once. At most one message will be read at a time. If an impossible message is written, the stream may be shut down. Rmesg_ld is exactly the opposite of mesg_ld. It is intended for use with devices that generate data containing encoded messages. Here is a list of message types, defined in <sys/stream.h>: M_DATA (0) Ordinary data. M_BREAK (01) A line break on an RS232-style asynchronous connection. No associated data. M_HANGUP (02) When received, indicates that the other side has gone away. Thereafter the stream is useless. No associated data. MESGLD(4) MESGLD(4) M_DELIM (03) A delimiter that introduces a record boundary in the data. No associated data. M_IOCTL (06) An ioctl(2) request. The associated data is a four-byte integer containing the function code, least significant byte first, followed by some amount of associated data. An M_IOCACK or M_IOCNAK reply is expected. M_DELAY (07) A real-time delay. One byte of data, giving the number of clock ticks of delay time. M_CTL (010) Device-specific control message. M_SIGNAL (0101) Generate signal number given in the one- byte message. M_FLUSH (0102) Flush input and output queue if possible. M_STOP (0103) Stop transmission immediately. M_START (0104) Restart transmission after M_STOP. M_IOCACK (0105) Successful reply to M_IOCTL. Associated data is to be written back to the caller. M_IOCNAK (0106) Failed reply to M_IOCTL. A single-byte message, if present, will be returned in by the failing ioctl. M_PRICTL (0107) High-priority device-specific control mes- sage. SEE ALSO stream(4) BUGS The format of arguments to M_IOCTL is machine dependent. The amount of associated data is limited, but large (>4K).