6.5. Configure UDP Transport

You will need to configure and register the UDP transport component with Connext Cert. To do this, create an instance of the UDP properties, add one or more network interfaces to the properties, then register the UDP transport.

Example code:

  • Create an instance of the UDP transport properties:

    #include "netio/netio_psl_udp.h"
    
    UDPv4_TransportProperty_T *udp_property = NULL;
    udp_property = UDPv4_TransportProperty_new();
    
  • Add a network interface to the UDP transport properties:

    /* This function takes the following arguments:
     * Param 1 is the UDP property
     * Param 2 is the IP address of the interface in host order
     * Param 3 is the Netmask of the interface
     * Param 4 is the name of the interface
     * Param 5 are flags. The following flags are supported (use OR for multiple):
     *      UDP_INTERFACE_INTERFACE_UP_FLAG - Interface is up
     *      UDP_INTERFACE_INTERFACE_MULTICAST_FLAG - Interface supports multicast
     */
    if (!UDPv4_InterfaceTable_add_entry(
                udp_property,
                0x7f000001, /* 127.0.0.1 */
                0xff000000,
                "lo",
                UDP_INTERFACE_INTERFACE_UP_FLAG |
                UDP_INTERFACE_INTERFACE_MULTICAST_FLAG))
    {
        printf("ERROR: Failed to add interface\n");
    }
    
  • Register the UDP component with updated properties:

    const char* const MY_UDP_NAME = "_udp";
    
    if (!UDPv4_Interface_register(registry, MY_UDP_NAME, udp_property))
    {
        /* failure */
    }
    

For more details, see the Transports section in the User’s Manual.