Classes | Macros | Functions | Variables
socket.c File Reference

BSD compatible socket interface. More...

#include "bsp/include/nm_bsp.h"
#include "socket/include/socket.h"
#include "driver/source/m2m_hif.h"
#include "socket/source/socket_internal.h"
Include dependency graph for socket.c:

Go to the source code of this file.

Classes

struct  tstrCloseCmd
 
struct  tstrSocket
 

Macros

#define ETHERNET_HEADER_LENGTH   (14)
 
#define ETHERNET_HEADER_OFFSET   (34)
 
#define IP_PACKET_OFFSET   (ETHERNET_HEADER_LENGTH + ETHERNET_HEADER_OFFSET - M2M_HIF_HDR_OFFSET)
 
#define SOCKET_REQUEST(reqID, reqArgs, reqSize, reqPayload, reqPayloadSize, reqPayloadOffset)   hif_send(M2M_REQ_GROUP_IP, reqID, reqArgs, reqSize, reqPayload, reqPayloadSize, reqPayloadOffset)
 
#define SSL_FLAGS_ACTIVE   NBIT0
 
#define SSL_FLAGS_BYPASS_X509   NBIT1
 
#define SSL_FLAGS_CACHE_SESSION   NBIT4
 
#define SSL_FLAGS_CHECK_CERTNAME   NBIT6
 
#define SSL_TX_PACKET_OFFSET   (TCP_TX_PACKET_OFFSET + TLS_RECORD_HEADER_LENGTH)
 
#define TCP_IP_HEADER_LENGTH   (40)
 
#define TCP_TX_PACKET_OFFSET   (IP_PACKET_OFFSET + TCP_IP_HEADER_LENGTH)
 
#define TLS_RECORD_HEADER_LENGTH   (5)
 
#define UDP_IP_HEADER_LENGTH   (28)
 
#define UDP_TX_PACKET_OFFSET   (IP_PACKET_OFFSET + UDP_IP_HEADER_LENGTH)
 

Functions

sint8 accept (SOCKET sock, struct sockaddr *addr, uint8 *addrlen)
 
sint8 bind (SOCKET sock, struct sockaddr *pstrAddr, uint8 u8AddrLen)
 
sint8 close (SOCKET sock)
 
sint8 connect (SOCKET sock, struct sockaddr *pstrAddr, uint8 u8AddrLen)
 
sint8 gethostbyname (uint8 *pcHostName)
 
sint8 getsockopt (SOCKET sock, uint8 u8Level, uint8 u8OptName, const void *pvOptValue, uint8 *pu8OptLen)
 
sint8 listen (SOCKET sock, uint8 backlog)
 
static void m2m_ip_cb (uint8 u8OpCode, uint16 u16BufferSize, uint32 u32Address)
 
sint8 m2m_ping_req (uint32 u32DstIP, uint8 u8TTL, tpfPingCb fpPingCb)
 
uint32 nmi_inet_addr (char *pcIpAddr)
 
sint16 recv (SOCKET sock, void *pvRecvBuf, uint16 u16BufLen, uint32 u32Timeoutmsec)
 
sint16 recvfrom (SOCKET sock, void *pvRecvBuf, uint16 u16BufLen, uint32 u32Timeoutmsec)
 
void registerSocketCallback (tpfAppSocketCb pfAppSocketCb, tpfAppResolveCb pfAppResolveCb)
 
sint16 send (SOCKET sock, void *pvSendBuffer, uint16 u16SendLength, uint16 flags)
 
sint16 sendto (SOCKET sock, void *pvSendBuffer, uint16 u16SendLength, uint16 flags, struct sockaddr *pstrDestAddr, uint8 u8AddrLen)
 
sint8 setsockopt (SOCKET sock, uint8 u8Level, uint8 option_name, const void *option_value, uint16 u16OptionLen)
 
SOCKET socket (uint16 u16Domain, uint8 u8Type, uint8 u8Flags)
 
NMI_API void Socket_ReadSocketData (SOCKET sock, tstrSocketRecvMsg *pstrRecv, uint8 u8SocketMsg, uint32 u32StartAddress, uint16 u16ReadCount)
 
void socketDeinit (void)
 Socket Layer De-initialization. More...
 
void socketInit (void)
 
static sint8 sslSetSockOpt (SOCKET sock, uint8 u8Opt, const void *pvOptVal, uint16 u16OptLen)
 

Variables

volatile tstrSocket gastrSockets [MAX_SOCKET]
 
volatile uint8 gbSocketInit = 0
 
volatile tpfPingCb gfpPingCb
 
volatile tpfAppResolveCb gpfAppResolveCb
 
volatile tpfAppSocketCb gpfAppSocketCb
 
volatile sint8 gsockerrno
 
volatile uint16 gu16BufferSize
 
volatile uint16 gu16SessionID = 0
 
volatile uint8 gu8OpCode
 

Detailed Description

BSD compatible socket interface.

Copyright (c) 2017-2018 Microchip Technology Inc. and its subsidiaries.

Definition in file socket.c.

Macro Definition Documentation

◆ ETHERNET_HEADER_LENGTH

#define ETHERNET_HEADER_LENGTH   (14)

Definition at line 51 of file socket.c.

◆ ETHERNET_HEADER_OFFSET

#define ETHERNET_HEADER_OFFSET   (34)

Definition at line 50 of file socket.c.

◆ IP_PACKET_OFFSET

Definition at line 55 of file socket.c.

◆ SOCKET_REQUEST

#define SOCKET_REQUEST (   reqID,
  reqArgs,
  reqSize,
  reqPayload,
  reqPayloadSize,
  reqPayloadOffset 
)    hif_send(M2M_REQ_GROUP_IP, reqID, reqArgs, reqSize, reqPayload, reqPayloadSize, reqPayloadOffset)

Definition at line 61 of file socket.c.

◆ SSL_FLAGS_ACTIVE

#define SSL_FLAGS_ACTIVE   NBIT0

Definition at line 65 of file socket.c.

◆ SSL_FLAGS_BYPASS_X509

#define SSL_FLAGS_BYPASS_X509   NBIT1

Definition at line 66 of file socket.c.

◆ SSL_FLAGS_CACHE_SESSION

#define SSL_FLAGS_CACHE_SESSION   NBIT4

Definition at line 67 of file socket.c.

◆ SSL_FLAGS_CHECK_CERTNAME

#define SSL_FLAGS_CHECK_CERTNAME   NBIT6

Definition at line 68 of file socket.c.

◆ SSL_TX_PACKET_OFFSET

#define SSL_TX_PACKET_OFFSET   (TCP_TX_PACKET_OFFSET + TLS_RECORD_HEADER_LENGTH)

Definition at line 59 of file socket.c.

◆ TCP_IP_HEADER_LENGTH

#define TCP_IP_HEADER_LENGTH   (40)

Definition at line 52 of file socket.c.

◆ TCP_TX_PACKET_OFFSET

#define TCP_TX_PACKET_OFFSET   (IP_PACKET_OFFSET + TCP_IP_HEADER_LENGTH)

Definition at line 57 of file socket.c.

◆ TLS_RECORD_HEADER_LENGTH

#define TLS_RECORD_HEADER_LENGTH   (5)

Definition at line 49 of file socket.c.

◆ UDP_IP_HEADER_LENGTH

#define UDP_IP_HEADER_LENGTH   (28)

Definition at line 53 of file socket.c.

◆ UDP_TX_PACKET_OFFSET

#define UDP_TX_PACKET_OFFSET   (IP_PACKET_OFFSET + UDP_IP_HEADER_LENGTH)

Definition at line 58 of file socket.c.

Function Documentation

◆ m2m_ip_cb()

static void m2m_ip_cb ( uint8  u8OpCode,
uint16  u16BufferSize,
uint32  u32Address 
)
static

Definition at line 187 of file socket.c.

◆ Socket_ReadSocketData()

NMI_API void Socket_ReadSocketData ( SOCKET  sock,
tstrSocketRecvMsg pstrRecv,
uint8  u8SocketMsg,
uint32  u32StartAddress,
uint16  u16ReadCount 
)

Definition at line 133 of file socket.c.

◆ sslSetSockOpt()

static sint8 sslSetSockOpt ( SOCKET  sock,
uint8  u8Opt,
const void *  pvOptVal,
uint16  u16OptLen 
)
static

Definition at line 1073 of file socket.c.

Variable Documentation

◆ gastrSockets

volatile tstrSocket gastrSockets[MAX_SOCKET]

Definition at line 103 of file socket.c.

◆ gbSocketInit

volatile uint8 gbSocketInit = 0

Definition at line 110 of file socket.c.

◆ gfpPingCb

volatile tpfPingCb gfpPingCb

Definition at line 111 of file socket.c.

◆ gpfAppResolveCb

volatile tpfAppResolveCb gpfAppResolveCb

Definition at line 109 of file socket.c.

◆ gpfAppSocketCb

volatile tpfAppSocketCb gpfAppSocketCb

Definition at line 108 of file socket.c.

◆ gsockerrno

volatile sint8 gsockerrno

Definition at line 102 of file socket.c.

◆ gu16BufferSize

volatile uint16 gu16BufferSize

Definition at line 105 of file socket.c.

◆ gu16SessionID

volatile uint16 gu16SessionID = 0

Definition at line 106 of file socket.c.

◆ gu8OpCode

volatile uint8 gu8OpCode

Definition at line 104 of file socket.c.



inertial_sense_ros
Author(s):
autogenerated on Sat Sep 19 2020 03:19:07