Data Structures used in TCP/IP API - SC12 @CHIP-RTOS V1.10
IPC@CHIP Documentation Index
Data Structures
Here are the BSD structures and other data types used by the
TCP/IP API.
All constants and data structures are defined in the TCPIPAPI.H header file.
Notes:
- Byte alignment is required
within all data structures used within the API.
- The phrase "network byte order" means big endian (like Motorola machines, unlike Intel).
Contents
:
ArpHeader
- Address Resolution Protocol
(ARP) packet header has following form.
| 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; |
Related Topics
-
- API function ARP_USER_CB - Install ARP callback function
Top of list Index page
ArpRouteCacheEntry
| typedef struct tagArpRouteCacheEntry
{
unsigned int ifIndex; // Interface index for this entry
unsigned long flags; // Type/state of entry (see below)
unsigned long arpIpAddress; // Device IP address or network address
unsigned long mask; // Ip network mask for cloned ARP entries
long arpTtl; // TimeToLive in milliseconds
long hops; // Number of routers between this host and route
union
{
struct
{
// Device IP address for Local routing entry
unsigned long DevIpAddress;
} LocalNetRouteEntry;
struct
{
// Device Ethernet address for ARP entry
unsigned char MacAddress[6];
unsigned char filler[2];
} ArpEntry;
struct
{
unsigned long GatewayIpAddress; // Indirect route
} GatewayEntry;
} ArpRouteGwayUnion;
} ArpRouteCacheEntry; |
Comments
- flags
This bit field is defined as follows:
Note: Bit 2, 3, and 4 select the view of the ArpRouteGwayUnion union.
Bit 2: Indirect route (GatewayEntry structure)
Bit 3: Valid ARP entry (ArpEntry structure)
Bit 4: Local route (LocalNetRouteEntry structure)
Bit 5: Static route
Bit 10, 11: Cloned ARP entry (e.g. ARP entry for default gateway)
Bit 16: Route is up
Bit 17: arpIpAddress entry is a host address, 0: network address
Related Topics
-
- API function GET_ARPROUTE_CACHE - Read internal ARP/Route cache table
Top of list Index page
ArpUserCallbackInfo
- A structure of this type is passed as an input parameter to an ARP
user callback handler.
| typedef struct ArpUserCallbackInfo
{
int size; // Size of this structure
unsigned int dataLength; // Length of the data in the ARP package
void far * dataPtr; // Pointer to the ARP data
} ArpCallbackUserInfo_t; |
Related Topics
-
- ArpHeader data structure
-
- API function ARP_USER_CB - Install ARP callback function
Top of list Index page
atEntry
| typedef struct tagAtEntry {
long IfIndex; // Interface on which this entry maps
unsigned char PhysAddress[11]; // Physical address of destination
unsigned char PhysAddressLen; // Length of PhysAddress
unsigned long NetAddress; // IP address of physical address
} atEntry; |
Comments
- These structures are only available in @CHIP-RTOS versions which contain the
SNMP option. A SNMP agent is not part of the @CHIP-RTOS. But if a user is able to implement
an agent based on the TCP/IP API, they need access to the internal TCP/IP SNMP variables.
Related Topics
-
- API function API_SNMP_GET - Get internal TCP/IP SNMP variables
Top of list Index page
DevUserBuffer
- This buffer handle private type is used internally by the TCP/IP stack.
| typedef void far * DevUserBuffer; // Device buffer handle type |
Top of list Index page
DevUserBufferHandle
- This type references a buffer handle private type used internally
by the TCP/IP stack.
| typedef DevUserBuffer far * DevUserBufferHandle; // Pointer to a device buffer handle |
Related Topics
-
- DevUserBuffer type - Device buffer handle (private)
-
- API function DEV_GET_BUF -
Get a buffer from TCP/IP stack
Top of list Index page
DevUserDriver
| typedef struct tag_DevUserDriver
{
int DevIndex; // Internal device index, filled by @CHIP-RTOS
char far * DevName; // Unique device name, max. 13 chars + 0
unsigned long IpAddr; // IP address
unsigned long Netmask; // Netmask
DevUserIfaceHandle IfaceHandle; // handle to identify the interface internal
DevUserLinkLayer LinkLayerHandle; // handle to identify the link layer internal
unsigned char iface_type, // Type of the device driver:
// 0: unknown user specific device,
// 1: device is an Ethernet controller,
// 2: use PPP protocol as a server
// (currently not supported).
// 3: use PPP protocol as a client
// (currently not supported).
// 4: use SLIP protocol (currently not supported)
unsigned char use_dhcp; // Boolean, set to 1 if you want to use
// DHCP server IP configuration.
UserEthDhcp_Entry far * Dhcp_Data; // Pointer to DHCP data set by
// DEV_WAIT_DHCP_COMPLETE API
// (only applies if use_dhcp=1
// and iface_type=1 =Ethernet).
//
void far * Reserved1; // reserved for future extensions
void far * Reserved2;
void far * Reserved3;
// Set of driver functions which user implements:
void far * DevOpen; // Driver Open/initialize function,
// optional (pass a Null pointer if not used).
void far * DevClose; // Driver Close function,
// optional (pass a Null pointer if not used).
void far * DevSend; // Driver send function
void far * DevRecv; // Driver recv function
void far * DevGetPhysAddr; // Ethernet driver only, returns MAC address,
// else pass a Null pointer.
void far * DevFreeRecv; // Free own allocated buffer,
// optional (pass a Null pointer if not used).
void far * DevIoctl; // Currently not supported, pass a Null pointer.
int far * ErrorCode; // Contains error code, if driver install
// (API call 0xAC 0xA0) failed.
void far * Reserved4; // reserved for future extensions
void far * Reserved5;
void far * Reserved6;
} DevUserDriver; |
Comments
- This is the main structure which is needed for installing your own device drivers/interfaces
for the TCP/IP stack of the @CHIP-RTOS.
Related Topics
-
- API function DEV_OPEN_IFACE -
Open/install a user TCP/IP device driver/interface
-
- DevUserIfaceHandle type - IfaceHandle structure member
-
- DevUserLinkLayer type - LinkLayerHandle structure member
-
- UserEthDhcp_Entry type - Dhcp_Data structure member
Top of list Index page
DevUserIfaceHandle
- A handle of this type is returned in the IfaceHandle member of
the DevUserDriver structure
used in the DEV_OPEN_IFACE API.
| typedef void far * DevUserIfaceHandle; // handle type, to identify a user interface |
Comments
- The data referenced by this handle is private and internal to the @CHIP-RTOS TCP/IP stack.
Related Topics
-
- API function DEV_OPEN_IFACE -
Open/install a user TCP/IP device driver/interface
Top of list Index page
DevUserLinkLayer
| typedef void far * DevUserLinkLayer; // handle type to identify link layer,
// (needed for internal use) |
Top of list Index page
GetSocketOption
- This data structure and specified constants are defined in the TCPIPAPI.H library header file.
| typedef struct tag_getsockopt
{
int protocol_level; // Protocol level: IP level, TCP level or socket level
int optionName; // Option's name
char far *optionValue; // Pointer to the option value buffer (type varies)
int far *optionLength; // Length of option value buffer
} GetSocketOption;
// protocol levels
#define IP_PROTOIP_LEVEL 0
#define IP_PROTOTCP_LEVEL 6
#define SOCKET_LEVEL 0x7fff
// Remaining constants apply to the .optionName field
// IP level options
#define IPO_TTL 0x0001
#define IPO_TOS 0x0002
// TCP level options
#define TCP_NODELAY 0x0001
#define TCP_NOPUSH 0x0004
#define TCP_SLOW_START 0x0200
#define TCP_KEEPALIVE 0x4001
#define TCP_DELAY_ACK 0x4002
#define TCP_KEEPALIVE_INTV 0x4004
#define TCP_KEEPALIVE_CNT 0x4005
#define TCP_FINWT2TIME 0x4006
#define TCP_2MSLTIME 0x4007
#define TCP_MAXRT 0x0010
#define TCP_MAXREXMIT 0x4003
// Socket level options
#define SO_REUSEADDR 0x0004
#define SO_KEEPALIVE 0x0008
#define SO_SNDBUF 0x1001
#define SO_RCVBUF 0x1002 |
Comments
- The type of data found at the location referenced by the optionValue member
pointer varies depending on the particular socket option that is being dealt with.
When manipulating socket options, the protocol_level at which the option resides and the
name of the option (optionName member) must be specified.
The size of the buffer (in bytes) pointed to by the optionValue
member depends on the option, and this size must be specified in the
optionLength field.
These sizes are stated in the list of options below.
The API uses the optionValue and optionLength members
to report option values.
The following list specifies the three different protocol levels and their valid socket options,
including a short description and the length of the option value.
Protocol level and optionName constants referred to here are defined in
TCPIPAPI.H header file.
protocol_level=IP_PROTOIP_LEVEL
(IP level options)
- optionName=IPO_TOS: Size: 8 bit, sizeof (char) - Set IP type of service, default 0
- optionName=IPO_TTL: Size: 8 bit, sizeof (char) -
Set IP time-to-live router hops, default 64
protocol_level=IP_PROTOTCP_LEVEL
(TCP level options)
- optionName=TCP_NODELAY: Size: 16 bit , sizeof (int) -
1: Disable nagle algorithm, default is 0: nagle algorithm is enabled
- optionName=TCP_NOPUSH: Size: 16 bit , sizeof (int) -
1: Force TCP to delay sending any TCP data until a full sized segment is buffered
in the TCP buffers (useful if continuous large amount of data is sent as with FTP) default is 0
- optionName=TCP_SLOW_START: Size: 16 bit, sizeof (int) -
1: Enable the TCP slow start algorithm (default), 0: disabled
- optionName=TCP_KEEPALIVE: Size: 16 bit, sizeof (int) -
Set idle time seconds before sending keep alive probes.
Default 7200 seconds, minimum 10 seconds, maximum 32767 seconds
Notes:
- The socket level option SO_KEEPALIVE (see below) must be enabled.
- The minimum value was changed in @CHIP-RTOS 070 to 10 seconds (was 7200 seconds in @CHIP-RTOS 069).
- optionName=TCP_DELAY_ACK: Size: 16 bit -
Set the TCP delay ACK time in milliseconds.
Default: 200 milliseconds, minimum 0 ms, maximum 65535 ms
- optionName=TCP_FINWT2TIME: Size: 16 bit -
Set the maximum amount of time TCP will wait for the remote side to close.
Default 600 seconds, minimum 0 seconds, maximum 32767 seconds
- optionName=TCP_2MSLTIME: Size: 16 bit -
Set the maximum amount of time TCP will wait in the TIME WAIT state,
once it has initiated a close. Default 2 seconds, minimum 0 seconds, maximum 32767 seconds
- optionName=TCP_MAXRT: Size: 16 bit -
Set the TCP/IP timeout in seconds (0=System Default [75 Seconds], -1 = endless).
Default 0, minimum 0, maximum 32767 seconds
- optionName=TCP_MAXREXMIT: Size: 16 bit -
Set the maximum number of TCP/IP send retries. Default 12, minimum 0, maximum 32767
- optionName=TCP_KEEPALIVE_INTV: Size: 16 bit - Set keep alive interval probes.
Default 75 seconds, minimum 1 second, maximum 600 seconds
Note:
This value can not be changed after a connection is established.
Also the socket must not be in listen mode.
- optionName=TCP_KEEPALIVE_CNT: Size: 16 bit - Set maximum number of keep alive
probes before TCP gives up and closes the connection. Default: 8, minimum 0, maximum 32767
protocol_level=SOCKET_LEVEL
- optionName=SO_REUSEADDR: Size: 16 bit - Enable/disable local address reuse,
coding: 1=enable, 0=disable default: enable
- optionName=SO_KEEPALIVE: Size: 16 bit - Keep connections alive,
coding: 1=enable, 0=disable default: disable
- optionName=SO_SNDBUF: Size: 32 bits, sizeof(long) -
Socket send buffer size. Default TCP 4096, UDP 2048 bytes.
(We recommend a maximum size of 8192 Bytes.)
- optionName=SO_RCVBUF: Size: 32 bits, sizeof(long) -
Socket input buffer size. Default TCP 4096, UDP 2048 bytes.
(We recommend at maximum size of 8192 Bytes.)
Related Topics
-
- API function API_GETSOCKOPT - Get socket options
-
- SetSocketOption structure typedef
Top of list Index page
IcmpMib
| typedef struct tagIcmpMib
{
unsigned long icmpInMsgs; // Total of ICMP msgs received
unsigned long icmpInErrors; // Total of ICMP msgs received with errors
unsigned long icmpInDestUnreachs;
unsigned long icmpInTimeExcds;
unsigned long icmpInParmProbs;
unsigned long icmpInSrcQuenchs;
unsigned long icmpInRedirects;
unsigned long icmpInEchos;
unsigned long icmpInEchoReps;
unsigned long icmpInTimestamps;
unsigned long icmpInTimestampReps;
unsigned long icmpInAddrMasks;
unsigned long icmpInAddrMaskReps;
unsigned long icmpOutMsgs;
unsigned long icmpOutErrors;
unsigned long icmpOutDestUnreachs;
unsigned long icmpOutTimeExcds;
unsigned long icmpOutParmProbs;
unsigned long icmpOutSrcQuenchs;
unsigned long icmpOutRedirects;
unsigned long icmpOutEchos;
unsigned long icmpOutEchoReps;
unsigned long icmpOutTimestamps;
unsigned long icmpOutTimestampReps;
unsigned long icmpOutAddrMasks;
unsigned long icmpOutAddrMaskReps;
} IcmpMib; |
Comments
- These structures are only available in @CHIP-RTOS versions which contain the
SNMP option. A SNMP agent is not part of the @CHIP-RTOS. But if a user is
able to implement an agent based on the TCP/IP API, they will need access to
these internal TCP/IP variables.
Related Topics
-
- API function API_SNMP_GET - Get internal TCP/IP SNMP variables
Top of list Index page
Iface_Entry
| typedef struct tag_iface_device
{
unsigned int devIndex; // Internal index number
char devName[14]; // Device name, terminated by zero
unsigned long devIPAddr; // IP address for this interface
unsigned long devNetmask; // Netmask for the route
unsigned long devDestIpAddr; // Remote peer address for PPP
unsigned char PhysAddr[6]; // Physical device address, max. 6 Bytes
int devType; // Type of the device driver:
// 0: unknown,
// 1: Ethernet driver,
// 2: PPP protocol
// 4: SLIP protocol (not supported)
// 5: Internal loopback
int devDHCP; // Interface configured by DHCP? 1:0
int devFlag; // Device status flag
// Bit1 == 1 Device opened
// Bit2 == 1 Device IP config in progress(PPP or DHCP)
// Bit3 == 1 Device open completed
int devMTU; // Max. Transfer Unit
void far * reserved;
} Iface_Entry; |
Related Topics
-
- API function GET_IFACE_ENTRIES - Read table of TCP/IP device interfaces
Top of list Index page
IfMib
| typedef struct tagIfMib // Interface table data
{
long ifIndex; // index of this interface
char ifDescr[32]; // description of interface
long ifType; // network device type
long ifMtu; // maximum transfer unit
unsigned long ifSpeed; // bandwidth in bits/sec
unsigned char ifPhysAddress[11]; // interface's address
unsigned char PhysAddrLen; // length of physAddr: 6
long ifAdminStatus; // desired state of interface, not supported
long ifOperStatus; // current operational status, not supported
//counters
unsigned long devLastChange; // value of sysUpTime when current state entered
unsigned long devInOctets; // number of octets received on interface
unsigned long devInUcastPkts; // number of unicast packets delivered
unsigned long devInMulticastPkts; // number of multicast packets delivered,
// not supported.
unsigned long devInBroadcastPkts; // broadcasts delivered
unsigned long devInDiscards; // number of broadcasts
unsigned long devInErrors; // number of packets containing errors
unsigned long devInUnknownProtos; // number of packets with unknown protocol
unsigned long devOutOctets; // number of octets transmitted
unsigned long devOutUcastPkts; // number of unicast packets sent
unsigned long devOutMulticastPkts;// number of multicast packets sent
unsigned long devOutBroadcastPkts;// broadcasts sent
unsigned long devOutDiscards; // number of packets discarded with no error
unsigned long devOutErrors; // number of pkts discarded with an error
unsigned long devOutQLen; // number of packets in output queue
unsigned long devSpecific;
} IfMib; |
Comments
- These structures are only available in @CHIP-RTOS versions which contain the
SNMP option. A SNMP agent is not part of the @CHIP-RTOS. But if a user is able to implement
an agent based on the TCP/IP API, they need access to the internal TCP/IP SNMP variables.
The SNMP MIB variables are not a part of our current official 6 @CHIP-RTOS versions.
It's necessary to order directly a @CHIP-RTOS version which includes this feature.
Related Topics
-
- API function API_SNMP_GET - Get internal TCP/IP SNMP variables
Top of list Index page
in_addr
| struct in_addr
{
u_long s_addr; // 32 bit netid/hostid address in network byte order
}; |
Related Topics
-
- sockaddr_in data structure
Top of list Index page
IpMib
| typedef struct tagIpMib
{
long ipForwarding; // 1
long ipDefaultTTL; // default TTL for pkts originating here
unsigned long ipInReceives; // no. of IP packets received from interfaces
unsigned long ipInHdrErrors; // number of pkts discarded due to header errors
unsigned long ipInAddrErrors; // no. of pkts discarded due to bad address
unsigned long ipForwDatagrams; // number pf pkts forwarded through this entity
unsigned long ipInUnknownProtos; // no. of local-addressed pkts w/unknown proto
unsigned long ipInDiscards; // number of error-free packets discarded
unsigned long ipInDelivers; // number of datagrams delivered to upper level
unsigned long ipOutRequests; // number of IP datagrams originating locally
unsigned long ipOutDiscards; // number of error-free output IP pkts discarded
unsigned long ipOutNoRoutes; // number of IP pkts discarded due to no route
long ipReasmTimeout; // seconds fragment is held awaiting reassembly
unsigned long ipReasmReqds; // no. of fragments needing reassembly (here)
unsigned long ipReasmOKs; // number of fragments reassembled
unsigned long ipReasmFails; // number of failures in IP reassembly
unsigned long ipFragOKs; // number of datagrams fragmented here
unsigned long ipFragFails; // no. pkts unable to be fragmented here
unsigned long ipFragCreates; // number of IP fragments created here
unsigned long ipRoutingDiscards;
} IpMib; |
Comments
- These structures are only available in @CHIP-RTOS versions which contain the
SNMP option. A SNMP agent is not part of the @CHIP-RTOS. But if a user is able to implement
an agent based on the TCP/IP API, they need access to these internal TCP/IP variables.
Related Topics
-
- API function API_SNMP_GET - Get internal TCP/IP SNMP variables
Top of list Index page
IpUserCallbackInfo
- A structure of this type is passed as an input parameter to an IP user callback handler.
| struct IpUserCallbackInfo
{
int size; // Size of this struct
unsigned long srcAddr; // Source IP Address (in network byte order)
unsigned long destAddr; // Destination IP Address (in network byte order))
unsigned int srcPort; // Source Port (in network byte order)
unsigned int destPort; // Destination Port (in network byte order)
unsigned char protocol; // Protocol (see list below)
int fragmented; // 0: it is an 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 far * dataPtr; // Pointer to the IP data
// (only available if package is not fragmented!)
} IpCallbackUserInfo_t; |
Comments
- Protocol types enumerated by the protocol member are coded as follows:
1 ICMP (Internet Control Management Protocol
)
2 IGMP (Internet Group Management Protocol
)
6 TCP (Transmission Control Protocol
)
17 UDP (User Datagram Protocol
)
Note: The IP callback function will be called before defragmenting fragmented
IP packages. So if we receive a fragmented package, the IP callback will be
called for every received fragment.
Related Topics
-
- API function IP_USER_CB - Install IP callback function
Top of list Index page
Packet_Count
| typedef struct tag_cnt_packet
{
unsigned int far * cnt_all_packets; // count all incoming Ethernet packets
unsigned int far * cnt_ip_packets; // count incoming IP packets
unsigned int far * cnt_arp_packets; // count incoming ARP packets
unsigned int far * cnt_tcp_packets; // count incoming TCP packets
unsigned int far * cnt_udp_packets; // count incoming UDP packets
unsigned int far * cnt_icmp_packets; // count incoming ICMP packets
unsigned int far * cnt_all_sended_packets; // count all sent Ethernet packets
unsigned int far * cnt_ip_sended_packets; // count all sent IP packets
unsigned int far * cnt_arp_sended_packets; // count all sent ARP packets
unsigned int far * cnt_tcp_sended_packets; // count all sent TCP packets
unsigned int far * cnt_udp_sended_packets; // count all sent UDP packets
unsigned int far * cnt_icmp_sended_packets; // count all sent ICMP packets
unsigned int far * cnt_ip_chksum_errs; // checksum errors on incoming IP packets
unsigned int far * cnt_udp_chksum_errs; // checksum errors on incoming UDP packets
unsigned int far * cnt_tcp_chksum_errs; // checksum errors on incoming TCP packets
unsigned int far * cnt_eth_errs; // errors on incoming Ethernet packets
} Packet_Count; |
Comments
- The counters count_all_packets and count_all_sended_packets count only
Ethernet packets.
Other counters also count the packets from and to other devices e.g. local loopback packets
and PPP packets.
Related Topics
-
- API function TCPIP_STATISTICS - Access packet counts.
Top of list Index page
PasCallBack
| typedef struct tag_PasCallBack
{
int sd; // socket descriptor
int event; // occurred event
} PasCallBack; |
Comments
- The pointer to this structure will be passed to a Pascal callback function in the
registers ES:DI. You can read out the information about the socket and the event
which has triggered the callback function.
Related Topics
-
- To register a Pascal callback function see API_REGISTER_CALLBACK_PASCAL
Top of list Index page
Ping
| typedef struct tag_ping_command
{
int sd; // Socket descriptor, set by PING_OPEN
// User must set following four values prior to PING_OPEN API call
char far *remoteHostNamePtr; // Remote IP
int pingInterval; // seconds
int pingDataLength; // Maximum 1024 bytes
unsigned long count; // Limit number of pings sent. Set to
// zero if ping should run forever (until PING_CLOSE)
unsigned char pingstate; // ping socket state, 1: open 0: closed
// Statistics, filled in by system inside PING_STATISTICS API:
unsigned long transmitted; // Sent ping requests count
unsigned long received; // Received replies count
unsigned int lastsenderr; // Last send error
unsigned int lastrcverr; // Last receive error
unsigned long maxRtt; // Maximum round trip time (ms), rounded off to 100 ms step
unsigned long minRtt; // Minimum round trip time (ms), (100 ms steps)
unsigned long lastRtt; // Round trip time (100 ms steps) of
// the last ping request/reply.
} Ping; |
Comments
- Caller to PING_OPEN API must initialize structure members:
remoteHostNamePtr ... who to "ping"
pingInterval ... block repetition rate in seconds
pingDataLength ... size of ping data blocks
count ... set to zero, if ping should run forever
The remainder of the data structure is managed within the API functions.
Related Topics
-
- API function PING_OPEN - Start ICMP echo requests
Top of list Index page
PPPClient_Init
| typedef struct tag_ppp_client
{
int port; // serial port (0:EXT 1:COM)
int auth; // 0: no authentication
// 1:PAP Client must send user name and password
// for PAP authentication to the peer
// 2:CHAP Client must send user name and password
// for CHAP authentication to the peer
// 3:PAP Client expects PAP user name and password
// from the peer
// 4:CHAP Client expects CHAP user name and password
// from the peer
int modem; // modem usage (0:nullmodem 1:modem)
int flow; // serial flow control (0: none, 1:XON/XOFF, 2:RTS/CTS)
long baud; // Serial port BAUD rate
unsigned long idletimeout; // Closing PPP after idle time seconds
// (0: no closing after idle time)
char username[50]; // Used if .auth != 0
char password[50]; // Used if .auth != 0
void far * dptr; // dummy ptr
char PPPClieipAddrStr[16]; // If IP is set to "0.0.0.0" client expect IP from
// the peer, IP is filled in after successful connection
// If IP is set to a string != "0.0.0.0" client
// wants to use this IP during the ppp session
char PPPClieRemipAddrStr[16]; // If RemoteIP is set to "0.0.0.0" client allow
// the peer to use its own IP during the PPP session,
// the RemoteIP is filled in after successful connection
// If RemoteIP is set to a string != "0.0.0.0"
// client wants to configure the remote peer with this IP
char PPPClienetMaskStr[16]; // subnet mask
char PPPClieipGatewayStr[16]; // gateway
PPPDial pppdial[PPP_MAX_DIAL]; // modem/dial entries
PPP_ModemHangup modem_hangup; // modem hang-up commands
int break_modem; // Flag for breaking SC12 - modem
// control communication (dialing, waiting for connect)
// Setting break_modem to 1 breaks current modem control communication
// between IPC@CHIP and the modem at a PPP client open or close call.
// The PPP client reads this flag and breaks the dialing, if flag is set.
// This flag can be set from another task. It will not break an established
// PPP link! Don't forget to clear this flag to zero after breaking.
} PPPClient_Init; |
Comments
- The PPPClient_Init structure is used to open a PPP client session.
The flow control mode XON/XOFF applied to PPP has not been tested. It is not advisable to use it.
Since @CHIP-RTOS 1.02B XON/XOFF mode is also available if the DMA
receive mode for the selected serial port is enabled, but due to the internal functionality of DMA it is not
possible to immediately detect an XON or XOFF from the peer. Therefore it is possible that
an overrun situation can occur at the connected peer (e.g. GSM modem).
We now offer this mode because GSM modems (any??) support only XON/XOFF flow control.
The PPPClient_Init structure contains an array of the PPPdial
structures used for initializing and dialing a modem.
These modem commands will be executed at the start of establishing a connection to a PPP server.
The PPPClient_Init structure also contains a PPP_ModemHangup
structures for closing the modem connection.
For how to initialize and use these structures see the PPPCLIE.C example.
Related Topics
-
- API function PPPCLIENT_OPEN - Open PPP client session.
-
- PPPdial dial-up command data
Top of list Index page
PPPDial
| typedef struct tag_pppdial_init
{
char far * modemcmd; // modem command string
char far * modemans; // modem answer string (max. 80 characters + '\0')
int timeout; // seconds, 0 = no time out
int retries; // Maximum number of dial attempts.
char expect_send; // = 0: PPP client sends modem AT command
// and expects modem answer (e.g. OK).
// = 1: PPP client expects modem answer
// (e.g. CONNECT) and sends modem command.
} PPPDial; |
Comments
- The PPPDial structure is used during PPP client dial-up.
Related Topics
-
- API function PPPCLIENT_OPEN - Open PPP client session
-
- PPPClient_Init PPP client open data structure
Top of list Index page
PPP_IPCfg_Data
| typedef struct tag_pppipcfg_data
{
char IP[16]; // PPP server IP
char RemIP[16]; // Remote IP (given to the client, if connected)
char Netmask[16]; // Subnet mask
char Gateway[16]; // Gateway
unsigned int comport; // COM port: EXT=0, COM=1
unsigned int papauth; // 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; |
Comments
- The PPP_IPCfg_Data structure is used to read out the configuration of the PPP server.
Related Topics
-
- API function PPPSERVER_GET_CFG - Get PPP server configuration
Top of list Index page
PPP_ModemHangup
| typedef struct tag_pppclie_hangup
{
char far *modemcmdmode; // string for switching modem into command mode e.g. +++
int delay; // delay time after switching in seconds
PPPDial pppdial[PPP_MAX_DIAL]; // modem commands and answer for hang-up procedure
}PPP_ModemHangup; |
Comments
- The PPP_ModemHangup structure is used when closing a PPP modem connection.
Related Topics
-
- API function PPPCLIENT_OPEN - Open PPP client session
-
- PPPClient_Init PPP client open data structure
Top of list Index page
PPP_Option
- This data structure and associated constants are defined in TCPIPAPI.H header
file. It is used to control PPP options for both the PPP server and client.
| typedef struct tag_ppp_option
{
int protocolLevel; // PPP_LCP_PROTOCOL or PPP_IPCP_PROTOCOL
int remoteLocalFlag; // PPP_OPTION_WANT or PPP_OPTION_ALLOW
int optionName; // From constants defined below
const char far *optionValuePtr; // To buffer provided by user
int optionLength; // Number of bytes at *optionValuePtr
} PPP_Option;
// PPP Protocol levels
#define PPP_LCP_PROTOCOL 0x21c0
#define PPP_IPCP_PROTOCOL 0x2180
// For .remoteLocalFlag
#define PPP_OPTION_WANT 0
#define PPP_OPTION_ALLOW 1
// Protocol options for .optionName field
// LCP protocol
#define PPP_LCP_ACCM 2
#define PPP_LCP_PROTO_COMP 7
#define PPP_LCP_ADDRCTRL_COMP 8
// IPCP protocol
#define PPP_IPCP_COMP_PROTOCOL 2
#define PPP_IPCP_DNS_PRI 29
#define PPP_IPCP_DNS_SEC 31 |
Comments
- The type of data found at the location referenced by the optionValue member varies
depending on the particular PPP option that is being dealt with.
When manipulating socket options, the protocol_level at which the option resides and the
name of the option (optionName member) must be specified.
The size of the buffer required pointed to by the optionValue member
depends on the option. These sizes (in bytes) are stated at the descriptions list
below. The parameters optionValue and optionLength
are used to access option values.
The structure member remoteLocalFlag can have two possible values:
PPP_OPTION_WANT or PPP_OPTION_ALLOW.
With remoteLocalFlag set to PPP_OPTION_WANT, the IPC@CHIP sends a PPP configuration
request to the connected peer which contains the specified option.
With remoteLocalFlag set to PPP_OPTION_ALLOW, the IPC@CHIP
accepts an incoming PPP configuration request from the connected peer for
the specified option.
The following list specifies the PPP options for the two different protocol levels,
including a short description and the length of the option needed for
setting the optionLength member. Protocol level and
optionName constants referred to here are defined in TCPIPAPI.H
protocolLevel=PPP_LCP_PROTOCOL
(Link Control Protocol
level options)
- optionName=PPP_LCP_ADDRCONTROL_COMP: Size: 8 bit, sizeof(char) -
Activate/Deactivate address control compression, default 0: Deactivated
- optionName=PPP_LCP_PROTO_COMP: Size: 8 bit, sizeof(char) -
Value 1: Protocol field compression, default 0: No compression
- optionName=PPP_LCP_ACCM: Size: 32 bit, sizeof(long) -
Set Async control character map. Each bit position of the unsigned long value represents the
corresponding character which should be escaped or not during PPP session.
protocolLevel=PPP_IPCP_PROTOCOL
(IpCp level options)
- optionName=PPP_IPCP_COMP_PROTOCOL: Size: 16 bit, sizeof(int) -
Value 1: VJ TCP/IP header compression, default 0: No compression
- optionName=PPP_IPCP_DNS_PRI: Size: 32 bit, sizeof(long) -
Specifies the IP addresses of the primary DNS server we will allow the
remote to use or the primary DNS server we want to use. If this option is called
with the value 0 and remotelocalflag==PPP_OPTION_WANT,
then we allow the connected peer to report their primary DNS server IP.
- optionName=PPP_IPCP_DNS_SEC: Size: 32 bit, sizeof(long) -
Specifies the IP addresses of the secondary DNS server we will allow the
remote to use or the secondary DNS server we want to use. If this option
is called with the value 0 and remotelocalflag==PPP_OPTION_WANT,
then we allow the connected peer to report their primary DNS server IP.
Related Topics
-
- API function PPPCLIENT_SET_OPTIONS - Set PPP client options
-
- API function PPPSERVER_SET_OPTIONS - Set PPP server options
-
- API function PPPCLIENT_GET_DNSIP - Get DNS IP
Developer Notes If the option PPP_IPCP_PROTOCOL (VJ TCP/IP header compression) is set, it can be possible that the FTP server of
the IPC@CHIP is not usable via the PPP interface.
Top of list Index page
recv_params
| struct recv_params
{
char far *bufferPtr; // Store incoming data here
int bufferLength; // Maximum bytes to store
int flags; // Blocking, timeout or no wait
struct sockaddr far *fromPtr; // Only needed for UDP.
int far *fromlengthPtr; // Only needed for UDP.
unsigned long timeout; // timeout milliseconds
}; |
Comments
- This structure is defined in tcpip.h.
bufferPtr
This output parameter specifies the user buffer into which the
received data will be placed by the system.
bufferLength
Size of user buffer at bufferPtr, places upper limit
on bytes transferred.
flags
Set to one of following constants defined in tcpip.h:
MSG_BLOCKING: Sleep until data comes in
MSG_TIMEOUT : The caller wakes up after timeout or
if data comes in. The structure member timeout must be set.
MSG_DONTWAIT: Return immediately
fromPtr
UDP only
This is an output parameter.
The referenced sockaddr
structure
is cast to a sockaddr_in
structure prior to usage.
This field will be set by the system inside the
API_RECVFROM call to indicate
the origin of the received UDP data.
fromlengthPtr
UDP only
The 16 bit value referenced by this pointer is both an input
and output parameter, which should be preset to:
sizeof(struct sockaddr_in)
prior to calling API_RECVFROM.
timeout
If flags is set to MSG_TIMEOUT, then
the maximum number of milliseconds to wait should be specified here.
Top of list Index page
Route_Entry
| typedef struct tag_route_entry{
unsigned long destIPAddress; // The IP address to add the route for
unsigned long destNetmask; // The netmask for the route
unsigned long gateway; // IP address of the gateway of the route
int hops; // Number or routers between this host and route
} Route_Entry; |
Related Topics
-
- API function ADD_STATIC_ROUTE - Add a route for an interface
-
- API function DEL_STATIC_ROUTE - Delete a route from an interface
Top of list Index page
send_params
| struct send_params
{
char far *bufferPtr; // Pointer to send data
int bufferLength; // Number of bytes to send
int flags; // Blocking or no wait
struct sockaddr far *toPtr; // only needed for UDP
int far *tolengthPtr; // only needed for UDP
}; |
Comments
- This structure is defined in tcpip.h. The elements are used as follows:
bufferPtr
Pointer to data to be sent.
bufferLength
Number of bytes to be sent from bufferPtr.
flags
Set to one of following constants defined in tcpip.h:
MSG_BLOCKING: Sleep until data is transferred into the socket transmit queue
MSG_DONTWAIT: Return immediately after loading bytes into
available transmit queue space
toPtr
UDP only
The referenced structure
is cast to a sockaddr_in
structure prior to usage.
The datagram destination IP address and port number is specified
here by caller.
tolengthPtr
UDP only
The 16 bit value referenced by this pointer must be:
sizeof(struct sockaddr_in)
Top of list Index page
SetSocketOption
- This data structure is defined in the TCPIPAPI.H library header file.
| typedef struct tag_setsockopt
{
int protocol_level; // Protocol level: IP level, TCP level or socket level
int optionName; // Option's name constant
const char far *optionValue; // Pointer to the option value (type varies)
int optionLength; // Length of option value data
} SetSocketOption;
// Example usage of API_SETSOCKOPT and SetSocketOption type to set
// IP Time-to-Live to 69 seconds (or router hops):
union REGS inregs, outregs;
struct SREGS segregs;
unsigned char time_to_live = 69;
int socketdescriptor; // You must initialize this (not shown here)
SetSocketOption sockopt = {IP_PROTOIP_LEVEL, // .protocol_level
IPO_TTL, // .optionName
(const char far *)&time_to_live, // .optionValue
sizeof(unsigned char)}; // .optionLength
inregs.h.ah = API_SETSOCKOPT; // Interrupt 0xAC service index
inregs.x.bx = socketdescriptor;
segregs.h.es = FP_SEG(&sockopt); // Fill in ES:DI with a pointer to sockopt
inregs.x.di = FP_OFF(&sockopt);
int86x(TCPIPVECT, &inregs, &outregs, &segregs); // Call API int 0xAC API_SETSOCKOPT |
Comments
- The type of data found at the location referenced by the optionValue
member varies depending on the particular socket
option that is being dealt with.
Related Topics
-
- For list of options and sizes see GetSocketOption
-
- API function API_SETSOCKOPT - Set socket options
Top of list Index page
sockaddr
| struct sockaddr
{
u_char sa_len; // Total Length
u_char sa_family; // Address Family AF_xxx
char sa_data[14]; // up to 14 bytes of protocol specific address
}; |
Comments
- This generic "one size fits all" BSD structure is treated as a
sockaddr_in
structure within the TCP/IP API
functions.
Top of list Index page
sockaddr_in
| struct sockaddr_in
{
short sin_family; // AF_INET
u_short sin_port; // 16 bit Port Number in network byte order
struct in_addr sin_addr; // 32 bit netid/hostid in network byte order
char sin_zero[8]; // unused
}; |
Comments
- The sin_family member should be set to AF_INET (=2).
The sin_addr member's in_addr
structure is simply a long IP
address in
big endian byte
order.
The htons function can be
used to convert port numbers to network byte order.
Top of list Index page
SocketInfo
| typedef struct tag_socket_info{
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; |
Comments
- Possible TCP socket states:
- CLOSED 0
LISTEN 1
SYN_SENT 2
SYN_RECEIVED 3
ESTABLISHED 4
CLOSE_WAIT 5
FIN_WAIT_1 6
CLOSING 7
LAST_ACK 8
FIN_WAIT_2 9
TIME_WAIT 10
INVALID 20
Top of list Index page
TcpMib
| typedef struct tagTcpMib
{
long tcpRtoAlgorithm; // retransmission timeout algorithm
long tcpRtoMin; // minimum retransmission timeout (mS)
long tcpRtoMax; // maximum retransmission timeout (mS)
long tcpMaxConn; // maximum TCP connections possible
unsigned long tcpActiveOpens; // number of SYN-SENT -> CLOSED transitions
unsigned long tcpPassiveOpens; // number of SYN-RCVD -> LISTEN transitions
unsigned long tcpAttemptFails; //(SYN-SENT,SYN-RCVD)->CLOSED or SYN-RCVD->LISTEN
unsigned long tcpEstabResets; // (ESTABLISHED,CLOSE-WAIT) -> CLOSED
unsigned long tcpCurrEstab; // number in ESTABLISHED or CLOSE-WAIT state
unsigned long tcpInSegs; // number of segments received
unsigned long tcpOutSegs; // number of segments sent
unsigned long tcpRetransSegs; // number of retransmitted segments
unsigned long tcpInErrs; // number of received errors
unsigned long tcpOutRsts; // number of transmitted resets
} TcpMib; |
Top of list Index page
UdpMib
| typedef struct tagUdpMib
{
unsigned long udpInDatagrams; // UDP datagrams delivered to users
unsigned long udpNoPorts; // UDP datagrams to port with no listener
unsigned long udpInErrors; // UDP datagrams unable to be delivered
unsigned long udpOutDatagrams;// UDP datagrams sent from this entity
} UdpMib; |
Comments
- These structures are only available in @CHIP-RTOS versions which contain the
SNMP option. A SNMP agent is not part of the @CHIP-RTOS. But if a user is able to implement
an agent based on the TCP/IP API, they need access to the internal TCP/IP SNMP variables.
Related Topics
-
- API function API_SNMP_GET - Get internal TCP/IP SNMP variables
Top of list Index page
UserEthDhcp_Entry
| typedef struct tag_UserDhcpEthEntry
{
unsigned long BootSIpAddress; // BOOT Server (TFTP server), not supported
unsigned long Dns1ServerIpAddress; // Domain name server
unsigned long Dns2ServerIpAddress; // Second domain name server
unsigned long Yiaddr; // Our (leased) IP address
unsigned long NetMask; // Our subnet mask
unsigned long DefRouter; // Default router
unsigned long DhcpServerId; // DHCP selected server IP address
unsigned long internal1; // Internal use only
unsigned long internal2; // Internal use only
unsigned long DhcpLeaseTime; // DHCP Address lease time in milliseconds
unsigned long internal3; // internal use only
unsigned long internal4; // internal use only
unsigned char DomainName[64]; // Domain name
unsigned char BootSname[64]; // TFTP server name, not used
unsigned char BootFileName[128]; // Boot file name (for TFTP download),
// not supported.
unsigned short BootFileSize; // Boot file size in 512 Bytes blocks
// (for TFTP download).
unsigned short internal5; // internal use only
} UserEthDhcp_Entry; |
Comments
- Members of this structure hold the DHCP configuration data if the IPC@CHIP is configured
by a DHCP server.
This is read only information!
Related Topics
-
- API function DHCP_STAT -
Get DHCP status of the internal Ethernet interface of the IPC@CHIP
-
- API function DEV_WAIT_DHCP_COMPLETE -
Get DHCP status for a user Ethernet interface
Top of list Index page
End of document
|