Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
net_cc3220/CC32xxSocket.hxx
Go to the documentation of this file.
1
34#include "Socket.hxx"
35
36#include <sys/socket.h>
37
38#ifndef _FREERTOS_DRIVERS_NET_CC32XX_CC32XXSOCKET_HXX_
39#define _FREERTOS_DRIVERS_NET_CC32XX_CC32XXSOCKET_HXX_
40
41class CC32xxWiFi;
42
44class CC32xxSocket : public Socket
45{
46public:
59 static int socket(int domain, int type, int protocol);
60
70 static int bind(int socket, const struct sockaddr *address,
71 socklen_t address_len);
72
82 static int listen(int socket, int backlog);
83
98 static int accept(int socket, struct sockaddr *address,
99 socklen_t *address_len);
100
109 static int connect(int socket, const struct sockaddr *address,
110 socklen_t address_len);
111
123 static ssize_t recv(int socket, void *buffer, size_t length, int flags);
124
133 static ssize_t send(int socket, const void *buffer, size_t length,
134 int flags);
135
146 static int setsockopt(int socket, int level, int option_name,
147 const void *option_value, socklen_t option_len);
148
159 static int getsockopt(int socket, int level, int option_name,
160 void *option_value, socklen_t *option_len);
161
166 {
167 }
168
169private:
174 int close(File *file) override;
175
182 bool select(File* file, int mode) override;
183
191 int fcntl(File *file, int cmd, unsigned long data) override;
192
196 : Socket(NULL)
197 , sd(-1)
198 , readActive(true)
199 , writeActive(true)
200 , listenActive(false)
201 {
202 }
203
210
216 static CC32xxSocket *get_instance_from_fd(int fd);
217
222 static void remove_instance_from_sd(int sd);
223
228 static int reserve_socket();
229
231 int16_t sd;
232
235 uint8_t readActive : 1;
236
239 uint8_t writeActive : 1;
240
242 uint8_t listenActive : 1;
243
245 friend class CC32xxWiFi;
246
248};
249
250#endif /* _FREERTOS_DRIVERS_NET_CC32XX_CC32XXSOCKET_HXX_ */
Socket implementation for the CC32xx class WiFi devices.
int16_t sd
CC32xx socket descriptor.
static int reserve_socket()
Reserve a location in the cc32xxSockets pool.
bool select(File *file, int mode) override
Device select method.
static CC32xxSocket * get_instance_from_fd(int fd)
Get the CC32xxSocket instance given a file descriptor.
static int connect(int socket, const struct sockaddr *address, socklen_t address_len)
Connect a socket.
uint8_t readActive
indicates our "best guess" at current socket's read active status
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.
uint8_t listenActive
This is a listen socket.
int fcntl(File *file, int cmd, unsigned long data) override
Manipulate a file descriptor.
static int bind(int socket, const struct sockaddr *address, socklen_t address_len)
Bind a name to a socket.
static CC32xxSocket * get_instance_from_sd(int sd)
Get the CC32xxSocket instance given a specific CC32xx socket descriptor.
static int listen(int socket, int backlog)
Mark a connection-mode socket, specified by the socket argument, as accepting connections.
static void remove_instance_from_sd(int sd)
Remove the CC32xxSocket instance from the active CC32xxSocket list.
static int socket(int domain, int type, int protocol)
Create an unbound socket in a communications domain.
int close(File *file) override
Close method.
static int accept(int socket, struct sockaddr *address, socklen_t *address_len)
Accept a new connection on a socket.
static ssize_t send(int socket, const void *buffer, size_t length, int flags)
Initiate transmission of a message from the specified socket.
uint8_t writeActive
indicates our "best guess" at current socket's write active status
static ssize_t recv(int socket, void *buffer, size_t length, int flags)
Receive a message from a connection-mode or connectionless-mode socket.
Provides the startup and mantainance methods for configuring and using the CC32xx Wi-Fi stack.
Implement a BSD compatible socket device.
Definition Socket.hxx:45
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Removes default copy-constructor and assignment added by C++.
Definition macros.h:171
uint32_t socklen_t
type of sockaddr lenth
Definition socket.h:89
File information.
Definition Devtab.hxx:52
IPv4 socket address.
Definition socket.h:83