Solstice X.25 9.2 Developer's Guide

12.4.1 Control of the M-, D-, and Q-bits

The settings of M-, D- and Q-bits in transmitted packets are changed by means of the X25_SEND_TYPE ioctl call.

ints, send_type;
 error = ioctl(s, X25_SEND_TYPE, &send_type);

send_type provides the new settings of the M-, D-, and Q-bits. The M-, D-, and Q-bits are encoded into the send_type field by bit shifting as shown below.

#define M_BIT 0       /* number of bits to shift to set "more"
        * bit */
 #define D_BIT 2       /* number of bits to shift to set end-to-end
        * acknowledge bit */
 #define Q_BIT 3       /* number of bits to shift to set qualified
        * data bit */

For example, to set the Q-bit in a packet:

intsend_type = (1 << Q_BIT), s;
 error = ioctl(s, X25_SEND_TYPE, &send_type); 

M_BIT determines whether or not a packet is the final piece of a complete X.25 message. If M_BIT is set, subsequent send calls are treated as part of a single X.25 message. If M_BIT is not set, the next send ends the current X.25 message. For example, the following code allows a complete X.25 message to be sent in three pieces:

ints, send_type, error;
 /* Set M_BIT to indicate multiple pieces */
 send_type = (1 << M_BIT);
 error = ioctl(s, X25_SEND_TYPE, &send_type);
 /* send first piece */
 error = send(s, &first_piece, sizeof(first_piece), 0);
 /* send next piece */
 error = send(s, &second_piece, sizeof(second_piece), 0);
 /* Clear M_BIT to indicate end of message */
 send_type = 0;
 error = ioctl(s, X25_SEND_TYPE, &send_type);
 /* send final piece */
 error = send(s, &final_piece, sizeof(final_piece), 0);   

If the M-bit is turned on using the X25_SEND_TYPE ioctl, it will stay turned on until it is turned off. The X.25 recommendation states that the M-bit shall be turned on only in packets that are "full"--that is, packets that have the maximum size for that virtual circuit. So if the M-bit is turned on, and the next send does not supply a full X.25 packet, X.25 will wait until enough send calls have been issued to build a full X.25 packet before transmitting the next packet with the M-bit turned on.

The Q-bit qualifies the data in Data packets. A local DTE sets the Q-bit to indicate that the data being sent is significant for a device connected to the remote DTE. It is often used by a remote host when sending control packets to a PAD, to distinguish the control packets from packets containing user data.

The D-bit allows a local DTE to specify end-to-end acknowledgment of data packets. Normally, a DTE receives acknowledgement only from its local DCE. The D-bit is significant only in call setup and data packets.

D_BIT and Q_BIT control the settings of those bits in an X.25 packet. These bits are manipulated in the same manner as the M_BIT was above. Since the X.25 recommendation states that the D_BIT and Q_BIT bits should remain constant for each packet in a complete X.25 message, D_BIT and Q_BIT should only be changed at the beginning of an X.25 message.

Unlike M_BIT, D_BIT and Q_BIT are turned off automatically after a complete X.25 message has been sent. Hence, to set these bits in a series of complete X.25 messages, you should turn them on at the start of each complete X.25 message. If the complete X.25 message is a sequence of full packets with the more bit turned on in all but the last packet in the sequence, the setting of D_BIT and Q_BIT will be the same for all the packets unless you explicitly change the setting in between.