Entities are organized according to [1]. The recommendation introduces the SDL diagrams to describe the algorithms of how the signalling entities work. These diagrams in this project are transformed directly into C-code. There is no need to introduce the entire bodies of entities' procedures. Instead, the rules of how SDL diagrams were converted into the code. All the rules and the code were prepared by the author. Of course, the transformation could be organized in a different way. The used structures are presented in The API, used by the entities is presented in . Four special functions have been prepared to be used by the procedures. These functions are called from the entities' functions, so they are internal ones. The user does not need to be conscious of their capabilities. They are introduced here to show how the conversation is preceeded.
The SendH245Message function is used to send a message to the peer (over a TCP socket). mn is a name of the message (e.g. OpenLogicalChannel), and parameters are parameters of the message. This function prepares the message (ASN.1 tree), then encodes it and sends to the peer.
The SendPrimitive function passes a primitive to the user. mt is a name of a primitive (e.g. H245_OPEN_LC_CONF), and message_params is a structure of the parameters for the given message.
The GetMessageOrPrimitive function gets a message or a primitive. When a message comes from the peer, it is stored in the entity message queue by the "TCP Manager". Every entity has a pointer to this queue as well as it has a pointer to the queue of primitives from the user. Say that two variables q1 and q2 are the pointers to queue from the "TCP Manager" and from the "User Manager" respectively, and m, n, and o are variables of the type struct message. GetMessageOrPrimitive may be called as follows:
m = GetMessageOrPrimitive(q1, q2); n = GetMessageOrPrimitive(q1, NULL); o = GetMessageOrPrimitive(NULL, q2);The first line shows the typical call of the routine (two non-zero parameters). First, the function checks whether there are any messages in q1. If positive, function returns with the appropriate message. Otherwise it checks q2. If positive, it returns the message. Otherwise the function blocks infinitely until a message appears in any queue. The second and the third call from the example show the usage of the function with one parameter only. In this case the functions checks just one, non-zero queue.
The GetMessageOrPrimitiveWithTimeout function is the version of GetMessageOrPrimitive with a timeout. Unless it can get a primitive from any queue, it blocks for secs seconds. After this time it returns a special, "timeout" primitive.
Now the transformation of SDL diagrams may be introduced. Figure 3-6 shows how every block is interpreted.