|
Open Model Railroad Network (OpenMRN)
|
Socket implementation for the CC32xx class WiFi devices. More...
#include <CC32xxSocket.hxx>
Public Member Functions | |
| ~CC32xxSocket () | |
| Destructor. | |
| ~CC32xxSocket () | |
| Destructor. | |
Public Member Functions inherited from Device | |
| Device (const char *name) | |
| Constructor. | |
| virtual | ~Device () |
| Destructor. | |
Static Public Member Functions | |
| static int | socket (int domain, int type, int protocol) |
| Create an unbound socket in a communications domain. | |
| static int | bind (int socket, const struct sockaddr *address, socklen_t address_len) |
| Bind a name to a socket. | |
| static int | listen (int socket, int backlog) |
| Mark a connection-mode socket, specified by the socket argument, as accepting connections. | |
| static int | accept (int socket, struct sockaddr *address, socklen_t *address_len) |
| Accept a new connection on a socket. | |
| static int | connect (int socket, const struct sockaddr *address, socklen_t address_len) |
| Connect a socket. | |
| static ssize_t | recv (int socket, void *buffer, size_t length, int flags) |
| Receive a message from a connection-mode or connectionless-mode socket. | |
| static ssize_t | send (int socket, const void *buffer, size_t length, int flags) |
| Initiate transmission of a message from the specified socket. | |
| static int | setsockopt (int socket, int level, int option_name, const void *option_value, socklen_t option_len) |
| Set the socket options. | |
| static int | getsockopt (int socket, int level, int option_name, void *option_value, socklen_t *option_len) |
| Get the socket options. | |
| static int | socket (int domain, int type, int protocol) |
| Create an unbound socket in a communications domain. | |
| static int | bind (int socket, const struct sockaddr *address, socklen_t address_len) |
| Bind a name to a socket. | |
| static int | listen (int socket, int backlog) |
| Mark a connection-mode socket, specified by the socket argument, as accepting connections. | |
| static int | accept (int socket, struct sockaddr *address, socklen_t *address_len) |
| Accept a new connection on a socket. | |
| static int | connect (int socket, const struct sockaddr *address, socklen_t address_len) |
| Connect a socket. | |
| static ssize_t | recv (int socket, void *buffer, size_t length, int flags) |
| Receive a message from a connection-mode or connectionless-mode socket. | |
| static ssize_t | send (int socket, const void *buffer, size_t length, int flags) |
| Initiate transmission of a message from the specified socket. | |
| static int | setsockopt (int socket, int level, int option_name, const void *option_value, socklen_t option_len) |
| Set the socket options. | |
| static int | getsockopt (int socket, int level, int option_name, void *option_value, socklen_t *option_len) |
| Get the socket options. | |
Static Public Member Functions inherited from Device | |
| static int | open (struct _reent *reent, const char *path, int flags, int mode) |
| Open a file or device. | |
| static int | close (struct _reent *reent, int fd) |
| Close a file or device. | |
| static int | stat (struct _reent *reent, const char *path, struct stat *stat) |
| Get the status information of a file or device. | |
| static int | select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, long long timeout) |
| POSIX select(). | |
| static void | select_clear () |
| Clears the current thread's select bits. | |
Static Public Member Functions inherited from FileIO | |
| static ssize_t | read (struct _reent *reent, int fd, void *buf, size_t count) |
| Read from a file or device. | |
| static ssize_t | write (struct _reent *reent, int fd, const void *buf, size_t count) |
| Write to a file or device. | |
| static _off_t | lseek (struct _reent *reent, int fd, _off_t offset, int whence) |
| Change the offset index of a file or device. | |
| static int | fstat (struct _reent *reent, int fd, struct stat *stat) |
| Get the status information of a file or device. | |
| static int | ioctl (int fd, unsigned long int key, unsigned long data) |
| Request and ioctl transaction. | |
| static int | fcntl (int fd, int cmd, unsigned long data) |
| Manipulate a file descriptor. | |
| static bool | is_device (int fd) |
| Test if the file descriptor belongs to a device. | |
Private Member Functions | |
| int | close (File *file) override |
| Close method. | |
| bool | select (File *file, int mode) override |
| Device select method. | |
| int | fcntl (File *file, int cmd, unsigned long data) override |
| Manipulate a file descriptor. | |
| CC32xxSocket () | |
| Constructor. | |
| DISALLOW_COPY_AND_ASSIGN (CC32xxSocket) | |
| int | close (File *file) override |
| Close method. | |
| bool | select (File *file, int mode) override |
| Device select method. | |
| int | fcntl (File *file, int cmd, unsigned long data) override |
| Manipulate a file descriptor. | |
| CC32xxSocket () | |
| Constructor. | |
| DISALLOW_COPY_AND_ASSIGN (CC32xxSocket) | |
Static Private Member Functions | |
| static CC32xxSocket * | get_instance_from_sd (int sd) |
| Get the CC32xxSocket instance given a specific CC32xx socket descriptor. | |
| static CC32xxSocket * | get_instance_from_fd (int fd) |
| Get the CC32xxSocket instance given a file descriptor. | |
| static void | remove_instance_from_sd (int sd) |
| Remove the CC32xxSocket instance from the active CC32xxSocket list. | |
| static int | reserve_socket () |
| Reserve a location in the cc32xxSockets pool. | |
| static CC32xxSocket * | get_instance_from_sd (int sd) |
| Get the CC32xxSocket instance given a specific CC32xx socket descriptor. | |
| static CC32xxSocket * | get_instance_from_fd (int fd) |
| Get the CC32xxSocket instance given a file descriptor. | |
| static void | remove_instance_from_sd (int sd) |
| Remove the CC32xxSocket instance from the active CC32xxSocket list. | |
| static int | reserve_socket () |
| Reserve a location in the cc32xxSockets pool. | |
Private Attributes | |
| int16_t | sd |
| CC32xx socket descriptor. | |
| uint8_t | readActive: 1 |
| indicates our "best guess" at current socket's read active status | |
| uint8_t | writeActive: 1 |
| indicates our "best guess" at current socket's write active status | |
| uint8_t | listenActive: 1 |
| This is a listen socket. | |
Friends | |
| class | CC32xxWiFi |
| allow access to private members from CC32xxWiFi | |
Additional Inherited Members | |
Protected Member Functions inherited from Socket | |
| Socket (const char *name) | |
| Constructor. | |
| ~Socket () | |
| Destructor. | |
| int | ioctl (File *file, unsigned long int key, unsigned long data) override |
| Request an ioctl transaction. | |
| bool | select (File *file, int mode) override |
| Device select method. | |
Protected Member Functions inherited from Node | |
| Node (const char *name) | |
| Constructor. | |
| virtual | ~Node () |
| Destructor. | |
| int | open (File *, const char *, int, int) OVERRIDE |
| Open method. | |
| int | close (File *) OVERRIDE |
| Close method. | |
| virtual int | fstat (File *file, struct stat *stat) override |
| Get the status information of a file or device. | |
Protected Member Functions inherited from FileIO | |
| FileIO (const char *name) | |
| Constructor. | |
| virtual | ~FileIO () |
| Destructor. | |
Static Protected Member Functions inherited from Device | |
| static void | select_insert (SelectInfo *info) |
| Add client to list of clients needing woken. | |
| static void | select_wakeup (SelectInfo *info) |
| Wakeup the list of clients needing woken. | |
| static void | select_wakeup_from_isr (SelectInfo *info, int *woken) |
| Wakeup the list of clients needing woken. | |
Static Protected Member Functions inherited from FileIO | |
| static int | fd_alloc (void) |
| Allocate a free file descriptor. | |
| static void | fd_free (int fd) |
| Free up a file descriptor. | |
| static File * | file_lookup (int fd) |
| Looks up a reference to a File corresponding to a given file descriptor. | |
| static int | fd_lookup (File *file) |
| Looks up a file descriptor corresponding to a given File reference. | |
Protected Attributes inherited from Socket | |
| SelectInfo | selInfoRd |
| select wakeup metadata for read active | |
| SelectInfo | selInfoWr |
| select wakeup metadata for write active | |
Protected Attributes inherited from Node | |
| OSMutex | lock_ |
| protects internal structures. | |
| mode_t | mode_ |
| File open mode, such as O_NONBLOCK. | |
| unsigned int | references_ |
| number of open references | |
Protected Attributes inherited from FileIO | |
| const char * | name |
| device name | |
Static Protected Attributes inherited from FileIO | |
| static const unsigned int | numOpenFiles = 20 |
| static File | files [] |
| File descriptor pool. | |
| static OSMutex | mutex |
| mutual exclusion for fileio | |
Socket implementation for the CC32xx class WiFi devices.
Definition at line 44 of file net_cc3220/CC32xxSocket.hxx.
|
inline |
Destructor.
This is public only so that smart pointers can be used without having to supply a custom destructor.
Definition at line 165 of file net_cc3220/CC32xxSocket.hxx.
|
inlineprivate |
Constructor.
Definition at line 195 of file net_cc3220/CC32xxSocket.hxx.
|
inline |
Destructor.
This is public only so that smart pointers can be used without having to supply a custom destructor.
Definition at line 165 of file net_cc32xx/CC32xxSocket.hxx.
|
inlineprivate |
Constructor.
Definition at line 195 of file net_cc32xx/CC32xxSocket.hxx.
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 282 of file net_cc3220/CC32xxSocket.cxx.
|
static |
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 |
|
static |
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 220 of file net_cc3220/CC32xxSocket.cxx.
|
static |
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 |
|
overrideprivatevirtual |
Close method.
Returns negative errno on failure.
| file | reference to close |
Implements FileIO.
Definition at line 744 of file net_cc3220/CC32xxSocket.cxx.
|
overrideprivatevirtual |
Close method.
Returns negative errno on failure.
| file | reference to close |
Implements FileIO.
|
static |
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 378 of file net_cc3220/CC32xxSocket.cxx.
|
static |
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 |
|
overrideprivatevirtual |
Manipulate a file descriptor.
| file | file reference for this device |
| cmd | operation to perform |
| data | parameter to the cmd operation |
Reimplemented from FileIO.
Definition at line 911 of file net_cc3220/CC32xxSocket.cxx.
|
overrideprivatevirtual |
Manipulate a file descriptor.
| file | file reference for this device |
| cmd | operation to perform |
| data | parameter to the cmd operation |
Reimplemented from FileIO.
|
staticprivate |
Get the CC32xxSocket instance given a file descriptor.
| fd | file descriptor we are looking for |
Definition at line 841 of file net_cc3220/CC32xxSocket.cxx.
|
staticprivate |
Get the CC32xxSocket instance given a file descriptor.
| fd | file descriptor we are looking for |
|
staticprivate |
Get the CC32xxSocket instance given a specific CC32xx socket descriptor.
Should only be called within a critical section.
| sd | socket descriptor we are looking for |
Definition at line 822 of file net_cc3220/CC32xxSocket.cxx.
|
staticprivate |
Get the CC32xxSocket instance given a specific CC32xx socket descriptor.
Should only be called within a critical section.
| sd | socket descriptor we are looking for |
|
static |
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 624 of file net_cc3220/CC32xxSocket.cxx.
|
static |
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 |
|
static |
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 252 of file net_cc3220/CC32xxSocket.cxx.
|
static |
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 |
|
static |
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 435 of file net_cc3220/CC32xxSocket.cxx.
|
static |
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 |
|
staticprivate |
Remove the CC32xxSocket instance from the active CC32xxSocket list.
Should only be called within a critical section.
| sd | socket descriptor we are looking for |
Definition at line 865 of file net_cc3220/CC32xxSocket.cxx.
|
staticprivate |
Remove the CC32xxSocket instance from the active CC32xxSocket list.
Should only be called within a critical section.
| sd | socket descriptor we are looking for |
|
staticprivate |
Reserve a location in the cc32xxSockets pool.
Definition at line 884 of file net_cc3220/CC32xxSocket.cxx.
|
staticprivate |
Reserve a location in the cc32xxSockets pool.
Device select method.
Default impementation returns true.
| file | reference to the file |
| mode | FREAD for read active, FWRITE for write active, 0 for exceptions |
Reimplemented from FileIO.
Definition at line 775 of file net_cc3220/CC32xxSocket.cxx.
|
static |
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 482 of file net_cc3220/CC32xxSocket.cxx.
|
static |
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 |
|
static |
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 535 of file net_cc3220/CC32xxSocket.cxx.
|
static |
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 |
|
static |
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 76 of file net_cc3220/CC32xxSocket.cxx.
|
static |
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 |
|
friend |
allow access to private members from CC32xxWiFi
Definition at line 245 of file net_cc3220/CC32xxSocket.hxx.
|
private |
This is a listen socket.
Definition at line 242 of file net_cc3220/CC32xxSocket.hxx.
|
private |
indicates our "best guess" at current socket's read active status
Definition at line 235 of file net_cc3220/CC32xxSocket.hxx.
|
private |
CC32xx socket descriptor.
Definition at line 231 of file net_cc3220/CC32xxSocket.hxx.
|
private |
indicates our "best guess" at current socket's write active status
Definition at line 239 of file net_cc3220/CC32xxSocket.hxx.