next up previous contents
Next: Traversing Messages Up: Message Library Previous: Adding and Stripping

Fragmenting and Reassembling Messages

Fragmenting and reassembling messages is a common activity in network protocols. The x-kernel supports the following two operations for manipulating message fragments:

void msgBreak(Msg *original_message, Msg *fragment_message, int length)

void msgJoin(Msg *new_message, Msg *fragment1, Msg *fragment2)

The first operation creates a pair of messages by breaking length bytes off the front of the original_message and placing them in fragment_message. After the operation returns, original_message contains the sequence of bytes that remain after length bytes are removed. The second operation attaches fragment1 to the front of fragment2, producing new_message. The arguments to msgJoin need not refer to distinct messages. One common use of msgJoin is to attach a fragment to the end of a larger message, in which case the first two arguments are the same (the larger message) and the third argument is the fragment. These two operations are illustrated in Figures 9 and 10.

  
Figure 9: Effects of msgBreak operation.

  
Figure 10: Effects of msgJoin operation.



Larry Peterson
Wed Feb 21 13:58:06 MST 1996