sbgECom Library  4.0.1987-stable
C library to interface SBG Systems IMU/AHRS/INS
sbgInterfaceUdp.h File Reference

This file implements an UDP interface. More...

#include <sbgCommon.h>
#include <interfaces/sbgInterface.h>

Go to the source code of this file.

Functions

SBG_COMMON_LIB_API SbgErrorCode sbgInterfaceUdpCreate (SbgInterface *pInterface, sbgIpAddress remoteAddr, uint32_t remotePort, uint32_t localPort)
 
SBG_COMMON_LIB_API void sbgInterfaceUdpSetConnectedMode (SbgInterface *pInterface, bool useConnected)
 
SBG_COMMON_LIB_API bool sbgInterfaceUdpGetConnectedMode (const SbgInterface *pInterface)
 
SBG_COMMON_LIB_API SbgErrorCode sbgInterfaceUdpAllowBroadcast (SbgInterface *pInterface, bool allowBroadcast)
 

Detailed Description

This file implements an UDP interface.

Author
SBG Systems
Date
05 February 2013
License

The MIT license

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Function Documentation

◆ sbgInterfaceUdpCreate()

SBG_COMMON_LIB_API SbgErrorCode sbgInterfaceUdpCreate ( SbgInterface pInterface,
sbgIpAddress  remoteAddr,
uint32_t  remotePort,
uint32_t  localPort 
)

Initialize an unconnected UDP interface for read and write operations.

Connected/Unconnected modes:

The UDP socket is unconnected so any host sending data on localPort should be received. However, only the host specified in remoteAddr should received sent data on remotePort.

You can enable the connected mode with the sbgInterfaceUdpSetConnectedMode method. If this case, only datagrams sent by the host with remoteAddr ip and remotePort will be received and any other traffic should be discarded.

Broadcast:

You can specify a SBG_IPV4_BROADCAST_ADDR address to send an UDP datagram to all hosts However, you have to allow broadcasted packets with the sbgInterfaceUdpAllowBroadcast method.

Parameters
[in]pInterfacePointer on an allocated interface instance to initialize.
[in]remoteAddrIP address to send data to.
[in]remotePortEthernet port to send data to.
[in]localPortEthernet port on which the interface is listening.
Returns
SBG_NO_ERROR if the interface has been created.

◆ sbgInterfaceUdpSetConnectedMode()

SBG_COMMON_LIB_API void sbgInterfaceUdpSetConnectedMode ( SbgInterface pInterface,
bool  useConnected 
)

Define if the UDP socket should use connected or unconnected mode.

If connected mode is enabled, the interface only accepts datagrams from remortAddr & remotePort.

Parameters
[in]pInterfacePointer on a valid UDP interface created using sbgInterfaceUdpCreate.
[in]useConnectedSet to true to enable connected mode and false for unconnected.

◆ sbgInterfaceUdpGetConnectedMode()

SBG_COMMON_LIB_API bool sbgInterfaceUdpGetConnectedMode ( const SbgInterface pInterface)

Returns if the UDP socket is using or not connected mode.

Parameters
[in]pInterfacePointer on a valid UDP interface created using sbgInterfaceUdpCreate.
Returns
true if connected mode is enabled or false otherwise.

◆ sbgInterfaceUdpAllowBroadcast()

SBG_COMMON_LIB_API SbgErrorCode sbgInterfaceUdpAllowBroadcast ( SbgInterface pInterface,
bool  allowBroadcast 
)

Define if a socket can send broadcasted packets.

Parameters
[in]pInterfacePointer on a valid UDP interface created using sbgInterfaceUdpCreate.
[in]allowBroadcastSet to true to allow this socket to send broadcasted UDP packets.
Returns
SBG_NO_ERROR if the allow broadcast status has been changed.