Skip to main content

Network Callbacks

The application supplies network callbacks so SK400VOP can use the target platform's networking implementation without embedding platform-specific socket code in the signaling stack.

The callback interface follows Berkeley/BSD Sockets concepts and compatible address structures. On platforms that use different APIs, the application should provide a mapping layer with equivalent behavior.

CallbackPurpose
SOCK_CREATE_CBCreates a socket or equivalent network endpoint (socket() semantics).
SOCK_CLOSE_CBCloses a socket or network endpoint (close() / closesocket() semantics).
SOCK_BIND_CBBinds an endpoint to a local address and port (bind() semantics).
SOCK_SENDTO_CBSends a datagram or packet to a destination (sendto() semantics).
SOCK_RECEIVEFROM_CBReceives a datagram or packet and source address (recvfrom() semantics).
SOCK_IOCTL_CBPerforms socket-control operations (ioctl() / ioctlsocket() semantics).
INET_PTON_CBConverts a presentation-format IPv4/IPv6 address to binary form (inet_pton() semantics).
INET_NTOP_CBConverts a binary IPv4/IPv6 address to presentation format (inet_ntop() semantics).
NET_MATCH_SUBNET_CBDetermines whether two addresses belong to the same local subnet according to the application's network configuration.
NET_GET_LOCAL_ADDR_CBReturns the local/interface address that SK400VOP should use for the requested network path. This is the local address, not the public NAT mapping.
NET_GET_MAPPED_ADDR_CBReturns the externally mapped/public address corresponding to a local interface when NAT traversal is required. The application may implement STUN or another environment-specific mapping method.
NET_RESOLVE_HOST_CBResolves a hostname/FQDN to an IPv4 or IPv6 address in the form expected by the stack.

Local address versus mapped address​

These two callbacks serve different purposes and should not return the same value automatically:

  • NET_GET_LOCAL_ADDR_CB identifies the address assigned to, or selected for, the local interface.
  • NET_GET_MAPPED_ADDR_CB identifies the externally visible address when a NAT device translates the local endpoint.

On a host with a directly routable address, the application can choose to return equivalent addresses when that matches the deployment, but the callbacks remain logically distinct.

Platform notes​

Windows uses functions such as closesocket() and ioctlsocket(), while POSIX-like systems commonly use close() and ioctl(). The callback layer exists so application code can hide those differences from SK400VOP.

For dual-stack targets, ensure the conversion, bind and resolver callbacks preserve the address family and structure layout expected by the supplied SK400VOP headers.