next up previous contents
Next: Fragmenting and Reassembling Up: Message Library Previous: Message Library

Adding and Stripping Headers

As outgoing messages move down the protocol graph, each protocol attaches (pushes) its header onto the front of the message. Similarly, as an incoming message moves up the protocol graph, each protocol strips (pops) its header from the front of the message. The message object supports the following two operations for pushing and popping headers:

char *msgPush(Msg *message, int length)

char *msgPop(Msg *message, int length)

Both operations return a pointer to a buffer that contains the header. In the case of msgPush, room for length bytes is attached to the front of the message, and a pointer to this memory location is returned. The protocol can then write the header to this location to effectively add the header to the message. In the case of msgPop, length bytes are removed from the front of the message. The protocol can then read the header available at the returned memory location. Figures 7 and 8 illustrate the semantics of the two operations.

  
Figure 7: Effects of msgPush operation.

  
Figure 8: Effects of msgPop operation.



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