Definitions

There are a few precompiler directives that help with messaging.

  • DAX_MSGMAX - This is the maximum size that a message is allowed to be. This helps us limit the size of the buffers in the server. If memory is an issue on a platform this number can be lowered.
  • MSG_HDR_SIZE - This is the size of the message header. The header is the same for all messages not matter the command is.
  • MSG_DATA_SIZE - (DAX_MSGMAX - MSG_HDR_SIZE) This represents the size of the data payload area of the message.
  • REG_TEST_???? - These are the packaging test points to determine whether or not a module will be required to pack it's data. See the Registration message protocol for more information.
  • CHECK_COMMAND(x) - This is a macro that returns 1 if x is NOT a valid command and 0 of it is a valid command.

Messages are represented inside the server with a structure defined as...


typedef struct {
u_int32_t size; /* size of the data sent */
u_int32_t command; /* Which function to call */
char data[MSG_DATA_SIZE];
int fd; /* We'll use the fd to identify the module*/
} dax_message;

The parts of the actual message header are above the data area. The data area is pre-defined to be big enough for the largest message. Everything below the data[] member is information that is helpful to the inner workings of the server but are not sent as part of the actual socket communications. For now the file descriptor of the socket is all that is defined here.

The size will always be sent in network byte order. This saves having to figure out which module sent the message before the message is received. It also saves some complexity for a registration message because we may not know which module sent the registration.