sbgECom Library
4.0.1987-stable
C library to interface SBG Systems IMU/AHRS/INS
|
This file implements an UDP interface. More...
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) |
This file implements an UDP interface.
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.
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.
[in] | pInterface | Pointer on an allocated interface instance to initialize. |
[in] | remoteAddr | IP address to send data to. |
[in] | remotePort | Ethernet port to send data to. |
[in] | localPort | Ethernet port on which the interface is listening. |
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.
[in] | pInterface | Pointer on a valid UDP interface created using sbgInterfaceUdpCreate. |
[in] | useConnected | Set to true to enable connected mode and false for unconnected. |
SBG_COMMON_LIB_API bool sbgInterfaceUdpGetConnectedMode | ( | const SbgInterface * | pInterface | ) |
Returns if the UDP socket is using or not connected mode.
[in] | pInterface | Pointer on a valid UDP interface created using sbgInterfaceUdpCreate. |
SBG_COMMON_LIB_API SbgErrorCode sbgInterfaceUdpAllowBroadcast | ( | SbgInterface * | pInterface, |
bool | allowBroadcast | ||
) |
Define if a socket can send broadcasted packets.
[in] | pInterface | Pointer on a valid UDP interface created using sbgInterfaceUdpCreate. |
[in] | allowBroadcast | Set to true to allow this socket to send broadcasted UDP packets. |