|
Open Model Railroad Network (OpenMRN)
|
#include "CC32xxSocket.hxx"#include "CC32xxWiFi.hxx"#include "CC32xxHelper.hxx"#include <memory>#include <fcntl.h>#include <unistd.h>#include <netdb.h>#include <netinet/in.h>#include <netinet/tcp.h>#include <ifaddrs.h>#include <sys/socket.h>#include <ti/drivers/net/wifi/simplelink.h>#include "utils/format_utils.hxx"#include "utils/logging.h"Go to the source code of this file.
Macros | |
| #define | SUPPORT_SL_R1_API |
| #define | CC32XX_SOCKET_RESERVED ((CC32xxSocket *)(&reservedPtr)) |
| Guard value indivating a reserved socket that is currently being allocated. | |
Functions | |
| int | socket (int domain, int type, int protocol) |
| Create an unbound socket in a communications domain. | |
| int | bind (int socket, const struct sockaddr *address, socklen_t address_len) |
| Bind a name to a socket. | |
| int | listen (int socket, int backlog) |
| Mark a connection-mode socket, specified by the socket argument, as accepting connections. | |
| int | accept (int socket, struct sockaddr *address, socklen_t *address_len) |
| Accept a new connection on a socket. | |
| int | connect (int socket, const struct sockaddr *address, socklen_t address_len) |
| Connect a socket. | |
| ssize_t | recv (int socket, void *buffer, size_t length, int flags) |
| Receive a message from a connection-mode or connectionless-mode socket. | |
| ssize_t | send (int socket, const void *buffer, size_t length, int flags) |
| Initiate transmission of a message from the specified socket. | |
| int | setsockopt (int socket, int level, int option_name, const void *option_value, socklen_t option_len) |
| Set the socket options. | |
| int | getsockopt (int socket, int level, int option_name, void *option_value, socklen_t *option_len) |
| Get the socket options. | |
| const char * | gai_strerror (int __ecode) |
| see 'man gai_strerror' | |
| void | freeaddrinfo (struct addrinfo *ai) |
| see 'man freeaddrinfo' | |
| int | getaddrinfo (const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res) |
| see 'man getaddrinfo' | |
| const char * | inet_ntop (int af, const void *src, char *dst, socklen_t size) |
| Convert the network address in src to a character string in src. | |
| int | getifaddrs (struct ifaddrs **ifap) |
| Create a linked list of structures describing the network interfaces of the local system. | |
| void | freeifaddrs (struct ifaddrs *ifa) |
| Free a previously generated linked list of structures describing the network interfaces of the local system. | |
Variables | |
| static CC32xxSocket * | cc32xxSockets [SL_MAX_SOCKETS] |
| Existing (allocated) sockets. | |
| static volatile uint8_t | reservedPtr |
| Dummy pointer address that can be used as a reserved indicator. | |
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file intantiates and initilizes the CC32xx Wi-Fi.
Definition in file net_cc32xx/CC32xxSocket.cxx.
| #define CC32XX_SOCKET_RESERVED ((CC32xxSocket *)(&reservedPtr)) |
Guard value indivating a reserved socket that is currently being allocated.
Definition at line 71 of file net_cc32xx/CC32xxSocket.cxx.
| #define SUPPORT_SL_R1_API |
Definition at line 34 of file net_cc32xx/CC32xxSocket.cxx.
Accept a new connection on a socket.
| socket | the socket file descriptor |
| address | either a null pointer, or a pointer to a sockaddr structure where the address of the connecting socket shall be returned |
| address_len | either a null pointer, if address is a null pointer, or a pointer to a socklen_t object which on input specifies the length of the supplied sockaddr structure, and on output specifies the length of the stored address |
Definition at line 1007 of file net_cc32xx/CC32xxSocket.cxx.
Bind a name to a socket.
| socket | file descriptor of the socket to be bound |
| address | points to a sockaddr structure containing the address to be bound to the socket |
| address_len | specifies the length of the sockaddr structure pointed to by the address argument |
Definition at line 974 of file net_cc32xx/CC32xxSocket.cxx.
Connect a socket.
| socket | the socket file descriptor |
| address | points to a sockaddr structure containing the peer address |
| address_len | specifies the length of the sockaddr structure pointed to by the address argument |
Definition at line 1020 of file net_cc32xx/CC32xxSocket.cxx.
| void freeaddrinfo | ( | struct addrinfo * | ai | ) |
see 'man freeaddrinfo'
| ai | is the addrinfo structure, allocated by getaddrinfo, to be released. |
Definition at line 1112 of file net_cc32xx/CC32xxSocket.cxx.
| void freeifaddrs | ( | struct ifaddrs * | ifa | ) |
Free a previously generated linked list of structures describing the network interfaces of the local system.
| ifa | pointer to the list that will be freed |
Definition at line 1356 of file net_cc32xx/CC32xxSocket.cxx.
| const char * gai_strerror | ( | int | __ecode | ) |
see 'man gai_strerror'
| __ecode | is the error code |
Definition at line 1093 of file net_cc32xx/CC32xxSocket.cxx.
| int getaddrinfo | ( | const char * | nodename, |
| const char * | servname, | ||
| const struct addrinfo * | hints, | ||
| struct addrinfo ** | res | ||
| ) |
see 'man getaddrinfo'
| nodename | what to look up (host name typically) |
| servname | local mDNS service name to look up |
| hints | not sure |
| res | an addrinfo strcture will be allocated into here |
Definition at line 1131 of file net_cc32xx/CC32xxSocket.cxx.
| int getifaddrs | ( | struct ifaddrs ** | ifap | ) |
Create a linked list of structures describing the network interfaces of the local system.
| ifap | the first item in the list is in *ifap |
Definition at line 1284 of file net_cc32xx/CC32xxSocket.cxx.
| int getsockopt | ( | int | socket, |
| int | level, | ||
| int | option_name, | ||
| void * | option_value, | ||
| socklen_t * | option_len | ||
| ) |
Get the socket options.
| socket | the socket file descriptor |
| level | specifies the protocol level at which the option resides |
| option_name | specifies a single option to get |
| option_value | the metadata that belongs to the option_name |
| option_len | the length of the metadata that belongs to the option_name |
Definition at line 1081 of file net_cc32xx/CC32xxSocket.cxx.
| const char * inet_ntop | ( | int | af, |
| const void * | src, | ||
| char * | dst, | ||
| socklen_t | size | ||
| ) |
Convert the network address in src to a character string in src.
| af | address family, AF_INET or AF_INET6 |
| src | source address in network byte order |
| dst | resulting address string |
| size | max number characters allowed for the result |
Definition at line 1244 of file net_cc32xx/CC32xxSocket.cxx.
| int listen | ( | int | socket, |
| int | backlog | ||
| ) |
Mark a connection-mode socket, specified by the socket argument, as accepting connections.
| socket | the socket file descriptor |
| backlog | provides a hint to the implementation which the implementation shall use to limit the number of outstanding connections in the socket's listen queue |
Definition at line 988 of file net_cc32xx/CC32xxSocket.cxx.
| ssize_t recv | ( | int | socket, |
| void * | buffer, | ||
| size_t | length, | ||
| int | flags | ||
| ) |
Receive a message from a connection-mode or connectionless-mode socket.
| socket | the socket file descriptor |
| buffer | buffer where the message should be stored |
| length | length in bytes of the buffer pointed to by the buffer argument |
| flags | Specifies the type of message reception |
Definition at line 1036 of file net_cc32xx/CC32xxSocket.cxx.
| ssize_t send | ( | int | socket, |
| const void * | buffer, | ||
| size_t | length, | ||
| int | flags | ||
| ) |
Initiate transmission of a message from the specified socket.
| socket | the socket file descriptor |
| buffer | buffer containing the message to send |
| length | length of the message in bytes |
| flags | the type of message transmission |
Definition at line 1049 of file net_cc32xx/CC32xxSocket.cxx.
| int setsockopt | ( | int | socket, |
| int | level, | ||
| int | option_name, | ||
| const void * | option_value, | ||
| socklen_t | option_len | ||
| ) |
Set the socket options.
| socket | the socket file descriptor |
| level | specifies the protocol level at which the option resides |
| option_name | specifies a single option to set |
| option_value | the metadata that belongs to the option_name |
| option_len | the length of the metadata that belongs to the option_name |
Definition at line 1064 of file net_cc32xx/CC32xxSocket.cxx.
| int socket | ( | int | domain, |
| int | type, | ||
| int | protocol | ||
| ) |
Create an unbound socket in a communications domain.
| domain | specifies the communications domain in which a socket is to be created |
| type | specifies the type of socket to be created |
| protocol | specifies a particular protocol to be used with the socket, specifying a protocol of 0 causes socket() to use an unspecified default protocol appropriate for the requested socket type |
Definition at line 960 of file net_cc32xx/CC32xxSocket.cxx.
|
static |
Existing (allocated) sockets.
we would also #define CC32XX_SD_UNUSED -1 and #define CC32XX_SD_RESERVED -2
Definition at line 65 of file net_cc32xx/CC32xxSocket.cxx.
|
static |
Dummy pointer address that can be used as a reserved indicator.
Definition at line 68 of file net_cc32xx/CC32xxSocket.cxx.