📄 tcpipapi.h
字号:
/****************************************************************************
* (C) 1999-2005 by BECK IPC GmbH
*
* BECK IPC GmbH
* Germany
*
* http://www.beck-ipc.com
*
* ---------------------------------------------------------------------------
* Module : TCPIPAPI.H
* Function : Constants and data structures for access to
* the Socket interface
* ---------------------------------------------------------------------------
$Header: /cvsrepo/CANopenNode/_src/CANopen/BECK_SC1x+SJA1000/Clib/TCPIPAPI.H,v 1.1 2006/03/08 11:29:44 jani Exp $
******************************************************************************/
#ifndef _TCPIP_API_H__
#define _TCPIP_API_H__
/*****************************************************************************/
// Compilation configuration switches for target version
#include "target.h"
/*****************************************************************************
*
* BSD Structure Definitions
*
*****************************************************************************/
struct sockaddr
{
unsigned char sa_len; /* Total Length */
unsigned char sa_family; /* Address Family AF_xxx */
char sa_data[14]; /* up to 14 bytes of protocol specific address */
};
struct in_addr
{
unsigned long s_addr; /* 32bit netis/hostid address in network byte order */
};
// struct sockaddr_in has changed from SC12/SC13 RTOS TCPIP stack to SC123 RTOS TCPIP stack
#ifdef TCPIP_STACK_V2
struct sockaddr_in // For TCP/IP with IPv6 support
{
unsigned char sin_len; //
unsigned char sin_family; // AF_INET
unsigned int sin_port; // 16bit Port Number in network byte order
struct in_addr sin_addr; // 32bit netid/hostid in network byte order
char sin_zero[8]; // unused
};
#else
struct sockaddr_in // For original SC12 TCP/IP stack
{
short sin_family; // AF_INET
unsigned int sin_port; // 16bit Port Number in network byte order
struct in_addr sin_addr; // 32bit netid/hostid in network byte order
char sin_zero[8];// unused
};
#endif // TCPIP_STACK_V2
struct in6_addr
{
//128-bit IPv6-formatted address in network byte order
union
{
unsigned char ip6U8[16];
unsigned short ip6U16[8];
unsigned long ip6U32[4];
}ip6Addr;
};
struct sockaddr_in6
{
unsigned char sin6_len; //Length (in bytes) of the sockaddr_in6 structure
unsigned char sin6_family; //Address family, set to AF_INET6
unsigned short sin6_port; //Transport layer port number
unsigned long sin6_flowinfo; //IPv6 packet header Flow Label
struct in6_addr sin6_addr; //128-bit IPv6-formatted address in network byte order.
unsigned long sin6_scope_id; //sin6_scope_id for local scope (i.e. link-local, site-local)
};
struct sockaddr_storage
{
union
{
struct sockaddr_in6 ipv6;
struct sockaddr_in ipv4;
}addr;
};
/*****************************************************************************/
struct recv_params
{
char far * bufferPtr;
int bufferLength;
int flags; /* Blocking or dontwait */
struct sockaddr far * fromPtr; /* only needed for UDP */
int far * fromlengthPtr; /* only needed for UDP */
unsigned long timeout; /* timeout milliseconds */
};
struct send_params
{
const char far * bufferPtr;
int bufferLength;
int flags; /* Blocking or dontwait */
struct sockaddr far * toPtr; /* only needed for UDP */
int far * tolengthPtr; /* only needed for UDP */
};
/*****************************************************************************/
//Set and get socket options structure
/*****************************************************************************/
typedef struct tag_setsockopt
{
int protocol_level; /* protocol level ip level,tcp level or socket level */
int optionName; /* options name */
const char far * optionValue; /* pointer to the option value */
int optionLength; /* length of option value */
}SetSocketOption;
typedef struct tag_getsockopt
{
int protocol_level; // protocol level ip level,tcp level or socket level
int optionName; // options name
char far * optionValue; // pointer to the option value buffer, where Value
// can be filled in by the API call
int far * optionLength; // length of option value buffer
}GetSocketOption;
/*****************************************************************************/
//Socket information (see API call 0x23
/*****************************************************************************/
typedef struct tag_socketinfo
{
unsigned int socIndex;
unsigned char protocol; /*6:TCP 17 UDP*/
unsigned int localPort;
unsigned long IfIpAddress;
unsigned int remotePort;
unsigned long remoteIP;
unsigned char tcpState;
}SocketInfo;
/*****************************************************************************/
//Socket information (see API call 0x25
/*****************************************************************************/
typedef struct tag_socketinfo_ipv4v6
{
unsigned int socIndex;
unsigned char protocol; /*6:TCP 17 UDP*/
unsigned int localPort;
struct in6_addr IfIpAddress;
unsigned int remotePort;
struct in6_addr remoteIP;
unsigned char tcpState;
}SocketInfoIPv4v6;
typedef struct tagIpUserCallbackInfo
{
int size; // size of this struct
unsigned long srcAddr; // sourde IP Address (in long format, already in correct byte order)
unsigned long destAddr; // destitnation IP Address (in long format, already in correct byte order))
unsigned int srcPort; // sourde Port (already in correct byte order)
unsigned int destPort; // destination Port (already in correct byte order)
unsigned char protocol; // Protocol (see list below)
int fragmented; // 0: it is a unfragmented package, 1: it is a fragment
unsigned int dataLength; // Length of the data in the IP package (only available if package is not fragmented!)
void * dataPtr; // Pointer to the IP data (only available if package is not fragmented!)
void * ipHdrPtr; // Pointer to the IP header
unsigned int ipHdrLen; // length of IP header
} IpCallbackUserInfo;
typedef struct ArpUserCallbackInfo
{
int size; // size of this struct
unsigned int dataLength; // Length of the data in the Arp package
void * dataPtr; // Pointer to the Arp data
}ArpCallbackUserInfo_t;
typedef struct tag_ArpHeader
{
unsigned int arpHardware;
unsigned int arpProtocol;
unsigned char arpHardwareLength;
unsigned char arpProtocolLength;
unsigned int arpOperation;
unsigned char arpSendPhyAddress[6];
unsigned char arpSendNetAddress[4];
unsigned char arpTargetPhyAddress[6];
unsigned char arpTargetNetAddress[4];
}ArpHeader;
/*****************************************************************************/
//PPP server config information structure
/*****************************************************************************/
typedef struct tag_pppipcfg_data
{
char IP[16];
char RemIP[16];
char Netmask[16];
char Gateway[16];
unsigned int comport; /* 0==EXT, 1==COM of the SC12*/
unsigned int auth; /* 0==No auth, 1==PAP authentication, 2:CHAP*/
unsigned int modem; /* 0==Nullmodem, 1==usage of modem*/
unsigned int flow;
long baud;
}PPP_IPCfg_Data;
/*****************************************************************************/
//PPP server IPv6 config information structure
/*****************************************************************************/
typedef struct tag_pppipcfg_data_ipv6
{
char IP[46]; // Auto configured PPP server IP
char RemIP[46]; // Auto configured Remote peer IP
unsigned int comport; // COM port: EXT=0, COM=1
unsigned int auth; // 0: no authentication 1:PAP 2:CHAP
unsigned int modem; // Analog Modem=1, Null Modem cable=0
unsigned int flow; // Flow control
long baud; // BAUD rate
} PPP_IPCfg_Data_IPv6;
/*****************************************************************************/
//PPP client structures
/*****************************************************************************/
#define PPP_MAX_DIAL 7
typedef struct tag_pppdial
{
char far * modemcmd; // modem command string
char far * modemans; // modem answer string
int timeout; // seconds
int retries;
char expect_send;
/*flag:
expect = 0: pppclient sends modemcmd and expects modemanswer
expect = 1: pppclient expects modemanswer and sends modemcmd
*/
}PPPDial;
typedef struct tag_pppclie_hangup
{
char far *modemcmdmode; // switch modem into command mode e.g. +++
int delay; // delay time after switching in seconds
PPPDial pppdial[PPP_MAX_DIAL]; // modem commands and answer for hangups
}PPP_ModemHangup;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -