CIGI API Version 2.7.1 
CIGI API : Users' Guide
Using the API : Working with Packets

Working with CIGI Packets

The packet structures defined in the CIGI API are a representation of the packets that are used to compose CIGI messages. All packet definitions in the API are created and upadted from the CIGI interface control document (ICD) specification, and the use of these packets is intended to be consistent with the interface and rules stated in the ICD specification for the CIGI. Refer to the resources in the references section for more information about obtaining the CIGI ICD.

Bit Fields in Packets

Many of the CIGI packets contain bit fields, since these fields only take a specified number of bits and only have an enumerated set of meaningful values, as indicated by the CIGI ICD specification for the version of CIGI being used. Each bit field is of type unsigned int, in order to be compliant with the ANSI C specification.

The valid values for each of the bit-fields are listed as preprocessor definitions under the packet declaration in the cigi_icd.h header file, or can be obtained from the CIGI ICD.

Variable Length Packets

The CIGI_USER_DATA_PACKET and CIGI_IG_RESPONSE_MESSAGE packets are handled in a different way than other CIGI packets because they contain variable-length data. A more detailed explanation for using these packets is provided.

Packet Helper Functions

The CigiPrintXXXPacket and CigiCreateXXXPacket utility functions have been created for each of the packets, and are used to print or initialize the packets, respectively. These are defined in the cigi_helper.h header file and implemented in cigi_helper.c source file.

The following example illustrates how to use a CigiCreateXXXPacket function to initialize a CIGI_ENTITY_CONTROL packet.

/* Initializes a CIGI_ENTITY_CONTROL packet */ CIGI_ENTITY_CONTROL entityControl = CigiCreateEntityControlPacket();

The CigiCreateEntityControlPacket function will initialize all numerical values to 0, except the packet_id and packet_size fields, which it will set to the appropriate value.

To print the packet (to stdout), the following function can be used, indicating the number of indent spaces to preceed each line with. In this example the indent size is 4 spaces.

/* Print the CIGI_ENTITY_CONTROL packet to stdout */ CigiPrintEntityControlPacket( &entityControl, 4);

In addition, the CigiPrintPacket function can be used to print any packet excpet user definable packets. It will determine which CigiPrintXXXPacket function to invoke depending on the value of the opcode parameter, which is the same value as the packet's packet_id field.

To obtain the name of a packet, the CigiOpcodeToPacketName function can be used. It determines the name of the packet from the opcode parameter, which is the same as the packet's packet_size field. The prototypes for these two functions are as follows.

/* Print the CIGI_ENTITY_CONTROL packet to stdout */ CigiPrintPacket( const int nType, const void* pPacket, const int nIndentSize); /* Print the CIGI_ENTITY_CONTROL packet to stdout */ const char* CigiOpcodeToPacketName( const int opcode);
SourceForge LogoBoeing
******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ********