$search
#include "build.h"
#include "build.h"
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "ipcam_packet.h"
Go to the source code of this file.
Defines | |
#define | SEC_TO_USEC(sec) (1000*1000*sec) |
Functions | |
int | wge100ArpAdd (IpCamList *camInfo) |
int | wge100ArpDel (IpCamList *camInfo) |
int | wge100CmdSocketCreate (const char *ifName, NetHost *localHost) |
int | wge100EthGetLocalMac (const char *ifName, struct sockaddr *macAddr) |
int | wge100IpGetLocalAddr (const char *ifName, struct in_addr *addr) |
int | wge100IpGetLocalBcast (const char *ifName, struct in_addr *bcast) |
int | wge100IpGetLocalNetmask (const char *ifName, struct in_addr *bcast) |
int | wge100SendUDP (int s, const IPAddress *ip, const void *data, size_t dataSize) |
int | wge100SendUDPBcast (int s, const char *ifName, const void *data, size_t dataSize) |
int | wge100SocketConnect (int s, const IPAddress *ip) |
int | wge100SocketCreate (const struct in_addr *addr, uint16_t port) |
int | wge100WaitForPacket (int *s, int nums, uint32_t type, size_t pktLen, uint32_t *wait_us) |
#define SEC_TO_USEC | ( | sec | ) | (1000*1000*sec) |
Definition at line 65 of file host_netutil.h.
int wge100ArpAdd | ( | IpCamList * | camInfo | ) |
Add a 'permanent' ARP to IP mapping in the system ARP table for one camera. Since the cameras do not support ARP, this step is necessary so that the host can find them.
camInfo | An IpCamList element that describes the IP and MAC of the camera |
Definition at line 61 of file host_netutil.c.
int wge100ArpDel | ( | IpCamList * | camInfo | ) |
Remove an to IP mapping from the system ARP table for one camera. This function can be used to prevent cluttering the ARP table with unused 'permanent' mappings.
camInfo | An IpCamList element that describes the IP and MAC of the camera |
Definition at line 107 of file host_netutil.c.
int wge100CmdSocketCreate | ( | const char * | ifName, | |
NetHost * | localHost | |||
) |
Creates and binds a new command packet socket for communicating to a camera. Will always bind to an ephemeral local port number.
ifName | Interface name to bind to. Null terminated string (e.g., "eth0") | |
localHost | Optional pointer to a structure to receive the local host (MAC/IP/Port) information |
Definition at line 387 of file host_netutil.c.
int wge100EthGetLocalMac | ( | const char * | ifName, | |
struct sockaddr * | macAddr | |||
) |
Utility function to retrieve the MAC address asssociated with a specified Ethernet interface name.
ifName | A null-terminated string containing the name of the Ethernet address (e.g., eth0) | |
macAddr | A sockaddr structure to contain the MAC |
Definition at line 154 of file host_netutil.c.
int wge100IpGetLocalAddr | ( | const char * | ifName, | |
struct in_addr * | addr | |||
) |
Utility function to retrieve the local IPv4 address asssociated with a specified Ethernet interface name.
ifName | A null-terminated string containing the name of the Ethernet address (e.g., eth0) | |
macAddr | A in_addr structure to contain the local interface IP |
Definition at line 231 of file host_netutil.c.
int wge100IpGetLocalBcast | ( | const char * | ifName, | |
struct in_addr * | bcast | |||
) |
Utility function to retrieve the broadcast IPv4 address asssociated with a specified Ethernet interface name.
ifName | A null-terminated string containing the name of the Ethernet address (e.g., eth0) | |
macAddr | A in_addr structure to contain the broadcast IP |
Definition at line 193 of file host_netutil.c.
int wge100IpGetLocalNetmask | ( | const char * | ifName, | |
struct in_addr * | addr | |||
) |
Utility function to retrieve the local IPv4 netmask asssociated with a specified Ethernet interface name.
ifName | A null-terminated string containing the name of the Ethernet address (e.g., eth0) | |
macAddr | A in_addr structure to contain the local interface IP |
Definition at line 269 of file host_netutil.c.
int wge100SendUDP | ( | int | s, | |
const IPAddress * | ip, | |||
const void * | data, | |||
size_t | dataSize | |||
) |
Utility function to send 'dataSize' bytes of 'data' to remote address 'ip'. This function always sends to the WG_CAMCMD_PORT port.
s | Bound socket to send on | |
ip | IPv4 Address of remote camera to send to | |
data | Array of at least dataSize bytes, containing payload to send | |
dataSize | Size of payload to send, in bytes |
Definition at line 435 of file host_netutil.c.
int wge100SendUDPBcast | ( | int | s, | |
const char * | ifName, | |||
const void * | data, | |||
size_t | dataSize | |||
) |
Utility function that wraps wge100SendUDP to send a packet to the broadcast address on the specified interface.
s | Bound socket to send on | |
ifName | Name of interface socket is bound on. (Null terminated string, e.g., "eth0") | |
data | Array of at least dataSize bytes, containing payload to send | |
dataSize | Size of payload to send, in bytes |
Definition at line 464 of file host_netutil.c.
int wge100SocketConnect | ( | int | s, | |
const IPAddress * | ip | |||
) |
Utility wrapper to 'connect' a datagram socket to a specific remote host. Once connected, the socket can only receive datagrams from that host.
s | The open and bound local socket to connect. | |
ip | The remote IP address to connect to. |
Definition at line 353 of file host_netutil.c.
int wge100SocketCreate | ( | const struct in_addr * | addr, | |
uint16_t | port | |||
) |
Utility function to create a UDP socket and bind it to a specified address & port.
addr | The host IP address to bind to. | |
port | The host UDP port to bind to. Host byte order. Port of 0 causes bind() to assign an ephemeral port. |
Definition at line 306 of file host_netutil.c.
int wge100WaitForPacket | ( | int * | s, | |
int | nums, | |||
uint32_t | type, | |||
size_t | pktLen, | |||
uint32_t * | wait_us | |||
) |
Waits for a specified amount of time for a WGE100 packet that matches the specified length and type criteria.
On return, the wait_us argument is updated to reflect the amount of time still remaining in the original timeout. This can be useful when calling wge100WaitForPacket() in a loop.
s | The datagram sockets to listen on. It must be opened, bound, and connected. | |
nums | The number of sockets to listen on. | |
type | The WGE100 packet type to listen for. Packets that do not match this type will be discarded | |
pktLen | The length of WGE100 packet to listen for. Packets that do not match this length will be discarded. | |
wait_us | The duration of time to wait before timing out. Is adjusted upon return to reflect actual time remaning on the timeout. |
Definition at line 493 of file host_netutil.c.