2.9 TCPIP Lite Driver Library
2.9.1 Introduction
The TCPIP-Lite Library for MCC Melody enables the development of TCPIP-Lite applications on 8-bit microcontrollers. This library facilitates quick and easy configuration and code generation of all the available protocols in the latest TCP/IP Lite stack.
2.9.2 Module Documentation
2.9.2.1 ARP
This header file provides the API for the ARPv4 protocol.
2.9.2.1.1 Module description
This header file provides the API for the ARPv4 protocol.
Data structures
struct arpHeader_t
Contains the ARP information.
struct arpMap_t
Contains the ARP database.
Functions
void ARPV4_Init (void)
Initializes the ARP table.
error_msg ARPV4_Packet (void)
Receives all ARP packets on the network and searches the ARP table for an existing ARP entry. If present, it updates the table. If the ARP packet is for the device and its operation is REQUEST, the function replies with the device MAC address.
void ARPV4_Update (void)
Updates the ARP table at least every 10s to avoid aging.
mac48Address_t * ARPV4_Lookup (uint32_t ipAddress)
Maintains an ARP table which maps hardware address to internet address.
error_msg ARPV4_Request (uint32_t destAddress)
Sends the ARP Request.
2.9.2.1.2 Function Documentation
ARPV4_Init()
void ARPV4_Init (void )
Initializes the ARP table.
None. |
None. |
ARPV4_Lookup()
mac48Address_t* ARPV4_Lookup (uint32_t ipAddress)
Maintains an ARP table which maps hardware address to internet address.
ipAddress |
32-bit destination IPv4 address in host order |
Pointer to the destination MAC address. |
ARPV4_Packet()
error_msg ARPV4_Packet (void )
Receives all ARP packets on the network and searches the ARP table for an existing ARP entry. If present, it updates the table. If the ARP packet is for the device and its operation is REQUEST, the function replies with the device MAC address.
None. |
1 |
ARP reply sent successfully |
!1 |
ARP reply is not sent or the ARP packet is not destined for the device |
ARPV4_Request()
error_msg ARPV4_Request (uint32_t destAddress)
Sends the ARP Request.
destAddress |
32-bit destination IPv4 address |
1 |
ARP request sent successfully |
!1 |
ARP request failed to send |
ARPV4_Update()
void ARPV4_Update (void )
Updates the ARP table at least every 10s to avoid aging.
None. |
None. |
2.9.2.2 DHCP
This file provides the API implementation for the Dynamic Host Configuration Protocol (DHCP) client.
2.9.2.2.1 Module description
This file provides the API implementation for the Dynamic Host Configuration Protocol (DHCP) client.
Data structures
struct dhcp_data_t
Contains option data.
struct dhcp_state_t
Contains state data.
Enumerations
enum dhcp_type { DHCP_DISCOVER = 1, DHCP_OFFER, DHCP_REQUEST, DHCP_DECLINE, DHCP_ACK, DHCP_NACK, DHCP_RELEASE, DHCP_INFORM, DHCP_FORCERENEW, DHCP_LEASEQUERY, DHCP_LEASEUNASSIGNED, DHCP_LEASEUNKNOWN, DHCP_LEASEACTIVE, DHCP_BULKLEASEQUERY, DHCP_LEASEQUERYDONE }
Contains DCHP request types.
enum dhcp_rx_client_state { SELECTING, REQUESTING, RENEWLEASE, BOUND }
Contains the DCHP RX Client state.
enum dhcp_timer_client_state { INIT_TIMER, WAITFORTIMER, STARTDISCOVER, STARTREQUEST }
Contains the DCHP Timer Client state.
Functions
bool sendDHCPDISCOVER (void)
Sends the DHCP DISCOVER request.
bool sendDHCPREQUEST (void)
Sends the DHCP REQUEST request.
bool sendDHCPDECLINE (void)
Sends DHCP DECLINE request.
bool sendRequest (dhcp_type type)
Sends a DHCP request.
void DHCP_init (void)
Initializes the DHCP.
void DHCP_Handler (int16_t length)
Receives and processes the DHCP packet.
void DHCP_Manage (void)
Updates the DHCP status at least every one second.
void DHCP_WriteZeros (uint16_t length)
Writes zeroes for the number of bytes passed.
2.9.2.2.2 Function Documentation
DHCP_Handler()
void DHCP_Handler (int16_t length)
Receives and processes the DHCP packet.
length |
Length of the received DHCP packet |
None. |
DHCP_init()
void DHCP_init (void )
Initializes the DHCP.
None. |
None. |
DHCP_Manage()
void DHCP_Manage (void )
Updates the DHCP status at least every one second.
None. |
None. |
DHCP_WriteZeros()
void DHCP_WriteZeros (uint16_t length)
Writes zeroes for the number of bytes passed.
length |
Number of bytes |
None. |
sendDHCPDECLINE()
bool sendDHCPDECLINE (void )
Sends DHCP DECLINE request.
None. |
True |
Request sent successfully |
False |
Request failed to send |
sendDHCPDISCOVER()
bool sendDHCPDISCOVER (void )
Sends the DHCP DISCOVER request.
None. |
True |
Request sent successfully |
False |
Request failed to send |
sendDHCPREQUEST()
bool sendDHCPREQUEST (void )
Sends the DHCP REQUEST request.
None. |
True |
Request sent successfully |
False |
Request failed to send |
sendRequest()
bool sendRequest (dhcp_type type)
Sends a DHCP request.
type |
Request type enumerated in dhcp_type |
True |
Request sent successfully |
False |
Request failed to send |
2.9.2.2.3 Enumeration Type Documentation
dhcp_rx_client_state
enum dhcp_rx_client_state
Contains the DCHP RX Client state.
SELECTING | |
REQUESTING | |
RENEWLEASE | |
BOUND |
dhcp_timer_client_state
enum dhcp_timer_client_state
Contains the DCHP Timer Client state.
INIT_TIMER | |
WAITFORTIMER | |
STARTDISCOVER | |
STARTREQUEST |
dhcp_type
enum dhcp_type
Contains DCHP request types.
DHCP_DISCOVER | |
DHCP_OFFER | |
DHCP_REQUEST | |
DHCP_DECLINE | |
DHCP_ACK | |
DHCP_NACK | |
DHCP_RELEASE | |
DHCP_INFORM | |
DHCP_FORCERENEW | |
DHCP_LEASEQUERY | |
DHCP_LEASEUNASSIGNED | |
DHCP_LEASEUNKNOWN | |
DHCP_LEASEACTIVE | |
DHCP_BULKLEASEQUERY | |
DHCP_LEASEQUERYDONE |
2.9.2.3 DNS
This file provides the API implementation for the Domain Name System (DNS) client.
2.9.2.3.1 Module description
This file provides the API implementation for the Domain Name System (DNS) client.
Functions
static int generateSeed (void)
Generates the seed.
void DNS_Init (void)
Initializes the DNS table.
void DNS_Query (const char *str)
Searches the DNS server for the IPv4 (type A) addresses of the domain names.
void DNS_Handler (int16_t length)
Receives and processes the DNS packet.
uint32_t DNS_Lookup (const char *dns_name)
Maintains the DNS table and maps Domain names to the Internet address.
void DNS_Update (void)
Updates the DNS table at least every 10s to avoid aging.
2.9.2.3.2 Function Documentation
DNS_Handler()
void DNS_Handler (int16_t length)
Receives and processes the DNS packet.
length |
Length of the received DNS packet |
None. |
DNS_Init()
void DNS_Init (void )
Initializes the DNS table.
None. |
None. |
DNS_Lookup()
uint32_t DNS_Lookup (const char * dns_name)
Maintains the DNS table and maps Domain names to the Internet address.
*dns_name |
Domain name |
IPv4 address. |
DNS_Query()
void DNS_Query (const char * str)
Searches the DNS server for the IPv4 (type A) addresses of the domain names.
*str |
Domain name |
None. |
DNS_Update()
void DNS_Update (void )
Updates the DNS table at least every 10s to avoid aging.
None. |
None. |
generateSeed()
static int generateSeed (void )[static]
Generates the seed.
None. |
Generated DNS seed. |
2.9.2.4 ICMP
This file provides the API implementation for the Internet Control Message Protocol (ICMP).
2.9.2.4.1 Module description
This file provides the API implementation for the Internet Control Message Protocol (ICMP).
Functions
error_msg ICMP_Receive (ipv4Header_t *ipv4Hdr)
Receives the ICMP packet. This function processes only Echo Request messages.
error_msg ICMP_EchoReply (ipv4Header_t *ipv4Hdr)
Sends an Echo Reply packet to the destination.
error_msg ICMP_PortUnreachable (uint32_t srcIPAddress, uint32_t destIPAddress, uint16_t length)
Sends Port Unreachable messages to the destination.
bool isPortUnreachable (uint16_t port)
Checks if the Port Unreachable flag is set to the port number of the application.
void resetPortUnreachable (void)
Resets the Port Unreachable flag to zero.
2.9.2.4.2 Function Documentation
ICMP_EchoReply()
error_msg ICMP_EchoReply (ipv4Header_t * ipv4Hdr)
Sends an Echo Reply packet to the destination.
*ipv4_hdr |
IPv4 header of the received packet |
Error status. Refer to the error description in tcpip_types.h. |
ICMP_PortUnreachable()
error_msg ICMP_PortUnreachable (uint32_t srcIPAddress, uint32_t destIPAddress, uint16_t length)
Sends Port Unreachable messages to the destination.
srcIPAddress |
Source IP address |
destIPAddress |
Destination IP address |
length |
Length of the IP datagram |
Error status. Refer to the error description in tcpip_types.h. |
ICMP_Receive()
error_msg ICMP_Receive (ipv4Header_t * ipv4Hdr)
Receives the ICMP packet. This function processes only Echo Request messages.
*ipv4_hdr |
IPv4 header of the received packet |
1 |
ICMP packet received |
!1 |
ICMP packet not received |
isPortUnreachable()
bool isPortUnreachable (uint16_t port)
Checks if the Port Unreachable flag is set to the port number of the application.
port |
Port number of the application |
True |
The port is unreachable |
False |
The port is reachable |
resetPortUnreachable()
void resetPortUnreachable (void )
Resets the Port Unreachable flag to zero.
None. |
None. |
2.9.2.5 IPV4
This file provides the API implementation for the Internet Protocol v4 (IPv4).
2.9.2.5.1 Module description
This file provides the API implementation for the Internet Protocol v4 (IPv4).
Data structures
struct ip_db_info_t
Contains IP information.
Functions
void ipdb_init (void)
Initializes the IP database.
uint32_t makeStrToIpv4Address (char *str)
Converts a string into a 32-bit IPv4 address.
char * makeIpv4AddresstoStr (uint32_t addr)
Converts an IPv4 address into a string.
void TCP_Recv (uint32_t remoteAddress, uint16_t length)
Receives TCP packets.
static uint8_t getHeaderLen (void)
Returns the header length.
error_msg IPV4_Packet (void)
Receives the IPv4 packet. This function reads the IPv4 header and filters the upper layer protocols.
error_msg IPv4_Start (uint32_t dstAddress, ipProtocolNumbers protocol)
Starts the IPv4 packet. This routine starts the Ethernet packet and writes the IPv4 header. Initially Checksum and Payload length are set to '0'. An error code is returned if there has been an error in accepting, or if something goes wrong.
uint16_t IPV4_PseudoHeaderChecksum (uint16_t payloadLen)
Computes the pseudo-header checksum for transport layer protocols.
error_msg IPV4_Send (uint16_t payloadLength)
Sends the IPv4 packet. This function inserts the total length of IPv4 packet, computes and adds the Ipv4 header checksum.
uint16_t IPV4_GetDatagramLength (void)
Returns the length of the IPv4 datagram.
2.9.2.5.2 Function Documentation
getHeaderLen()
static uint8_t getHeaderLen (void )[static]
Returns the header length.
None. |
Length of the header. |
ipdb_init()
void ipdb_init (void )
Initializes the IP database.
None. |
None. |
IPV4_GetDatagramLength()
uint16_t IPV4_GetDatagramLength (void )
Returns the length of the IPv4 datagram.
None. |
Length of IPV4 datagram. |
IPV4_Packet()
error_msg IPV4_Packet (void )
Receives the IPv4 packet. This function reads the IPv4 header and filters the upper layer protocols.
None. |
Error status. Refer to the error description in tcpip_types.h. |
IPV4_PseudoHeaderChecksum()
uint16_t IPV4_PseudoHeaderChecksum (uint16_t payloadLen)
Computes the pseudo-header checksum for transport layer protocols.
payloadLen |
Length of the transport layer packet |
Checksum. |
IPV4_Send()
error_msg IPV4_Send (uint16_t payloadLength)
Sends the IPv4 packet. This function inserts the total length of IPv4 packet, computes and adds the Ipv4 header checksum.
payloadLength |
Data length of the transport packet |
1 |
IP packet was sent successfully |
!1 |
IP packet was not sent |
IPv4_Start()
error_msg IPv4_Start (uint32_t dstAddress, ipProtocolNumbers protocol)
Starts the IPv4 packet. This routine starts the Ethernet packet and writes the IPv4 header. Initially Checksum and Payload length are set to '0'. An error code is returned if there has been an error in accepting, or if something goes wrong.
dstAddress |
32-bit destination Ipv4 address |
protocol |
Protocol number |
Error status. Refer to the error description in tcpip_types.h. |
makeIpv4AddresstoStr()
char* makeIpv4AddresstoStr (uint32_t addr)
Converts an IPv4 address into a string.
addr |
32-bit IPV4 address |
IPV4 address in a string format. |
makeStrToIpv4Address()
uint32_t makeStrToIpv4Address (char * str)
Converts a string into a 32-bit IPv4 address.
*str |
IPv4 address in a string format |
IPv4 address. |
TCP_Recv()
void TCP_Recv (uint32_t remoteAddress, uint16_t length)
Receives TCP packets.
remoteAddress |
Address of the remote device |
length |
Packet length |
None. |
Receives TCP packets.
remoteAddress |
Source IP address for the received TCP packet |
length |
Length of the TCP payload |
None. |
2.9.2.6 LLDP
This file provides the API implementation of the Link Layer Discovery Protocol (LLDP).
2.9.2.6.1 Module description
This file provides the API implementation of the Link Layer Discovery Protocol (LLDP).
Data structures
struct lldp_tx_port_t
Per-interface structure for TX, part of lldp_port.
struct lldp_rx_port_t
Per-interface structure for RX, part of lldp_port.
struct lldp_per_port_t
LLDP per port.
struct lldp_tx_timers_t
LLDP TX timers.
struct createBasicTLV_t
Creates a basic Type-Length-Value (TLV).
struct createOrgTLV_t
Creates Organizationally Specific TLV.
struct orgSpecificTLVs_t
Initializes the Organizationally Specific TLV.
union orgProcessFlags
Process flags.
Enumerations
enum lldp_admin_status { disabled =0, enabledTxOnly = 1, enabledRxOnly = 2, enabledRxTx = 3 }
Contains the LLDP admin status.
enum lldp_txTimerStates_t { TX_TIMER_INITIALIZE, TX_TIMER_IDLE, TX_TIMER_EXPIRES, TX_TICK, SIGNAL_TX, TX_FAST_START }
LLDP TX Timer states.
enum lldp_txStates_t { TX_LLDP_INITIALIZE, TX_IDLE, TX_INFO_FRAME, TX_SHUTDOWN_FRAME }
LLDP TX states.
enum lldp_rxStates_t { LLDP_WAIT_PORT_OPERATIONAL, RX_LLDP_INITIALIZE, RX_WAIT_FOR_FRAME, RX_FRAME }
LLDP RX states.
enum TLV_TYPES { END_LLDPDU_TLV =0, CHASSIS_ID_TLV, PORT_ID_TLV, TIME_TO_LIVE_TLV, PORT_DESCRIPTION_TLV, SYSTEM_NAME_TLV, SYSTEM_DESCRIPTION_TLV, SYSTEM_CAPABILITIES_TLV, MANAGEMENT_ADDRESS_TLV, ORG_SPECIFIC_TLV =127 }
Mandatory and optional TLV types from IEEE 802.1AB.
enum CHASSIS_SUBTYPE { CHASSIS_COMPONENT =1, CHASSIS_INTERFACE_ALIAS, CHASSIS_PORT_COMPONENT, CHASSIS_MAC_ADDRESS, CHASSIS_NETWORK_ADDRESS, CHASSIS_INTERFACE_NAME, CHASSIS_LOCALLY_ASSIGNED }
TLV subtypes from section 9 of IEEE 802.1AB.
enum PORT_SUBTYPE { reserved, PORT_INTERFACE_ALIAS =1, PORT_COMPONENT, PORT_MAC_ADDRESS, PORT_NETWORK_ADDRESS, PORT_INTERFACE_NAME, PORT_AGENT_CIRCUIT_ID, PORT_LOCALLY_ASSIGNED }
TLV subtypes from section 9 of IEEE 802.1AB.
enum ORG_IEEE_3_SUBTYPE { res, IEEE_3_MAC_PHY_CONFIG =1, IEEE_3_POWER_VIA_MDI, IEEE_3_LINK_AGGREGATION, IEEE_3_MAX_FRAME_SIZE, IEEE_3_ENERGY_EFFICIENT_ETHERNET }
Organizationally Specific TLVs from section 79.3 of IEEE 802.3.
enum ORG_TIA_SUBTYPE { res1, TIA_LLDP_MED =1, TIA_NETWORK_POLICY, TIA_LOCATION_ID, TIA_EXTENDED_POWER_VIA_MDI, TIA_INVENT_HW_REV, TIA_INVENT_FW_REV, TIA_INVENT_SW_REV, TIA_INVENT_SERIAL_NUM, TIA_INVENT_MANUFACT_NAME, TIA_INVENT_MODEL_NAME, TIA_INVENT_ASSET_ID }
Organizationally Specific TLVs from section 10 of ANSI-TIA_1057.
enum ORG_CISCO_SUBTYPE { res2 =0, CISCO_POWER_VIA_MDI =1, CISCO_OUI_TLV, CISCO_CLASS_TLV, CISCO_PROTOCOL_TLV }
Organizationally Specific TLVs from section 79.3 of IEEE 802.3.
enum ORG_MUD_CISCO_SUBTYPE { res3 =0, CISCO_MUD_TLV =1 }
Organizationally Specific TLVs from section 79.3 of IEEE 802.3.
Functions
void LLDP_Packet (void)
Processes LLDP packets.
uint8_t get_org_tlvs_table_size (void)
Gets the size of the table that stores Organizationally Specific TLVs.
void LLDP_Run (void)
Runs the LLDP.
void LLDP_InitRx (void)
Initializes the LLDP RX.
void LLDP_InitTx (void)
Initializes the LLDP TX.
void LLDP_InitRxTx (void)
Initializes the LLDP RX and TX.
void LLDP_DecTTR (void)
Decreases the LLDP TX timer value.
void LLDP_SetDesiredPower (uint16_t pwr)
Sets the LLDP desired power.
uint16_t LLDP_GetAllocatedPower (void)
Gets the LLDP allocated power.
void LLDP_setPortDescription (const char *val)
Sets the LLDP port description.
char * LLDP_getPortDescription (void)
Gets the LLDP port description.
char * LLDP_getInfo (char *Name)
Gets the LLDP information.
void LLDP_setAssetID (const char *val)
Sets the LLDP asset ID.
char * LLDP_getAssetID (void)
Gets the LLDP asset ID.
void LLDP_setModelName (const char *val)
Sets the LLDP module name.
char * LLDP_getModelName (void)
Gets the LLDP module name.
void LLDP_setManufacturer (const char *val)
Sets the LLDP manufacturer.
char * LLDP_getManufacturer (void)
Gets the LLDP manufacturer.
void LLDP_setSerialNumber (const char *val)
Sets the LLDP serial number.
char * LLDP_getSerialNumber (void)
Gets the LLDP serial number.
void LLDP_setSoftwareRevision (const char *val)
Sets the LLDP software revision.
char * LLDP_getSoftwareRevision (void)
Gets the LLDP software revision.
void LLDP_setHardwareRevision (const char *val)
Sets the LLDP hardware revision.
char * LLDP_getHardwareRevision (void)
Gets the LLDP hardware revision.
void LLDP_setFirmwareRevision (const char *val)
Sets the LLDP firmware revision.
char * LLDP_getFirmwareRevision (void)
Gets the LLDP firmware revision.
void LLDP_setMUDInfo (const char *val)
Sets the LLDP Manufacturer Usage Description (MUD) information.
MulticastMacAddr LLDP_SetDestAddress (void)
Sets the LLDP destination address.
2.9.2.6.2 Function Documentation
get_org_tlvs_table_size()
uint8_t get_org_tlvs_table_size (void )
Gets the size of the table that stores Organizationally Specific TLVs.
None. |
Table size |
LLDP_DecTTR()
void LLDP_DecTTR (void )
Decreases the LLDP TX timer value.
None. |
None. |
LLDP_GetAllocatedPower()
uint16_t LLDP_GetAllocatedPower (void )
Gets the LLDP allocated power.
None. |
Allocated power. |
LLDP_getAssetID()
char* LLDP_getAssetID (void )
Gets the LLDP asset ID.
None. |
Asset ID. |
LLDP_getFirmwareRevision()
char* LLDP_getFirmwareRevision (void )
Gets the LLDP firmware revision.
None. |
Firmware revision. |
LLDP_getHardwareRevision()
char* LLDP_getHardwareRevision (void )
Gets the LLDP hardware revision.
None. |
Hardware revision. |
LLDP_getInfo()
char* LLDP_getInfo (char * Name)
Gets the LLDP information.
*Name |
Name of port |
Port description. |
LLDP_getManufacturer()
char* LLDP_getManufacturer (void )
Gets the LLDP manufacturer.
None. |
Manufacturer. |
LLDP_getModelName()
char* LLDP_getModelName (void )
Gets the LLDP module name.
None. |
Module name. |
LLDP_getPortDescription()
char* LLDP_getPortDescription (void )
Gets the LLDP port description.
None. |
Port description. |
LLDP_getSerialNumber()
char* LLDP_getSerialNumber (void )
Gets the LLDP serial number.
None. |
Serial number. |
LLDP_getSoftwareRevision()
char* LLDP_getSoftwareRevision (void )
Gets the LLDP software revision.
None. |
Software revision. |
LLDP_InitRx()
void LLDP_InitRx (void )
Initializes the LLDP RX.
None. |
None. |
LLDP_InitRxTx()
void LLDP_InitRxTx (void )
Initializes the LLDP RX and TX.
None. |
None. |
LLDP_InitTx()
void LLDP_InitTx (void )
Initializes the LLDP TX.
None. |
None. |
LLDP_Packet()
void LLDP_Packet (void )
Processes LLDP packets.
None. |
None. |
LLDP_Run()
void LLDP_Run (void )
Runs the LLDP.
None. |
None. |
LLDP_setAssetID()
void LLDP_setAssetID (const char * val)
Sets the LLDP asset ID.
*val |
Asset ID |
None. |
LLDP_SetDesiredPower()
void LLDP_SetDesiredPower (uint16_t pwr)
Sets the LLDP desired power.
pwr |
Desired power |
None. |
LLDP_SetDestAddress()
MulticastMacAddr LLDP_SetDestAddress (void )
Sets the LLDP destination address.
None. |
Multicast MAC Address. |
LLDP_setFirmwareRevision()
void LLDP_setFirmwareRevision (const char * val)
Sets the LLDP firmware revision.
*val |
Firmware revision |
None. |
LLDP_setHardwareRevision()
void LLDP_setHardwareRevision (const char * val)
Sets the LLDP hardware revision.
*val |
Hardware revision |
None. |
LLDP_setManufacturer()
void LLDP_setManufacturer (const char * val)
Sets the LLDP manufacturer.
*val |
- Manufacturer |
None. |
LLDP_setModelName()
void LLDP_setModelName (const char * val)
Sets the LLDP module name.
*val |
Module name |
None. |
LLDP_setMUDInfo()
void LLDP_setMUDInfo (const char * val)
Sets the LLDP Manufacturer Usage Description (MUD) information.
*val |
MUD information |
None. |
LLDP_setPortDescription()
void LLDP_setPortDescription (const char * val)
Sets the LLDP port description.
*val |
Port description |
None. |
LLDP_setSerialNumber()
void LLDP_setSerialNumber (const char * val)
Sets the LLDP serial number.
*val |
Serial number |
None. |
LLDP_setSoftwareRevision()
void LLDP_setSoftwareRevision (const char * val)
Sets the LLDP software revision.
*val |
Software revision |
None. |
2.9.2.6.3 Enumeration Type Documentation
CHASSIS_SUBTYPE
enum CHASSIS_SUBTYPE
TLV subtypes from section 9 of IEEE 802.1AB.
CHASSIS_COMPONENT | |
CHASSIS_INTERFACE_ALIAS | |
CHASSIS_PORT_COMPONENT | |
CHASSIS_MAC_ADDRESS | |
CHASSIS_NETWORK_ADDRESS | |
CHASSIS_INTERFACE_NAME | |
CHASSIS_LOCALLY_ASSIGNED |
lldp_admin_status
enum lldp_admin_status
Contains the LLDP admin status.
disabled | |
enabledTxOnly | |
enabledRxOnly | |
enabledRxTx |
lldp_rxStates_t
enum lldp_rxStates_t
LLDP RX states.
LLDP_WAIT_PORT_OPERATIONAL | |
RX_LLDP_INITIALIZE | |
RX_WAIT_FOR_FRAME | |
RX_FRAME |
lldp_txStates_t
enum lldp_txStates_t
LLDP TX states.
TX_LLDP_INITIALIZE | |
TX_IDLE | |
TX_INFO_FRAME | |
TX_SHUTDOWN_FRAME |
lldp_txTimerStates_t
enum lldp_txTimerStates_t
LLDP TX Timer states.
TX_TIMER_INITIALIZE | |
TX_TIMER_IDLE | |
TX_TIMER_EXPIRES | |
TX_TICK | |
SIGNAL_TX | |
TX_FAST_START |
ORG_CISCO_SUBTYPE
enum ORG_CISCO_SUBTYPE
Organizationally Specific TLVs from section 79.3 of IEEE 802.3.
res2 | |
CISCO_POWER_VIA_MDI | |
CISCO_OUI_TLV | |
CISCO_CLASS_TLV | |
CISCO_PROTOCOL_TLV |
ORG_IEEE_3_SUBTYPE
enum ORG_IEEE_3_SUBTYPE
Organizationally Specific TLVs from section 79.3 of IEEE 802.3.
res | |
IEEE_3_MAC_PHY_CONFIG | |
IEEE_3_POWER_VIA_MDI | |
IEEE_3_LINK_AGGREGATION |
Deprecated |
IEEE_3_MAX_FRAME_SIZE | |
IEEE_3_ENERGY_EFFICIENT_ETHERNET |
ORG_MUD_CISCO_SUBTYPE
enum ORG_MUD_CISCO_SUBTYPE
Organizationally Specific TLVs from section 79.3 of IEEE 802.3.
res3 | |
CISCO_MUD_TLV |
ORG_TIA_SUBTYPE
enum ORG_TIA_SUBTYPE
Organizationally Specific TLVs from section 10 of ANSI-TIA_1057.
res1 | |
TIA_LLDP_MED | |
TIA_NETWORK_POLICY | |
TIA_LOCATION_ID | |
TIA_EXTENDED_POWER_VIA_MDI | |
TIA_INVENT_HW_REV | |
TIA_INVENT_FW_REV | |
TIA_INVENT_SW_REV | |
TIA_INVENT_SERIAL_NUM | |
TIA_INVENT_MANUFACT_NAME | |
TIA_INVENT_MODEL_NAME | |
TIA_INVENT_ASSET_ID |
PORT_SUBTYPE
enum PORT_SUBTYPE
TLV subtypes from section 9 of IEEE 802.1AB.
reserved | |
PORT_INTERFACE_ALIAS | |
PORT_COMPONENT | |
PORT_MAC_ADDRESS | |
PORT_NETWORK_ADDRESS | |
PORT_INTERFACE_NAME | |
PORT_AGENT_CIRCUIT_ID | |
PORT_LOCALLY_ASSIGNED |
TLV_TYPES
enum TLV_TYPES
Mandatory and optional TLV types from IEEE 802.1AB.
END_LLDPDU_TLV |
Mandatory |
CHASSIS_ID_TLV |
Mandatory |
PORT_ID_TLV |
Mandatory |
TIME_TO_LIVE_TLV |
Mandatory |
PORT_DESCRIPTION_TLV |
Optional |
SYSTEM_NAME_TLV |
Optional |
SYSTEM_DESCRIPTION_TLV |
Optional |
SYSTEM_CAPABILITIES_TLV |
Optional |
MANAGEMENT_ADDRESS_TLV |
Optional |
ORG_SPECIFIC_TLV |
Optional |
2.9.2.7 NTP
This file provides the API implementation for the Network Time Protocol (NTP) client.
2.9.2.7.1 Module description
This file provides the API implementation for the Network Time Protocol (NTP) client.
Definitions
#define NTP_TIME_OFFSET 2208988800
The time offset converts from unix time (seconds, since January 1, 1970) to RFC 868 time (seconds, since January 1, 1900). The RFC indicates that this is sufficient until 2036.
Functions
void NTP_Request (void)
Sends the NTP request to the NTP server.
void NTP_Handler (int16_t length)
Receives and processes the NTP packet.
2.9.2.7.2 Definition Documentation
NTP_TIME_OFFSET
#define NTP_TIME_OFFSET 2208988800
The time offset converts from unix time (seconds, since January 1, 1970) to RFC 868 time (seconds, since January 1, 1900). The RFC indicates that this is sufficient until 2036.
2.9.2.7.3 Function Documentation
NTP_Handler()
void NTP_Handler (int16_t length)
Receives and processes the NTP packet.
length |
Length of the received NTP packet |
None. |
NTP_Request()
void NTP_Request (void )
Sends the NTP request to the NTP server.
None. |
None. |
2.9.2.8 TCP
This file provides the API implementation for the Transmission Control Protocol v4 (TCPv4).
2.9.2.8.1 Module description
This file provides the API implementation for the Transmission Control Protocol v4 (TCPv4).
Data structures
struct tcpTCB_t
Defines TCP Transmission Control Block.
Enumerations
enum tcp_fsm_states_t { CLOSED = 0, LISTEN, SYN_SENT, SYN_RECEIVED, ESTABLISHED, FIN_WAIT_1, FIN_WAIT_2, CLOSE_WAIT, CLOSING, LAST_ACK, TIME_WAIT }
TCP Finite State Machine (FSM) states.
enum tcpEvent_t { CLOSE = 0, ACTIVE_OPEN, PASIVE_OPEN, RCV_SYN, RCV_ACK, RCV_SYNACK, RCV_FIN, RCV_FINACK, RX_PACKET, RCV_RST, RCV_RSTACK, RCV_PSHACK, TIMEOUT, NOP }
TCP events.
enum socketState_t { NOT_A_SOCKET = 0, SOCKET_CLOSED, SOCKET_IN_PROGRESS, SOCKET_CONNECTED, SOCKET_CLOSING }
Socket states to be used in the application.
enum tcpBufferState_t { NO_BUFF = 0, RX_BUFF_IN_USE, TX_BUFF_IN_USE }
TCP Buffer state.
enum tcp_options_t { TCP_EOP = 0u, TCP_NOP = 1u, TCP_MSS = 2u }
TCP options.
Functions
static error_msg TCP_FiniteStateMachine (void)
TCP stack state machine called upon the occurrence of each event (e.g., opening/closing a connection, receiving a TCP packet).
static error_msg TCP_TimoutRetransmit (void)
Retransmits TCP packets after timeout.
static void TCB_Insert (tcpTCB_t *ptr)
Inserts a pointer to the new TCB into the TCB pointer list.
static void TCB_Remove (tcpTCB_t *ptr)
Removes a pointer to a TCB from the TCB pointer list and connects its adjacent items together.
static void TCB_Reset (tcpTCB_t *tcbPtr)
Resets the socket to a known state.
static error_msg TCB_Check (tcpTCB_t *ptr)
Check if there is a pointer to a socket/TCB. If the pointer is in the TCB list, then it is a valid socket.
static error_msg TCP_Snd (tcpTCB_t *tcbPtr)
Internal function of the TCP stack to send a TCP packet.
error_msg TCP_PayloadSave (uint16_t len)
Copies the TCP packet payload to the socket RX buffer. This routine also sends the ACK for the received packet and any data ready to be sent.
static error_msg TCP_ParseTCPOptions (void)
Reads and parses the Options field in the TCP header. This routine reads only the ones that have SYN or SYN + ACK. For the other TCP headers the field will be skipped.
void TCP_Recv (uint32_t remoteAddress, uint16_t length)
Identifies the destination socket and parses the TCP header. This routine is called by the IP layer for each received TCP packet.
void TCP_Init (void)
Initializes TCP structures, meaning certain internal TCP stack variables.
error_msg TCP_SocketInit (tcpTCB_t *tcbPtr)
Initializes the TCB and adds it to the list of TCB pointers. The socket needs to be put in the Closed state. The user is responsible to manage memory allocation and release.
error_msg TCP_SocketRemove (tcpTCB_t *tcbPtr)
Removes the socket pointer from the TCP stack, and the list of TCB pointers, respectively. After calling this routine the memory is ready to be used again.
socketState_t TCP_SocketPoll (tcpTCB_t *socket_ptr)
Provides an interface to read the status of the socket. This routine also checks if the pointer is already in the TCB list. This means that the socket is "in use". If the socket is in the TCB list, the socket status will be returned.
error_msg TCP_Bind (tcpTCB_t *tcbPtr, uint16_t port)
Assigns a port number to the specified socket. This is used for configuring the local port of a socket.
error_msg TCP_Listen (tcpTCB_t *tcbPtr)
Listens for connections on a socket. This routine marks the socket as passive, meaning that it will be used to accept incoming connection requests.
error_msg TCP_Connect (tcpTCB_t *tcbPtr, sockaddr_in4_t *srvaddr)
Starts the client for a particular socket.
error_msg TCP_Close (tcpTCB_t *tcbPtr)
Closes the TCP connection. This initiates the closing sequence for the TCP connection.
error_msg TCP_Send (tcpTCB_t *tcbPtr, uint8_t *data, uint16_t dataLen)
Sends a buffer to a remote machine using a TCP connection. This routine adds the buffer to the socket and the payload is sent as soon as possible.
error_msg TCP_SendDone (tcpTCB_t *tcbPtr)
Checks if the TX buffer was sent. This means that the data was received correctly by the remote machine and the TX buffer memory can be reused by the application.
error_msg TCP_InsertRxBuffer (tcpTCB_t *tcbPtr, uint8_t *data, uint16_t data_len)
Adds the RX buffer to the socket.
int16_t TCP_GetReceivedData (tcpTCB_t *tcbPtr)
Reads the available data from the socket. This routine provides the start address of the received buffer to the user.
int16_t TCP_GetRxLength (tcpTCB_t *tcbPtr)
Checks and returns the number of available bytes received on a socket.
void TCP_Update (void)
Handles the TCP stack time-outs for each available socket. This routine needs to be called periodically.
2.9.2.8.2 Function Documentation
TCB_Check()
static error_msg TCB_Check (tcpTCB_t * ptr)[static]
Check if there is a pointer to a socket/TCB. If the pointer is in the TCB list, then it is a valid socket.
*ptr |
Pointer to the socket/TCB structure |
Error status. Refer to the error description in tcpip_types.h. |
TCB_Insert()
static void TCB_Insert (tcpTCB_t * ptr)[static]
Inserts a pointer to the new TCB into the TCB pointer list.
*ptr |
Pointer to the user-allocated memory for the TCB structure |
None. |
TCB_Remove()
static void TCB_Remove (tcpTCB_t * ptr)[static]
Removes a pointer to a TCB from the TCB pointer list and connects its adjacent items together.
*ptr |
Pointer to the user-allocated memory for the TCB structure |
None. |
TCB_Reset()
static void TCB_Reset (tcpTCB_t * tcbPtr)[static]
Resets the socket to a known state.
*tcbPtr |
Pointer to the socket/TCB structure |
None. |
TCP_Bind()
error_msg TCP_Bind (tcpTCB_t * tcbPtr, uint16_t port)
Assigns a port number to the specified socket. This is used for configuring the local port of a socket.
*tcbPtr |
Pointer to the socket/TCB structure |
port |
Port number to be used as a local port |
True |
The port initialization succeeded |
False |
The port initialization failed |
TCP_Close()
error_msg TCP_Close (tcpTCB_t * tcbPtr)
Closes the TCP connection. This initiates the closing sequence for the TCP connection.
*tcbPtr |
Pointer to the socket/TCB structure |
True |
The closing sequence was initialized |
False |
The closing sequence was not initialized |
TCP_Connect()
error_msg TCP_Connect (tcpTCB_t * tcbPtr, sockaddr_in4_t * srvaddr)
Starts the client for a particular socket.
*tcbPtr |
Pointer to the socket/TCB structure |
*srvaddr |
Pointer to the server address |
True |
Starting the server succeeded |
False |
Starting the server failed |
TCP_FiniteStateMachine()
static error_msg TCP_FiniteStateMachine (void )[static]
TCP stack state machine called upon the occurrence of each event (e.g., opening/closing a connection, receiving a TCP packet).
None. |
Error status. Refer to the error description in tcpip_types.h. |
TCP_GetReceivedData()
int16_t TCP_GetReceivedData (tcpTCB_t * tcbPtr)
Reads the available data from the socket. This routine provides the start address of the received buffer to the user.
*tcbPtr |
Pointer to the socket/TCB structure |
Number of received bytes in the buffer. |
TCP_GetRxLength()
int16_t TCP_GetRxLength (tcpTCB_t * tcbPtr)
Checks and returns the number of available bytes received on a socket.
*tcbPtr |
Pointer to the socket/TCB structure |
Number of received bytes in the buffer. |
TCP_Init()
void TCP_Init (void )
Initializes TCP structures, meaning certain internal TCP stack variables.
None. |
None. |
TCP_InsertRxBuffer()
error_msg TCP_InsertRxBuffer (tcpTCB_t * tcbPtr, uint8_t * data, uint16_t data_len)
Adds the RX buffer to the socket.
*tcbPtr |
Pointer to the socket/TCB structure |
*data |
Pointer to the data buffer |
data_len |
Size of the buffer |
True |
Passing the buffer to the socket succeeded |
False |
Passing the buffer to the socket failed |
TCP_Listen()
error_msg TCP_Listen (tcpTCB_t * tcbPtr)
Listens for connections on a socket. This routine marks the socket as passive, meaning that it will be used to accept incoming connection requests.
*tcbPtr |
Pointer to the socket/TCB structure |
True |
Starting the server succeeded |
False |
Starting the server failed |
TCP_ParseTCPOptions()
static error_msg TCP_ParseTCPOptions (void )[static]
Reads and parses the Options field in the TCP header. This routine reads only the ones that have SYN or SYN + ACK. For the other TCP headers the field will be skipped.
None. |
True |
Parsing the Options field succeeded |
False |
Parsing the Options field failed |
TCP_PayloadSave()
error_msg TCP_PayloadSave (uint16_t len)
Copies the TCP packet payload to the socket RX buffer. This routine also sends the ACK for the received packet and any data ready to be sent.
len |
Length of the payload received |
True |
Copying the payload to the RX buffer succeeded |
False |
Copying the payload to the RX buffer failed |
TCP_Recv()
void TCP_Recv (uint32_t remoteAddress, uint16_t length)
Identifies the destination socket and parses the TCP header. This routine is called by the IP layer for each received TCP packet.
Receives TCP packets.
remoteAddress |
Source IP address for the received TCP packet |
length |
Length of the TCP payload |
None. |
TCP_Send()
error_msg TCP_Send (tcpTCB_t * tcbPtr, uint8_t * data, uint16_t dataLen)
Sends a buffer to a remote machine using a TCP connection. This routine adds the buffer to the socket and the payload is sent as soon as possible.
*tcbPtr |
Pointer to the socket/TCB structure |
*data |
Pointer to the data buffer |
dataLen |
Size of the buffer |
True |
Adding the buffer to the socket/TCB succeeded |
False |
Adding the buffer to the socket/TCB failed |
TCP_SendDone()
error_msg TCP_SendDone (tcpTCB_t * tcbPtr)
Checks if the TX buffer was sent. This means that the data was received correctly by the remote machine and the TX buffer memory can be reused by the application.
*tcbPtr |
Pointer to the socket/TCB structure |
True |
Buffer transmission succeeded |
False |
Buffer transmission failed or was not yet started |
TCP_Snd()
static error_msg TCP_Snd (tcpTCB_t * tcbPtr)[static]
Internal function of the TCP stack to send a TCP packet.
*tcbPtr |
Pointer to the socket/TCB structure |
True |
Sending the buffer succeeded |
False |
Sending the buffer failed |
TCP_SocketInit()
error_msg TCP_SocketInit (tcpTCB_t * tcbPtr)
Initializes the TCB and adds it to the list of TCB pointers. The socket needs to be put in the Closed state. The user is responsible to manage memory allocation and release.
*tcbPtr |
Pointer to the socket/TCB structure |
-1 |
The insertion failed |
0 |
The insertion succeeded |
TCP_SocketPoll()
socketState_t TCP_SocketPoll (tcpTCB_t * socket_ptr)
Provides an interface to read the status of the socket. This routine also checks if the pointer is already in the TCB list. This means that the socket is "in use". If the socket is in the TCB list, the socket status will be returned.
*socket_ptr |
Pointer to the socket/TCB structure |
Socket status. |
TCP_SocketRemove()
error_msg TCP_SocketRemove (tcpTCB_t * tcbPtr)
Removes the socket pointer from the TCP stack, and the list of TCB pointers, respectively. After calling this routine the memory is ready to be used again.
*tcbPtr |
Pointer to the socket/TCB structure |
-1 |
Removing the socket failed |
0 |
Removing the socket succeeded |
TCP_TimoutRetransmit()
static error_msg TCP_TimoutRetransmit (void )[static]
Retransmits TCP packets after timeout.
None. |
Error status. Refer to the error description in tcpip_types.h. |
TCP_Update()
void TCP_Update (void )
Handles the TCP stack time-outs for each available socket. This routine needs to be called periodically.
None. |
None. |
2.9.2.8.3 Enumeration Type Documentation
socketState_t
enum socketState_t
Socket states to be used in the application.
NOT_A_SOCKET |
This is not a socket |
SOCKET_CLOSED |
Socket closed |
SOCKET_IN_PROGRESS |
The TCP listens or initiates a connection |
SOCKET_CONNECTED |
The TCP is in the established state and the user can send/receive data |
SOCKET_CLOSING |
The user initiates the closing procedure for this socket |
tcp_fsm_states_t
enum tcp_fsm_states_t
TCP Finite State Machine (FSM) states.
CLOSED |
Facilitates initialization |
LISTEN | |
SYN_SENT | |
SYN_RECEIVED | |
ESTABLISHED | |
FIN_WAIT_1 | |
FIN_WAIT_2 | |
CLOSE_WAIT | |
CLOSING | |
LAST_ACK | |
TIME_WAIT |
tcp_options_t
enum tcp_options_t
TCP options.
TCP_EOP |
length = 0 End of Option List, [RFC793] |
TCP_NOP |
length = 0 No-Operation, [RFC793] |
TCP_MSS |
length = 4 Maximum Segment Size, [RFC793] |
tcpBufferState_t
enum tcpBufferState_t
TCP Buffer state.
NO_BUFF | |
RX_BUFF_IN_USE | |
TX_BUFF_IN_USE |
tcpEvent_t
enum tcpEvent_t
TCP events.
CLOSE |
Facilitates initialization |
ACTIVE_OPEN | |
PASIVE_OPEN | |
RCV_SYN | |
RCV_ACK | |
RCV_SYNACK | |
RCV_FIN | |
RCV_FINACK | |
RX_PACKET | |
RCV_RST | |
RCV_RSTACK | |
RCV_PSHACK | |
TIMEOUT | |
NOP |
2.9.2.9 TFTP
This file contains the API implementation for the Trivial File Transfer Protocol (TFTP).
2.9.2.9.1 Module description
This file contains the API implementation for the Trivial File Transfer Protocol (TFTP).
Data structures
struct store_handler_t
Storage handler.
Enumerations
enum tftp_client_state { tftp_read = 1, tftp_write, tftp_data, tftp_ack, tftp_error, tftp_optack }
TFTP Client state.
enum tftp_opcode { TFTP_READ_REQUEST =0x0001, TFTP_WRITE_REQUEST, TFTP_DATA, TFTP_ACK, TFTP_ERROR, TFTP_OPTACK }
TFTP opcode.
Functions
void TFTP_Ack (uint8_t opcode)
Sends an acknowledgement on receiving a packet from a TFTP Server.
error_msg TFTP_Read_Write_Request (uint8_t opcode)
Sends a read or write request to the TFTP server depending on the opcode.
void TFTP_Handler (int16_t length)
Processes a TFTP message as per the opcode in the packet.
void Process_TFTP_Data (uint32_t address, char *data, uint16_t length)
Processes TFTP packets with 'data' opcode and blocks of the specified size. Depending on TFTP_callBackTable, the storage can be in EEPROM, Flash, etc.
void TFTP_Configure (uint32_t tftp_server_address, char *tftp_filename, char *tftp_block_size)
Allows the user to configure the TFTP server options.
Variables
uint16_t store_type = 0
2.9.2.9.2 Function Documentation
Process_TFTP_Data()
void Process_TFTP_Data (uint32_t address, char * data, uint16_t length)
Processes TFTP packets with 'data' opcode and blocks of the specified size. Depending on TFTP_callBackTable, the storage can be in EEPROM, Flash, etc.
address |
Destination address where the data has to be stored (EEPROM, Flash, etc.) |
*data |
Actual data in the packet to be programmed |
length |
Packet length, number of bytes to be programmed |
None. |
TFTP_Ack()
void TFTP_Ack (uint8_t opcode)
Sends an acknowledgement on receiving a packet from a TFTP Server.
opcode |
Packet opcode |
None. |
TFTP_Configure()
void TFTP_Configure (uint32_t tftp_server_address, char * tftp_filename, char * tftp_block_size)
Allows the user to configure the TFTP server options.
tftp_server_address |
TFTP server address |
*tftp_filename |
Name of the file to be read from the TFTP server |
*tftp_block_size |
Size of each packet in bytes sent by the TFTP server |
None. |
TFTP_Handler()
void TFTP_Handler (int16_t length)
Processes a TFTP message as per the opcode in the packet.
length |
Packet length |
None. |
TFTP_Read_Write_Request()
error_msg TFTP_Read_Write_Request (uint8_t opcode)
Sends a read or write request to the TFTP server depending on the opcode.
opcode |
Packet opcode |
Status of the read/write request. Refer to the error description in tcpip_types.h. |
2.9.2.9.3 Enumeration Type Documentation
tftp_client_state
enum tftp_client_state
TFTP Client state.
tftp_read | |
tftp_write | |
tftp_data | |
tftp_ack | |
tftp_error | |
tftp_optack |
tftp_opcode
enum tftp_opcode
TFTP opcode.
TFTP_READ_REQUEST | |
TFTP_WRITE_REQUEST | |
TFTP_DATA | |
TFTP_ACK | |
TFTP_ERROR | |
TFTP_OPTACK |
2.9.2.9.4 Variable Documentation
store_type
store_type = 0
Default storage type for TFTP handler is 0.
2.9.2.10 UDP
This file provides the API implementation for UDP v4.
2.9.2.10.1 Module description
This file provides the API implementation for UDP v4.
Data structures
struct udp_handler_t
UDP handler types.
Functions
error_msg UDP_Start (uint32_t destIP, uint16_t srcPort, uint16_t dstPort)
Starts a UDP packet.
-
Sends a UDP packet.
error_msg UDP_Receive (uint16_t udpcksm)
Catches all UDP packets and dispatches them to the appropriate callback.
udp_table_iterator_t udp_table_getIterator (void)
Returns the UDP table iterator.
udp_table_iterator_t udp_table_nextEntry (udp_table_iterator_t i)
Returns the UDP table next entry.
2.9.2.10.2 Function Documentation
UDP_Receive()
error_msg UDP_Receive (uint16_t udpcksm)
Catches all UDP packets and dispatches them to the appropriate callback.
udpcksm |
UDP Checksum |
Error status. Refer to the error description in tcpip_types.h. |
UDP_Send()
error_msg UDP_Send (void )
Sends a UDP packet.
None. |
Error status. Refer to the error description in tcpip_types.h. |
UDP_Start()
error_msg UDP_Start (uint32_t destIP, uint16_t srcPort, uint16_t dstPort)
Starts a UDP packet.
destIP |
Destination IP address |
srcPort |
Source port |
dstPort |
Destination port |
Error status. Refer to the error description in tcpip_types.h. |
udp_table_getIterator()
udp_table_iterator_t udp_table_getIterator (void )
Returns the UDP table iterator.
None. |
Pointer to UDP_CallBackTable. |
udp_table_nextEntry()
udp_table_iterator_t udp_table_nextEntry (udp_table_iterator_t i)
Returns the UDP table next entry.
i |
UDP table iteration |
Pointer to UDP_CallBackTable. |
2.9.3 Class Documentation
2.9.3.1 arpHeader_t Struct Reference
Contains the ARP information.
2.9.3.1.1 Detailed Description
Contains the ARP information.
Public Attributes
2.9.3.1.2 Member Data Documentation
hlen
uint8_t hlen
Hardware Address Length
htype
uint16_t htype
Hardware Type
oper
uint16_t oper
Operation
plen
uint8_t plen
Protocol Address Length
ptype
uint16_t ptype
Protocol Type
sha
mac48Address_t sha
Sender Hardware Address
spa
uint32_t spa
Sender Protocol Address
tha
mac48Address_t tha
Target Hardware Address
tpa
uint32_t tpa
Target Protocol Address
2.9.3.2 arpMap_t Struct Reference
Contains the ARP database.
2.9.3.2.1 Detailed Description
Contains the ARP database.
Public Attributes
mac48Address_t macAddress
uint32_t ipAddress
uint16_t protocolType
uint8_t age
2.9.3.2.2 Member Data Documentation
age
uint8_t age
Replace oldest entry with new data as required.
ipAddress
uint32_t ipAddress
IP address
macAddress
mac48Address_t macAddress
MAC address
protocolType
uint16_t protocolType
Protocol type
2.9.3.3 createBasicTLV_t Struct Reference
Creates a basic Type-Length-Value (TLV).
2.9.3.3.1 Detailed Description
Creates a basic Type-Length-Value (TLV).
#include <lldp.h>
Public Attributes
uint8_t tlvOrder
uint8_t type
uint8_t subtype
uint16_t buffLength
2.9.3.3.2 Member Data Documentation
buffLength
uint16_t buffLength
callTlvMaker
createBasicFuncPtr callTlvMaker
subtype
uint8_t subtype
tlvOrder
uint8_t tlvOrder
type
uint8_t type
2.9.3.4 createOrgTLV_t Struct Reference
Creates Organizationally Specific TLV.
2.9.3.4.1 Detailed Description
Creates Organizationally Specific TLV.
#include <lldp.h>
Public Attributes
uint8_t tlvOrder
uint8_t type
uint16_t buffLength
uint32_t OUI
2.9.3.4.2 Member Data Documentation
buffLength
uint16_t buffLength
callTlvMaker
createOrgFuncPtr callTlvMaker
OUI
uint32_t OUI
Organizationally Unique Identifier
tlvOrder
uint8_t tlvOrder
type
uint8_t type
2.9.3.5 destIP_t Struct Reference
#include <tcpip_types.h>
2.9.3.5.1 Public Attributes
2.9.3.5.2 Member Data Documentation
dest_addr
inAddr_t dest_addr
2.9.3.6 dhcp_data_t Struct Reference
Contains option data.
2.9.3.6.1 Detailed Description
Contains option data.
Public Attributes
uint32_t dhcpIPAddress
uint32_t subnetMask
uint32_t routerAddress
uint32_t dnsAddress [2]
uint32_t ntpAddress [2]
uint32_t gatewayAddress
uint32_t xidValue
uint32_t t1
uint32_t t2
uint32_t dhcpServerIdentifier
2.9.3.6.2 Member Data Documentation
dhcpIPAddress
uint32_t dhcpIPAddress
DHCP IP address
dhcpServerIdentifier
uint32_t dhcpServerIdentifier
DHCP Server ID
dnsAddress
uint32_t dnsAddress[2]
Captures only two DNS addresses
gatewayAddress
uint32_t gatewayAddress
x ID value
ntpAddress
uint32_t ntpAddress[2]
Captures only two DNS addresses
routerAddress
uint32_t routerAddress
Router address
subnetMask
uint32_t subnetMask
Subnet mask
t1
uint32_t t1
Name as per the RFC, page 35
t2
uint32_t t2
Name as per the RFC, page 35
xidValue
uint32_t xidValue
x ID value
2.9.3.7 dhcp_state_t Struct Reference
Contains state data.
2.9.3.7.1 Detailed Description
Contains state data.
Public Attributes
2.9.3.7.2 Member Data Documentation
rxClientState
dhcp_rx_client_state rxClientState
tmrClientState
dhcp_timer_client_state tmrClientState
2.9.3.8 dns_map_t Struct Reference
2.9.3.8.1 Public Attributes
const char * dnsName
uint32_t ipAddress
uint32_t ttl
bool isValid
time_t birthSecond
2.9.3.8.2 Member Data Documentation
birthSecond
time_t birthSecond
dnsName
const char* dnsName
ipAddress
uint32_t ipAddress
isValid
bool isValid
ttl
uint32_t ttl
2.9.3.9 ethernetFrame_t Struct Reference
Ethernet frame information.
2.9.3.9.1 Detailed Description
Ethernet frame information.
#include <tcpip_types.h>
Public Attributes
2.9.3.9.2 Member Data Documentation
destinationMAC
uint8_t destinationMAC[6]
id
union { ... } id
length
uint16_t length
sourceMAC
uint8_t sourceMAC[6]
tpid
uint16_t tpid
type
uint16_t type
Ethernet 2 frame type, 802.3 length, 802.1Q TPID
2.9.3.10 icmpHeader_t Struct Reference
ICMP header information.
2.9.3.10.1 Detailed Description
ICMP header information.
#include <tcpip_types.h>
Public Attributes
2.9.3.10.2 Member Data Documentation
@4
union { ... }
checksum
uint16_t checksum
code
uint8_t code
type
uint8_t type
typeCode
uint16_t typeCode
2.9.3.11 inAddr_t Struct Reference
INET address.
2.9.3.11.1 Detailed Description
INET address.
#include <tcpip_types.h>
Public Attributes
union {
uint32_t s_addr
uint8_t s_addr_byte [4]
};
2.9.3.11.2 Member Data Documentation
@16
union { ... }
s_addr
uint32_t s_addr
s_addr_byte
uint8_t s_addr_byte[4]
2.9.3.12 ip_db_info_t Struct Reference
Contains IP information.
2.9.3.12.1 Detailed Description
Contains IP information.
#include <ip_database.h>
Public Attributes
uint32_t ipv4_myAddress
uint32_t ipv4_subnetMask
uint32_t ipv4_router
uint32_t ipv4_gateway
uint32_t ipv4_ntpAddress [MAX_NTP]
uint32_t ipv4_tftpAddress
2.9.3.12.2 Member Data Documentation
ipv4_dns
uint32_t ipv4_dns[MAX_DNS]
Primary & secondary DNS addresses
ipv4_gateway
uint32_t ipv4_gateway
Gateway address
ipv4_myAddress
uint32_t ipv4_myAddress
IP address
ipv4_ntpAddress
uint32_t ipv4_ntpAddress[MAX_NTP]
NTP addresses
ipv4_router
uint32_t ipv4_router
Router address
ipv4_subnetMask
uint32_t ipv4_subnetMask
Subnet mask
ipv4_tftpAddress
uint32_t ipv4_tftpAddress
TFTP address
2.9.3.13 ipv4_pseudo_header_t Struct Reference
Pseudo header used for checksum calculation on UDP and TCP.
2.9.3.13.1 Detailed Description
Pseudo header used for checksum calculation on UDP and TCP.
#include <tcpip_types.h>
Public Attributes
uint32_t srcIpAddress
uint32_t dstIpAddress
uint8_t protocol
uint8_t z
uint16_t length
2.9.3.13.2 Member Data Documentation
dstIpAddress
uint32_t dstIpAddress
Destination IP Address
length
uint16_t length
Length
protocol
uint8_t protocol
Protocol
srcIpAddress
uint32_t srcIpAddress
Source IP Address
z
uint8_t z
Used for memory cleaning
2.9.3.14 ipv4Header_t Struct Reference
IPv4 header information.
2.9.3.14.1 Detailed Description
IPv4 header information.
#include <tcpip_types.h>
Public Attributes
unsigned ihl: 4
unsigned version: 4
unsigned ecn: 2
unsigned dscp: 6
uint16_t length
uint16_t identifcation
unsigned fragmentOffsetHigh: 5
unsigned __pad0__: 1
unsigned dontFragment: 1
unsigned moreFragments: 1
uint8_t fragmentOffsetLow
uint8_t timeToLive
uint8_t protocol
uint16_t headerCksm
uint32_t srcIpAddress
uint32_t dstIpAddress
2.9.3.14.2 Member Data Documentation
__pad0__
unsigned __pad0__
Leave this bit as zero
dontFragment
unsigned dontFragment
Drop if fragmentation is required to route
dscp
unsigned dscp
Differentiated Service Code Point RFC3260
dstIpAddress
uint32_t dstIpAddress
Destination IP Address
ecn
unsigned ecn
Explicit Congestion Notification RFC3168
fragmentOffsetHigh
unsigned fragmentOffsetHigh
Offset for a fragment, needed for reassembly
fragmentOffsetLow
uint8_t fragmentOffsetLow
Low byte for the fragment offset
headerCksm
uint16_t headerCksm
RFC1071 defines this calculation
identifcation
uint16_t identifcation
ID for packet fragments
ihl
unsigned ihl
Internet header length in 32-bit words
length
uint16_t length
Total length including header and data (no more than 576 octets)
moreFragments
unsigned moreFragments
Fragments have this bit set (except for the final packet)
protocol
uint8_t protocol
IP Protocol (from RFC790)
srcIpAddress
uint32_t srcIpAddress
Source IP Address
timeToLive
uint8_t timeToLive
Decrement at each hop and discard when zero
version
unsigned version
4 for IPV4
2.9.3.15 lldp_per_port_t Struct Reference
LLDP per port.
2.9.3.15.1 Detailed Description
LLDP per port.
Public Attributes
uint8_t source_mac [6]
uint8_t source_ipaddr [4]
bool newNeighbor
bool portEnabled
uint8_t adminStatus
uint16_t allocatedPower
uint16_t desiredPower
2.9.3.15.2 Member Data Documentation
adminStatus
uint8_t adminStatus
IEEE 802.1AB 9.2.5.1
allocatedPower
uint16_t allocatedPower
desiredPower
uint16_t desiredPower
newNeighbor
bool newNeighbor
portEnabled
bool portEnabled
IEEE 802.1AB 9.2.4.1
rx
lldp_rx_port_t rx
source_ipaddr
uint8_t source_ipaddr[4]
source_mac
uint8_t source_mac[6]
tx
lldp_tx_port_t tx
2.9.3.16 lldp_rx_port_t Struct Reference
Per-interface structure for RX, part of lldp_port.
2.9.3.16.1 Detailed Description
Per-interface structure for RX, part of lldp_port.
Public Attributes
2.9.3.16.2 Member Data Documentation
badFrame
bool badFrame
rcvFrame
bool rcvFrame
state
uint8_t state
2.9.3.17 lldp_tx_port_t Struct Reference
Per-interface structure for TX, part of lldp_port.
2.9.3.17.1 Detailed Description
Per-interface structure for TX, part of lldp_port.
Public Attributes
2.9.3.17.2 Member Data Documentation
localChange
bool localChange
IEEE 802.1AB var
state
uint8_t state
The TX state for this interface
timers
lldp_tx_timers_t timers
LLDP TX state machine timers for this interface
txCredit
uint8_t txCredit
IEEE 802.1AB 9.2.5.16
txFast
uint8_t txFast
IEEE 802.1AB 9.2.5.18
txNow
bool txNow
IEEE 802.1AB 9.2.5.20
txTTL
uint16_t txTTL
IEEE 802.1AB var
2.9.3.18 lldp_tx_timers_t Struct Reference
LLDP TX timers.
2.9.3.18.1 Detailed Description
LLDP TX timers.
#include <lldp.h>
Public Attributes
uint16_t txDelay
uint16_t txTTR
uint16_t txShutdownWhile
uint16_t txDelayWhile
bool txTick
2.9.3.18.2 Member Data Documentation
txDelay
uint16_t txDelay
IEEE 802.1AB 10.5.3
txDelayWhile
uint16_t txDelayWhile
txShutdownWhile
uint16_t txShutdownWhile
IEEE 802.1AB 9.2.2.3
txTick
bool txTick
IEEE 802.1AB 9.2.5.21
txTTR
uint16_t txTTR
IEEE 802.1AB 9.2.2.3 Transmit on expire
2.9.3.19 logFields_t Struct Reference
Log fields.
2.9.3.19.1 Detailed Description
Log fields.
#include <log.h>
Public Attributes
2.9.3.19.2 Member Data Documentation
logFacility
LOG_FACILITY logFacility
severityThreshold
LOG_SEVERITY severityThreshold
2.9.3.20 orgProcessFlags Union Reference
Process flags.
2.9.3.20.1 Detailed Description
Process flags.
#include <lldp.h>
Public Attributes
uint8_t val
struct {
unsigned fixTlvSize:1
unsigned poeEnabledPair:1
unsigned uPoeEnabledPower:1
unsigned poePlusEnabledPower:1
unsigned poeEnabledMinPower:1
unsigned is4WireSupported:1
unsigned PD_requestSparePairOn:1
unsigned __pad0__:1
};
2.9.3.20.2 Member Data Documentation
@1
struct { ... }
__pad0__
unsigned __pad0__
fixTlvSize
unsigned fixTlvSize
is4WireSupported
unsigned is4WireSupported
Switch capabilities - RO for all practical purposes
PD_requestSparePairOn
unsigned PD_requestSparePairOn
Only if the desired power is more than 25.5w and 4-wire supported
poeEnabledMinPower
unsigned poeEnabledMinPower
poeEnabledPair
unsigned poeEnabledPair
poePlusEnabledPower
unsigned poePlusEnabledPower
uPoeEnabledPower
unsigned uPoeEnabledPower
val
uint8_t val
2.9.3.21 orgSpecificTLVs_t Struct Reference
Initializes the Organizationally Specific TLV.
2.9.3.21.1 Detailed Description
Initializes the Organizationally Specific TLV.
#include <lldp.h>
Public Attributes
2.9.3.21.2 Member Data Documentation
oui
uint32_t oui
processOrgTlvs
OrgFuncPtr processOrgTlvs
subtype
uint8_t subtype
2.9.3.22 sockaddr_in4_t Struct Reference
INET4 socket address.
2.9.3.22.1 Detailed Description
INET4 socket address.
#include <tcpip_types.h>
Public Attributes
2.9.3.22.2 Member Data Documentation
addr
inAddr_t addr
port
uint16_t port
2.9.3.23 store_handler_t Struct Reference
Storage handler.
2.9.3.23.1 Detailed Description
Storage handler.
#include <tftp_handler_table.h>
Public Attributes
2.9.3.23.2 Member Data Documentation
The documentation for this struct was generated from the following file:
source/
storeNumber
uint16_t storeNumber
TFTP_CallBack
TFTP_receive_function_ptr TFTP_CallBack
2.9.3.24 tcpHeader_t Struct Reference
TCP header information.
2.9.3.24.1 Detailed Description
TCP header information.
#include <tcpip_types.h>
Public Attributes
uint16_t sourcePort
uint16_t destPort
uint32_t sequenceNumber
uint32_t ackNumber
union {
uint8_t byte13
struct {
uint8_t ns: 1
uint8_t reserved: 3
uint8_t dataOffset: 4
}
};
union {
};
uint16_t windowSize
uint16_t checksum
uint16_t urgentPtr
2.9.3.24.2 Member Data Documentation
@10
union { ... }
@8
union { ... }
ack
uint8_t ack
Indicates that the ACKfield is significant.
ackNumber
uint32_t ackNumber
ACK Number
byte13
uint8_t byte13
checksum
uint16_t checksum
TCP Header Checksum.
cwr
uint8_t cwr
Congestion Window Reduced (CWR) (added to header by RFC 3168).
dataOffset
uint8_t dataOffset
Specifies the size of the TCP header in 32-bit words.
destPort
uint16_t destPort
Destination port
ece
uint8_t ece
ECN-Echo. Depends on SYN flag set or clear.
fin
uint8_t fin
No more data from sender.
flags
uint8_t flags
Flags
ns
uint8_t ns
ECN-nonce concealment protection (added to header by RFC 3540).
psh
uint8_t psh
Asks to push the buffered data to the receiving application.
reserved
uint8_t reserved
For future use and needs to be set to zero.
rst
uint8_t rst
Resets the connection.
sequenceNumber
uint32_t sequenceNumber
Sequence number
sourcePort
uint16_t sourcePort
Source port
syn
uint8_t syn
Synchronizes sequence numbers. Only the first packet sent from each end must have this flag set.
urg
uint8_t urg
Indicates that the Urgent pointer field is significant.
urgentPtr
uint16_t urgentPtr
Urgent pointer.
windowSize
uint16_t windowSize
Window size.
2.9.3.25 tcpSocket_t Struct Reference
#include <tcpv4.h>
2.9.3.25.1 Public Attributes
uint32_t localIP
uint16_t localPort
uint32_t remoteIP
uint16_t remotePort
2.9.3.25.2 Member Data Documentation
localIP
uint32_t localIP
localPort
uint16_t localPort
remoteIP
uint32_t remoteIP
remotePort
uint16_t remotePort
2.9.3.26 tcpTCB_t Struct Reference
Defines TCP Transmission Control Block.
2.9.3.26.1 Detailed Description
Defines TCP Transmission Control Block.
#include <tcpv4.h>
Public Attributes
uint16_t localPort
uint32_t destIP
uint16_t destPort
uint32_t remoteSeqno
uint32_t remoteAck
uint32_t localSeqno
uint32_t localLastAck
uint16_t remoteWnd
uint16_t localWnd
uint16_t mss
uint8_t * rxBufferStart
uint8_t * rxBufferPtr
uint8_t * txBufferStart
uint8_t * txBufferPtr
uint16_t bytesToSend
uint16_t bytesSent
bool payloadSave
void * nextTCB
void * prevTCB
uint16_t timeout
uint16_t timeoutReloadValue
uint8_t timeoutsCount
uint8_t flags
2.9.3.26.2 Member Data Documentation
bytesSent
uint16_t bytesSent
bytesToSend
uint16_t bytesToSend
connectionEvent
tcpEvent_t connectionEvent
destIP
uint32_t destIP
destPort
uint16_t destPort
flags
uint8_t flags
Save the flags to be used for time-outs
fsmState
tcp_fsm_states_t fsmState
Connection state
localLastAck
uint32_t localLastAck
Last ACK number received
localPort
uint16_t localPort
Local Port
localSeqno
uint32_t localSeqno
localWnd
uint16_t localWnd
Receiver window
mss
uint16_t mss
nextTCB
void* nextTCB
Downstream list pointer
payloadSave
bool payloadSave
prevTCB
void* prevTCB
Upstream list pointer
remoteAck
uint32_t remoteAck
Last ACK packet sent to remote
remoteSeqno
uint32_t remoteSeqno
remoteWnd
uint16_t remoteWnd
Sender window
rxBufferPtr
uint8_t* rxBufferPtr
Pointer to write inside the RX buffer
rxBufferStart
uint8_t* rxBufferStart
rxBufState
tcpBufferState_t rxBufState
socketState
socketState_t socketState
Socket states used in application
timeout
uint16_t timeout
Retransmission time-out in seconds
timeoutReloadValue
uint16_t timeoutReloadValue
timeoutsCount
uint8_t timeoutsCount
Number of retransmissions
txBufferPtr
uint8_t* txBufferPtr
txBufferStart
uint8_t* txBufferStart
txBufState
tcpBufferState_t txBufState
2.9.3.27 tftp_t Struct Reference
#include <tftp.h>
2.9.3.27.1 Public Attributes
uint32_t tftp_server_address
char tftp_block_size [5]
char tftp_filename [32]
2.9.3.27.2 Member Data Documentation
tftp_block_size
char tftp_block_size[5]
tftp_filename
char tftp_filename[32]
tftp_server_address
uint32_t tftp_server_address
2.9.3.28 udp_handler_t Struct Reference
UDP handler types.
2.9.3.28.1 Detailed Description
UDP handler types.
#include <udpv4_port_handler_table.h>
Public Attributes
uint16_t portNumber
2.9.3.28.2 Member Data Documentation
The documentation for this struct was generated from the following file:
source/
callBack
ip_receive_function_ptr callBack
portNumber
uint16_t portNumber
2.9.3.29 udpHeader_t Struct Reference
UDP header information.
2.9.3.29.1 Detailed Description
UDP header information.
#include <tcpip_types.h>
Public Attributes
2.9.3.29.2 Member Data Documentation
checksum
uint16_t checksum
Checksum
dstPort
uint16_t dstPort
Destination Port
length
uint16_t length
Length
srcPort
uint16_t srcPort
Source Port
2.9.4 File Documentation
2.9.4.1 source/arpv4.c File Reference
This file provides the API implementation for the Address Resolution Protocol (ARP) v4.
#include <stdio.h> #include <stdint.h> #include <stdbool.h> #include <string.h> #include "../tcpip_types.h" #include "../network.h" #include "../arpv4.h" #include "../../ethernet/physical_layer_interface.h" #include "../ipv4.h" #include "../tcpip_config.h" #include "../ip_database.h"
2.9.4.1.1 Data structures
struct arpHeader_t
Contains the ARP information.
struct arpMap_t
Contains the ARP database.
2.9.4.1.2 Functions
void ARPV4_Init (void)
Initializes the ARP table.
error_msg ARPV4_Packet (void)
Receives all ARP packets on the network and searches the ARP table for an existing ARP entry. If present, it updates the table. If the ARP packet is for the device and its operation is REQUEST, the function replies with the device MAC address.
void ARPV4_Update (void)
Updates the ARP table at least every 10s to avoid aging.
error_msg ARPV4_Request (uint32_t destAddress)
Sends the ARP Request.
mac48Address_t * ARPV4_Lookup (uint32_t ip_address)
Maintains an ARP table which maps hardware address to internet address.
2.9.4.1.3 Macros
#define ARP_REQUEST 1
#define ARP_REPLY 2
#define ARP_NAK 10
2.9.4.1.4 Variables
mac48Address_t hostMacAddress
2.9.4.1.5 Detailed Description
This file provides the API implementation for the Address Resolution Protocol (ARP) v4.
ARP v4 Implementation Source File
2.9.4.1.6 Macro Definition Documentation
ARP_NAK
#define ARP_NAK 10
ARP_REPLY
#define ARP_REPLY 2
ARP_REQUEST
#define ARP_REQUEST 1
2.9.4.1.7 Variable Documentation
arpMap
arpMap_t arpMap[ARP_MAP_SIZE]
hostMacAddress
mac48Address_t hostMacAddress
2.9.4.2 source/arpv4.h File Reference
#include "../ethernet/physical_layer_interface.h" #include "tcpip_config.h"
2.9.4.2.1 Functions
void ARPV4_Init (void)
Initializes the ARP table.
error_msg ARPV4_Packet (void)
Receives all ARP packets on the network and searches the ARP table for an existing ARP entry. If present, it updates the table. If the ARP packet is for the device and its operation is REQUEST, the function replies with the device MAC address.
void ARPV4_Update (void)
Updates the ARP table at least every 10s to avoid aging.
mac48Address_t * ARPV4_Lookup (uint32_t ipAddress)
Maintains an ARP table which maps hardware address to internet address.
error_msg ARPV4_Request (uint32_t destAddress)
Sends the ARP Request.
2.9.4.2.2 Detailed Description
ARPv4 Protocol Header file
2.9.4.3 source/dhcp_client.c File Reference
This file provides the API implementation for the DHCP client.
#include <stdio.h> #include <string.h> #include <time.h> #include <stdbool.h> #include <limits.h> #include "../log.h" #include "../../ethernet/physical_layer_interface.h" #include "../network.h" #include "../udpv4.h" #include "../udpv4_port_handler_table.h" #include "../ipv4.h" #include "../arpv4.h" #include "../dhcp_client.h" #include "../ip_database.h" #include "../lfsr.h"
2.9.4.3.1 Data structures
struct dhcp_data_t
Contains option data.
struct dhcp_state_t
Contains state data.
2.9.4.3.2 Functions
bool sendDHCPDISCOVER (void)
Sends the DHCP DISCOVER request.
bool sendDHCPREQUEST (void)
Sends the DHCP REQUEST request.
bool sendDHCPDECLINE (void)
Sends DHCP DECLINE request.
bool sendRequest (dhcp_type type)
Sends a DHCP request.
void DHCP_init (void)
Initializes the DHCP.
void DHCP_Manage (void)
Updates the DHCP status at least every one second.
void DHCP_Handler (int16_t length)
Receives and processes the DHCP packet.
void DHCP_WriteZeros (uint16_t length)
Writes zeroes for the number of bytes passed.
2.9.4.3.3 Macros
#define logMsg(msg, msgSeverity, msgLogDest)
#define DHCP_HEADER_SIZE 240
#define DHCP_REQUEST_LENGTH DHCP_PACKET_SIZE
2.9.4.3.4 Enumerations
enum dhcp_type { DHCP_DISCOVER = 1, DHCP_OFFER, DHCP_REQUEST, DHCP_DECLINE, DHCP_ACK, DHCP_NACK, DHCP_RELEASE, DHCP_INFORM, DHCP_FORCERENEW, DHCP_LEASEQUERY, DHCP_LEASEUNASSIGNED, DHCP_LEASEUNKNOWN, DHCP_LEASEACTIVE, DHCP_BULKLEASEQUERY, DHCP_LEASEQUERYDONE }
Contains DCHP request types.
enum dhcp_rx_client_state { SELECTING, REQUESTING, RENEWLEASE, BOUND }
Contains the DCHP RX Client state.
enum dhcp_timer_client_state { INIT_TIMER, WAITFORTIMER, STARTDISCOVER, STARTREQUEST }
Contains the DCHP Timer Client state.
2.9.4.3.5 Variables
static mac48Address_t ethMAC
dhcp_data_t dhcpData = {0,0,0,{0,0},{0,0},0,0,10,3600,0}
const char dhcpName [] = "PIC16F18857 Ethernet"
2.9.4.3.6 Detailed Description
This file provides the API implementation for the DHCP client.
DHCP v4 client Implementation Source File
2.9.4.3.7 Macro Definition Documentation
DHCP_HEADER_SIZE
#define DHCP_HEADER_SIZE 240
DHCP_REQUEST_LENGTH
#define DHCP_REQUEST_LENGTH DHCP_PACKET_SIZE
logMsg
#define logMsg( msg, msgSeverity, msgLogDest)
2.9.4.3.8 Variable Documentation
dhcpData
dhcp_data_t dhcpData = {0,0,0,{0,0},{0,0},0,0,10,3600,0}
dhcpName
const char dhcpName[] = "PIC16F18857 Ethernet"
dhcpState
dhcp_state_t dhcpState = {SELECTING,INIT_TIMER}
ethMAC
mac48Address_t ethMAC[static]
2.9.4.4 source/dhcp_client.h File Reference
#include "tcpip_types.h" #include "tcpip_config.h"
2.9.4.4.1 Functions
void DHCP_init (void)
Initializes the DHCP.
void DHCP_Handler (int16_t length)
Receives and processes the DHCP packet.
void DHCP_Manage (void)
Updates the DHCP status at least every one second.
void DHCP_WriteZeros (uint16_t length)
Writes zeroes for the number of bytes passed.
2.9.4.4.2 Detailed Description
DHCPv4 Client Protocol Header File
2.9.4.5 source/dns_client.c File Reference
This file provides the API implementation for the DNS client stack.
#include <stdlib.h> #include <stdint.h> #include <string.h> #include <stdio.h> #include <time.h> #include "../dns_client.h" #include "../udpv4.h" #include "../log.h" #include "../ip_database.h" #include "../lfsr.h"
2.9.4.5.1 Data structures
struct dns_map_t
2.9.4.5.2 Functions
static int generateSeed (void)
Generates the seed.
void DNS_Init (void)
Initializes the DNS table.
void DNS_Query (const char *str)
Searches the DNS server for the IPv4 (type A) addresses of the domain names.
void DNS_Handler (int16_t length)
Receives and processes the DNS packet.
void DNS_Update (void)
Updates the DNS table at least every 10s to avoid aging.
uint32_t DNS_Lookup (const char *dns_name)
Maintains the DNS table and maps Domain names to the Internet address.
2.9.4.5.3 Macros
#define logMsg(msg, msgSeverity, msgLogDest)
#define DNS_HEADER_SIZE 12
#define DNS_TYPE_SIZE 2
#define DNS_CLASS_SIZE 2
#define DNS_QUERY_SIZE (DNS_TYPE_SIZE + DNS_CLASS_SIZE)
#define DNS_PACKET_SIZE (DNS_HEADER_SIZE + DNS_QUERY_SIZE)
#define ARRAYSIZE(a) (sizeof(a) / sizeof(*(a)))
#define DNS_MAP_SIZE 8
2.9.4.5.4 Variables
uint16_t dnsXidValue
mac48Address_t ethMACdns
2.9.4.5.5 Detailed Description
This file provides the API implementation for the DNS client stack.
DNS client Implementation Source File
2.9.4.5.6 Macro Definition Documentation
ARRAYSIZE
#define ARRAYSIZE( a) (sizeof(a) / sizeof(*(a)))
DNS_CLASS_SIZE
#define DNS_CLASS_SIZE 2
DNS_HEADER_SIZE
#define DNS_HEADER_SIZE 12
DNS_MAP_SIZE
#define DNS_MAP_SIZE 8
DNS_PACKET_SIZE
#define DNS_PACKET_SIZE (DNS_HEADER_SIZE + DNS_QUERY_SIZE)
DNS_QUERY_SIZE
#define DNS_QUERY_SIZE (DNS_TYPE_SIZE + DNS_CLASS_SIZE)
DNS_TYPE_SIZE
#define DNS_TYPE_SIZE 2
logMsg
#define logMsg( msg, msgSeverity, msgLogDest)
2.9.4.5.7 Variable Documentation
dnsCache
dns_map_t dnsCache[DNS_MAP_SIZE]
dnsXidValue
uint16_t dnsXidValue
ethMACdns
mac48Address_t ethMACdns
2.9.4.6 source/dns_client.h File Reference
#include <stdint.h>
2.9.4.6.1 Functions
void DNS_Init (void)
Initializes the DNS table.
void DNS_Query (const char *str)
Searches the DNS server for the IPv4 (type A) addresses of the domain names.
void DNS_Handler (int16_t length)
Receives and processes the DNS packet.
uint32_t DNS_Lookup (const char *dns_name)
Maintains the DNS table and maps Domain names to the Internet address.
void DNS_Update (void)
Updates the DNS table at least every 10s to avoid aging.
2.9.4.6.2 Detailed Description
DNSv4 Client Protocol Header File
2.9.4.7 source/icmp.c File Reference
This file provides the API implementation for the Internet Control Message Protocol (ICMP).
#include <stdint.h> #include <stdio.h> #include <stddef.h> #include "../network.h" #include "../tcpip_types.h" #include "../../ethernet/physical_layer_interface.h" #include "../ipv4.h" #include "../icmp.h" #include "../ip_database.h"
2.9.4.7.1 Functions
error_msg ICMP_EchoReply (ipv4Header_t *ipv4Hdr)
Sends an Echo Reply packet to the destination.
error_msg ICMP_Receive (ipv4Header_t *ipv4Hdr)
Receives the ICMP packet. This function processes only Echo Request messages.
error_msg ICMP_PortUnreachable (uint32_t srcIPAddress, uint32_t destIPAddress, uint16_t length)
Sends Port Unreachable messages to the destination.
bool isPortUnreachable (uint16_t port)
Checks if the Port Unreachable flag is set to the port number of the application.
void resetPortUnreachable (void)
Resets the Port Unreachable flag to zero.
2.9.4.7.2 Variables
uint16_t portUnreachable = 0
2.9.4.7.3 Detailed Description
This file provides the API implementation for the Internet Control Message Protocol (ICMP).
ICMP protocol Implementation Source File
2.9.4.7.4 Variable Documentation
portUnreachable
uint16_t portUnreachable = 0
2.9.4.8 source/icmp.h File Reference
2.9.4.8.1 Functions
error_msg ICMP_Receive (ipv4Header_t *ipv4Hdr)
Receives the ICMP packet. This function processes only Echo Request messages.
error_msg ICMP_EchoReply (ipv4Header_t *ipv4Hdr)
Sends an Echo Reply packet to the destination.
error_msg ICMP_PortUnreachable (uint32_t srcIPAddress, uint32_t destIPAddress, uint16_t length)
Sends Port Unreachable messages to the destination.
bool isPortUnreachable (uint16_t port)
Checks if the Port Unreachable flag is set to the port number of the application.
void resetPortUnreachable (void)
Resets the Port Unreachable flag to zero.
2.9.4.8.2 Macros
#define DEST_UNREACHABLE_LEN 64
2.9.4.8.3 Detailed Description
ICMPv4 Protocol Header File
2.9.4.8.4 Macro Definition Documentation
DEST_UNREACHABLE_LEN
#define DEST_UNREACHABLE_LEN 64
2.9.4.9 source/ip_database.c File Reference
This file provides the API implementation for the IP database.
#include <stdint.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include "../ip_database.h"
2.9.4.9.1 Functions
void ipdb_init (void)
Initializes the IP database.
uint32_t makeStrToIpv4Address (char *str)
Converts a string into a 32-bit IPv4 address.
char * makeIpv4AddresstoStr (uint32_t addr)
Converts an IPv4 address into a string.
2.9.4.9.2 Variables
2.9.4.9.3 Detailed Description
This file provides the API implementation for the IP database.
IP Database Implementation Source File
2.9.4.9.4 Variable Documentation
ip_database_info
ip_db_info_t ip_database_info
2.9.4.10 source/ip_database.h File Reference
This file contains IP addresses for different operations.
2.9.4.10.1 Data structures
struct ip_db_info_t
Contains IP information.
2.9.4.10.2 Functions
void ipdb_init (void)
Initializes the IP database.
uint32_t makeStrToIpv4Address (char *str)
Converts a string into a 32-bit IPv4 address.
char * makeIpv4AddresstoStr (uint32_t addr)
Converts an IPv4 address into a string.
2.9.4.10.3 Macros
#define MAX_DNS 2
#define MAX_NTP 2
#define IPV4_ZERO_ADDRESS 0
#define SPECIAL_IPV4_BROADCAST_ADDRESS 0xFFFFFFFF
#define CLASS_A_IPV4_BROADCAST_MASK 0XFF000000
#define CLASS_B_IPV4_BROADCAST_MASK 0xFFFF0000
#define CLASS_C_IPV4_BROADCAST_MASK 0xFFFFFF00
#define ALL_HOST_MULTICAST_ADDRESS 0xE0000001
#define LOCAL_HOST_ADDRESS 0x7F000001
#define CLASS_A_IPV4_REVERSE_BROADCAST_MASK 0x00FFFFFF
#define CLASS_B_IPV4_REVERSE_BROADCAST_MASK 0x0000FFFF
#define CLASS_C_IPV4_REVERSE_BROADCAST_MASK 0X000000FF
#define ipdb_getAddress() (ip_database_info.ipv4_myAddress)
#define ipdb_getDNS(x) (x < MAX_DNS ? ip_database_info.ipv4_dns[x] : ip_database_info.ipv4_dns[0])
#define ipdb_getSubNetMASK() (ip_database_info.ipv4_subnetMask)
#define ipdb_getRouter() (ip_database_info.ipv4_router)
#define ipdb_getNTP(x) (x < MAX_NTP ? ip_database_info.ipv4_ntpAddress[x] : ip_database_info.ipv4_ntpAddress[0])
#define ipdb_getTFTP() (ip_database_info.ipv4_tftpAddress)
#define ipdb_classAbroadcastAddress() (ip_database_info.ipv4_myAddress|CLASS_A_IPV4_REVERSE_BROADCAST_MASK)
#define ipdb_classBbroadcastAddress() (ip_database_info.ipv4_myAddress|CLASS_B_IPV4_REVERSE_BROADCAST_MASK)
#define ipdb_classCbroadcastAddress() (ip_database_info.ipv4_myAddress|CLASS_C_IPV4_REVERSE_BROADCAST_MASK)
#define ipdb_specialbroadcastAddress() SPECIAL_IPV4_BROADCAST_ADDRESS
#define ipdb_setAddress(a) do{ ip_database_info.ipv4_myAddress = a; } while(0)
#define ipdb_setDNS(x, v) do{ if(x < MAX_DNS) ip_database_info.ipv4_dns[x] = v; } while(0)
#define ipdb_setSubNetMASK(m) do{ ip_database_info.ipv4_subnetMask = m; } while(0)
#define ipdb_setRouter(r) do{ ip_database_info.ipv4_router = r; } while(0)
#define ipdb_setGateway(g) do{ ip_database_info.ipv4_gateway = g; } while(0)
#define ipdb_setNTP(x, n) do{ if(x < MAX_NTP) ip_database_info.ipv4_ntpAddress[x] = n; } while(0)
#define ipdb_setTFTP(a) do{ ip_database_info.ipv4_tftpAddress = a; } while(0)
2.9.4.10.4 Variables
2.9.4.10.5 Detailed Description
This file contains IP addresses for different operations.
IP Database Header File
2.9.4.10.6 Macro Definition Documentation
ALL_HOST_MULTICAST_ADDRESS
#define ALL_HOST_MULTICAST_ADDRESS 0xE0000001
CLASS_A_IPV4_BROADCAST_MASK
#define CLASS_A_IPV4_BROADCAST_MASK 0XFF000000
CLASS_A_IPV4_REVERSE_BROADCAST_MASK
#define CLASS_A_IPV4_REVERSE_BROADCAST_MASK 0x00FFFFFF
CLASS_B_IPV4_BROADCAST_MASK
#define CLASS_B_IPV4_BROADCAST_MASK 0xFFFF0000
CLASS_B_IPV4_REVERSE_BROADCAST_MASK
#define CLASS_B_IPV4_REVERSE_BROADCAST_MASK 0x0000FFFF
CLASS_C_IPV4_BROADCAST_MASK
#define CLASS_C_IPV4_BROADCAST_MASK 0xFFFFFF00
CLASS_C_IPV4_REVERSE_BROADCAST_MASK
#define CLASS_C_IPV4_REVERSE_BROADCAST_MASK 0X000000FF
ipdb_classAbroadcastAddress
#define ipdb_classAbroadcastAddress( ) (ip_database_info.ipv4_myAddress|CLASS_A_IPV4_REVERSE_BROADCAST_MASK)
ipdb_classBbroadcastAddress
#define ipdb_classBbroadcastAddress( ) (ip_database_info.ipv4_myAddress|CLASS_B_IPV4_REVERSE_BROADCAST_MASK)
ipdb_classCbroadcastAddress
#define ipdb_classCbroadcastAddress( ) (ip_database_info.ipv4_myAddress|CLASS_C_IPV4_REVERSE_BROADCAST_MASK)
ipdb_getAddress
#define ipdb_getAddress( ) (ip_database_info.ipv4_myAddress)
ipdb_getDNS
#define ipdb_getDNS( x) (x < MAX_DNS ? ip_database_info.ipv4_dns[x] : ip_database_info.ipv4_dns[0])
ipdb_getNTP
#define ipdb_getNTP( x) (x < MAX_NTP ? ip_database_info.ipv4_ntpAddress[x] : ip_database_info.ipv4_ntpAddress[0])
ipdb_getRouter
#define ipdb_getRouter( ) (ip_database_info.ipv4_router)
ipdb_getSubNetMASK
#define ipdb_getSubNetMASK( ) (ip_database_info.ipv4_subnetMask)
ipdb_getTFTP
#define ipdb_getTFTP( ) (ip_database_info.ipv4_tftpAddress)
ipdb_setAddress
#define ipdb_setAddress( a) do{ ip_database_info.ipv4_myAddress = a; } while(0)
ipdb_setDNS
#define ipdb_setDNS( x, v) do{ if(x < MAX_DNS) ip_database_info.ipv4_dns[x] = v; } while(0)
ipdb_setGateway
#define ipdb_setGateway( g) do{ ip_database_info.ipv4_gateway = g; } while(0)
ipdb_setNTP
#define ipdb_setNTP( x, n) do{ if(x < MAX_NTP) ip_database_info.ipv4_ntpAddress[x] = n; } while(0)
ipdb_setRouter
#define ipdb_setRouter( r) do{ ip_database_info.ipv4_router = r; } while(0)
ipdb_setSubNetMASK
#define ipdb_setSubNetMASK( m) do{ ip_database_info.ipv4_subnetMask = m; } while(0)
ipdb_setTFTP
#define ipdb_setTFTP( a) do{ ip_database_info.ipv4_tftpAddress = a; } while(0)
ipdb_specialbroadcastAddress
#define ipdb_specialbroadcastAddress( ) SPECIAL_IPV4_BROADCAST_ADDRESS
IPV4_ZERO_ADDRESS
#define IPV4_ZERO_ADDRESS 0
LOCAL_HOST_ADDRESS
#define LOCAL_HOST_ADDRESS 0x7F000001
MAX_DNS
#define MAX_DNS 2
MAX_NTP
#define MAX_NTP 2
SPECIAL_IPV4_BROADCAST_ADDRESS
#define SPECIAL_IPV4_BROADCAST_ADDRESS 0xFFFFFFFF
2.9.4.10.7 Variable Documentation
ip_database_info
ip_db_info_t ip_database_info
2.9.4.11 source/ipv4.c File Reference
This file provides the API implementation for IPv4.
#include <stdint.h> #include <stdio.h> #include <stddef.h> #include "../network.h" #include "../ipv4.h" #include "../icmp.h" #include "../arpv4.h" #include "../udpv4.h" #include "../udpv4_port_handler_table.h" #include "../tcpv4.h" #include "../tcpip_types.h" #include "../../ethernet/physical_layer_interface.h" #include "../log.h" #include "../ip_database.h"
2.9.4.11.1 Functions
void TCP_Recv (uint32_t remoteAddress, uint16_t length)
Receives TCP packets.
static uint8_t getHeaderLen (void)
Returns the header length.
void IPV4_Init (void)
Initializes IPv4.
uint16_t IPV4_PseudoHeaderChecksum (uint16_t payloadLen)
Computes the pseudo-header checksum for transport layer protocols.
error_msg IPV4_Packet (void)
Receives the IPv4 packet. This function reads the IPv4 header and filters the upper layer protocols.
error_msg IPv4_Start (uint32_t dstAddress, ipProtocolNumbers protocol)
Starts the IPv4 packet. This routine starts the Ethernet packet and writes the IPv4 header. Initially Checksum and Payload length are set to '0'. An error code is returned if there has been an error in accepting, or if something goes wrong.
error_msg IPV4_Send (uint16_t payloadLength)
Sends the IPv4 packet. This function inserts the total length of IPv4 packet, computes and adds the Ipv4 header checksum.
uint16_t IPV4_GetDatagramLength (void)
Returns the length of the IPv4 datagram.
2.9.4.11.2 Macros
#define logMsg(msg, msgSeverity, msgLogDest)
2.9.4.11.3 Variables
uint32_t remoteIpv4Address
2.9.4.11.4 Detailed Description
This file provides the API implementation for IPv4.
IPv4 Implementation Source File
2.9.4.11.5 Function Documentation
IPV4_Init()
void IPV4_Init (void )
Initializes IPv4.
None. |
None. |
2.9.4.11.6 Macro Definition Documentation
logMsg
#define logMsg( msg, msgSeverity, msgLogDest)
2.9.4.11.7 Variable Documentation
ipv4Header
ipv4Header_t ipv4Header
remoteIpv4Address
uint32_t remoteIpv4Address
2.9.4.12 source/ipv4.h File Reference
#include <stdbool.h> #include "tcpip_types.h" #include "../ethernet/physical_layer_interface.h"
2.9.4.12.1 Functions
void IPV4_Init (void)
Initializes IPv4.
error_msg IPV4_Packet (void)
Receives the IPv4 packet. This function reads the IPv4 header and filters the upper layer protocols.
error_msg IPv4_Start (uint32_t dstAddress, ipProtocolNumbers protocol)
Starts the IPv4 packet. This routine starts the Ethernet packet and writes the IPv4 header. Initially Checksum and Payload length are set to '0'. An error code is returned if there has been an error in accepting, or if something goes wrong.
uint16_t IPV4_PseudoHeaderChecksum (uint16_t payloadLen)
Computes the pseudo-header checksum for transport layer protocols.
error_msg IPV4_Send (uint16_t payloadLength)
Sends the IPv4 packet. This function inserts the total length of IPv4 packet, computes and adds the Ipv4 header checksum.
uint16_t IPV4_GetDatagramLength (void)
Returns the length of the IPv4 datagram.
2.9.4.12.2 Detailed Description
IPv4 Protocol Header File
2.9.4.12.3 Function Documentation
IPV4_Init()
void IPV4_Init (void )
Initializes IPv4.
None. |
None. |
2.9.4.13 source/lfsr.c File Reference
This file provides the API prototypes for the Linear Feedback Shift Register (LFSR) module.
#include "../lfsr.h"
2.9.4.13.1 Functions
lfsr_t lfsr_getSequence (void)
Returns the LFSR sequence.
int lfsr_getSequenceCount (void)
Returns the LFSR sequence count.
void lfsr_reset (void)
Resets the LFSR.
void lfsr_setSequence (uint16_t s)
Sets the LFSR sequence.
-
Returns the LFSR value.
lfsr_t lfsrWithSeed (uint8_t lfsrSeed)
Returns the LFSR value with seed.
2.9.4.13.2 Macros
#define lfsr_seed 0x40
#define lfsrOutputMask 0x7fu
2.9.4.13.3 Variables
static uint8_t sequenceIndex = 0
const lfsr_t xorSequences [] = {0x41,0x44,0x47,0x48,0x4E,0x53,0x55,0x5C,0x5F,0x60,0x65,0x69,0x6A,0x72,0x77,0x78,0x7B,0x7E}
2.9.4.13.4 Detailed Description
This file provides the API prototypes for the Linear Feedback Shift Register (LFSR) module.
LFSR Implementation Source File
2.9.4.13.5 Function Documentation
lfsr()
lfsr_t lfsr (void )
Returns the LFSR value.
None. |
Value of LFSR. |
lfsr_getSequence()
lfsr_t lfsr_getSequence (void )
Returns the LFSR sequence.
None. |
Sequence. |
lfsr_getSequenceCount()
int lfsr_getSequenceCount (void )
Returns the LFSR sequence count.
None. |
Sequence count. |
lfsr_reset()
void lfsr_reset (void )
Resets the LFSR.
None. |
None. |
lfsr_setSequence()
void lfsr_setSequence (uint16_t s)
Sets the LFSR sequence.
s |
Sequence |
None. |
lfsrWithSeed()
lfsr_t lfsrWithSeed (uint8_t lfsrSeed)
Returns the LFSR value with seed.
lfsrSeed |
LFSR with seed |
Value of LFSR with seed. |
2.9.4.13.6 Macro Definition Documentation
lfsr_seed
#define lfsr_seed 0x40
lfsrOutputMask
#define lfsrOutputMask 0x7fu
2.9.4.13.7 Variable Documentation
lfsr_value
lfsr_t lfsr_value = lfsr_seed
sequenceIndex
uint8_t sequenceIndex = 0[static]
xor_mask
lfsr_t xor_mask = 0x41
xorSequences
const lfsr_t xorSequences[] = {0x41,0x44,0x47,0x48,0x4E,0x53,0x55,0x5C,0x5F,0x60,0x65,0x69,0x6A,0x72,0x77,0x78,0x7B,0x7E}
2.9.4.14 source/lfsr.h File Reference
This file provides the API implementation for the Linear Feedback Shift Register (LFSR).
#include <stdint.h>
2.9.4.14.1 Functions
int lfsr_getSequenceCount (void)
Returns the LFSR sequence count.
lfsr_t lfsr_getSequence (void)
Returns the LFSR sequence.
void lfsr_reset (void)
Resets the LFSR.
void lfsr_setSequence (uint16_t s)
Sets the LFSR sequence.
-
Returns the LFSR value.
lfsr_t lfsrWithSeed (uint8_t lfsrSeed)
Returns the LFSR value with seed.
2.9.4.14.2 Typedefs
typedef uint8_t lfsr_t
2.9.4.14.3 Detailed Description
This file provides the API implementation for the Linear Feedback Shift Register (LFSR).
lfsr API Header File
2.9.4.14.4 Function Documentation
lfsr()
lfsr_t lfsr (void )
Returns the LFSR value.
None. |
Value of LFSR. |
lfsr_getSequence()
lfsr_t lfsr_getSequence (void )
Returns the LFSR sequence.
None. |
Sequence. |
lfsr_getSequenceCount()
int lfsr_getSequenceCount (void )
Returns the LFSR sequence count.
None. |
Sequence count. |
lfsr_reset()
void lfsr_reset (void )
Resets the LFSR.
None. |
None. |
lfsr_setSequence()
void lfsr_setSequence (uint16_t s)
Sets the LFSR sequence.
s |
Sequence |
None. |
lfsrWithSeed()
lfsr_t lfsrWithSeed (uint8_t lfsrSeed)
Returns the LFSR value with seed.
lfsrSeed |
LFSR with seed |
Value of LFSR with seed. |
2.9.4.14.5 Typedef Documentation
lfsr_t
typedef uint8_t lfsr_t
2.9.4.15 source/lldp.c File Reference
This file provides the API implementation of LLDP.
#include <stdio.h> #include <stdint.h> #include <stdbool.h> #include <string.h> #include "../network.h" #include "../../ethernet/physical_layer_interface.h" #include "../log.h" #include "../lldp_tlv_handler_table.h" #include "../ipv4.h" #include "../ip_database.h"
2.9.4.15.1 Data structures
struct lldp_tx_port_t
Per-interface structure for TX, part of lldp_port.
struct lldp_rx_port_t
Per-interface structure for RX, part of lldp_port.
struct lldp_per_port_t
LLDP per port.
2.9.4.15.2 Functions
void txTimerInitializeLLDP (void)
void txTimerStateMachine (void)
void txStateMachine (void)
void rxStateMachine (void)
void txFrame (void)
void constrInfoLLDPDU (void)
uint8_t tl_tlvConstruct (uint8_t type, uint16_t length, uint8_t whichField)
bool buffFitCheck (uint16_t)
void chkBoundaryCase (void)
bool createEndTLV (void)
error_msg createOrgTLV (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg createBasicTLV (uint8_t type, uint8_t sub, uint16_t buffLen)
error_msg createOptionalTLV (uint8_t, uint8_t, uint16_t)
void rxProcessFrame (void)
void processMandatory (uint8_t tlvType, uint16_t tlvLength)
void processError (void)
bool processEnd (uint16_t tlvLength)
void processOptional (uint8_t tlvType, uint16_t tlvLength)
void processSpecific (uint16_t tlvLength)
static void swapEvenBytes (void *ptr, uint8_t len)
static error_msg setTheTLV (uint8_t sub, uint16_t buffLen, uint32_t orgOUI, char *val)
void LLDP_InitRx (void)
Initializes the LLDP RX.
void LLDP_InitTx (void)
Initializes the LLDP TX.
void LLDP_InitRxTx (void)
Initializes the LLDP RX and TX.
void LLDP_DecTTR (void)
Decreases the LLDP TX timer value.
MulticastMacAddr LLDP_SetDestAddress (void)
Sets the LLDP destination address.
void LLDP_SetDesiredPower (uint16_t pwr)
Sets the LLDP desired power.
uint16_t LLDP_GetAllocatedPower (void)
Gets the LLDP allocated power.
void LLDP_Run (void)
Runs the LLDP.
error_msg LLDP_createIeeeMDI (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createCiscoMDI (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createCiscoOUI (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createCiscoClass (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createCiscoProtocol (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createIeeeConfig (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createTiaMED_cap (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createTia_Net_pol (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createTia_PWR_MDI (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createTia_HW_Rev (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createTia_FW_Rev (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createTia_Srl_Num (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createTia_SW_Rev (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createTia_Manufacturer_Name (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createTia_Model_Name (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createTia_Asset_ID (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createCisco_MUD_Ext (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg createChassisTLV (uint8_t type, uint8_t sub, uint16_t buffLen)
error_msg createPortTLV (uint8_t type, uint8_t sub, uint16_t buffLen)
error_msg createTTLTLV (uint8_t type, uint8_t sub, uint16_t buffLen)
error_msg createPortDesc (uint8_t type, uint8_t sub, uint16_t buffLen)
error_msg createSysCap (uint8_t type, uint8_t sub, uint16_t buffLen)
error_msg createSystemDesc (uint8_t type, uint8_t sub, uint16_t buffLen)
error_msg createMgmtAddrTLV (uint8_t type, uint8_t sub, uint16_t buffLen)
void LLDP_Packet (void)
Processes LLDP packets.
error_msg processCiscoPowerTlv (uint8_t len, uint32_t oui, uint8_t orgSubtype)
error_msg processIEEE3PowerTlv (uint8_t len, uint32_t oui, uint8_t orgSubtype)
void LLDP_setPortDescription (const char *val)
Sets the LLDP port description.
char * LLDP_getPortDescription (void)
Gets the LLDP port description.
void LLDP_setHardwareRevision (const char *val)
Sets the LLDP hardware revision.
char * LLDP_getHardwareRevision (void)
Gets the LLDP hardware revision.
void LLDP_setFirmwareRevision (const char *val)
Sets the LLDP firmware revision.
char * LLDP_getFirmwareRevision (void)
Gets the LLDP firmware revision.
void LLDP_setSoftwareRevision (const char *val)
Sets the LLDP software revision.
char * LLDP_getSoftwareRevision (void)
Gets the LLDP software revision.
void LLDP_setSerialNumber (const char *val)
Sets the LLDP serial number.
char * LLDP_getSerialNumber (void)
Gets the LLDP serial number.
void LLDP_setManufacturer (const char *val)
Sets the LLDP manufacturer.
char * LLDP_getManufacturer (void)
Gets the LLDP manufacturer.
void LLDP_setModelName (const char *val)
Sets the LLDP module name.
char * LLDP_getModelName (void)
Gets the LLDP module name.
void LLDP_setAssetID (const char *val)
Sets the LLDP asset ID.
char * LLDP_getAssetID (void)
Gets the LLDP asset ID.
void LLDP_setMUDInfo (const char *val)
Sets the LLDP Manufacturer Usage Description (MUD) information.
2.9.4.15.3 Macros
#define ARRAYSIZE(a) (sizeof(a)/sizeof(*(a)))
#define ADMIN_STATUS_RX_MASK 0x02
#define ADMIN_STATUS_TX_MASK 0x01
#define logMsg(msg, msgSeverity, msgLogDest)
#define disableLLDP() do{lldp_port.adminStatus=(lldp_admin_status)disabled;}while(0)
#define enableLLDP_rx() do{lldp_port.adminStatus=(lldp_admin_status)enabledRxOnly;}while(0)
#define enableLLDP_tx() do{lldp_port.adminStatus=(lldp_admin_status)enabledTxOnly;}while(0)
#define enableLLDP_rx_tx() do{lldp_port.adminStatus=(lldp_admin_status)enabledRxTx;}while(0)
#define LLDP_rxEnabled() ((lldp_port.adminStatus & ADMIN_STATUS_RX_MASK) != 0)
#define LLDP_txEnabled() ((lldp_port.adminStatus & ADMIN_STATUS_TX_MASK) != 0)
#define LLDP_isDisabled() (lldp_port.adminStatus == 0)
#define typeField 1
#define lengthField 2
2.9.4.15.4 Enumerations
enum lldp_admin_status { disabled =0, enabledTxOnly = 1, enabledRxOnly = 2, enabledRxTx = 3 }
Contains the LLDP admin status.
enum lldp_txTimerStates_t { TX_TIMER_INITIALIZE, TX_TIMER_IDLE, TX_TIMER_EXPIRES, TX_TICK, SIGNAL_TX, TX_FAST_START }
LLDP TX Timer states.
enum lldp_txStates_t { TX_LLDP_INITIALIZE, TX_IDLE, TX_INFO_FRAME, TX_SHUTDOWN_FRAME }
LLDP TX states.
enum lldp_rxStates_t { LLDP_WAIT_PORT_OPERATIONAL, RX_LLDP_INITIALIZE, RX_WAIT_FOR_FRAME, RX_FRAME }
LLDP RX states.
2.9.4.15.5 Variables
const uint8_t AddressType = 1
uint8_t rxState
bool lldpdu_end
static const mac48Address_t genericMAC ={{0X01,0X80,0XC2,0X00,0X00,0X0E}}
uint8_t throughTimes
uint16_t txSizeCount
uint16_t totalSize
static orgProcessFlags orgProcFlags
const char PortDescription [] ="Vendor LED"
const char HardwareRevision [] ="Rev 1.0"
const char FirmwareRevision [] ="Rev 1.0"
const char SoftwareRevision [] ="Rev 1.0"
const char SerialNumber [] ="US-1234"
const char Manufacturer [] ="Vendor ID"
const char ModelName [] ="LED-Dimmable"
const char AssetID [] ="V1234"
const char MUDExt [] ="Add the mud info"
char * portdescription =NULL
char * hardwarerev =NULL
char * firmwarerev =NULL
char * softwarerev =NULL
char * serialnumber =NULL
char * manufacturer =NULL
char * modelname =NULL
char * assetID =NULL
char * mudext =NULL
char PortInterfaceName [7] ="Gi?/?"
lldp_tx_timers_t lldp_tx_timers = {0,0,0,0,0}
uint8_t txTimerState
2.9.4.15.6 Detailed Description
This file provides the API implementation of LLDP.
LLDP Implementation Source File
2.9.4.15.7 Function Documentation
buffFitCheck()
bool buffFitCheck (uint16_t )
chkBoundaryCase()
void chkBoundaryCase (void )
constrInfoLLDPDU()
void constrInfoLLDPDU (void )
createBasicTLV()
error_msg createBasicTLV (uint8_t type, uint8_t sub, uint16_t buffLen)
createChassisTLV()
error_msg createChassisTLV (uint8_t type, uint8_t sub, uint16_t buffLen)
createEndTLV()
bool createEndTLV (void )
createMgmtAddrTLV()
error_msg createMgmtAddrTLV (uint8_t type, uint8_t sub, uint16_t buffLen)
createOptionalTLV()
error_msg createOptionalTLV (uint8_t , uint8_t , uint16_t )
createOrgTLV()
error_msg createOrgTLV (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
createPortDesc()
error_msg createPortDesc (uint8_t type, uint8_t sub, uint16_t buffLen)
createPortTLV()
error_msg createPortTLV (uint8_t type, uint8_t sub, uint16_t buffLen)
createSysCap()
error_msg createSysCap (uint8_t type, uint8_t sub, uint16_t buffLen)
createSystemDesc()
error_msg createSystemDesc (uint8_t type, uint8_t sub, uint16_t buffLen)
createTTLTLV()
error_msg createTTLTLV (uint8_t type, uint8_t sub, uint16_t buffLen)
LLDP_createCisco_MUD_Ext()
error_msg LLDP_createCisco_MUD_Ext (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createCiscoClass()
error_msg LLDP_createCiscoClass (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createCiscoMDI()
error_msg LLDP_createCiscoMDI (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createCiscoOUI()
error_msg LLDP_createCiscoOUI (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createCiscoProtocol()
error_msg LLDP_createCiscoProtocol (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createIeeeConfig()
error_msg LLDP_createIeeeConfig (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createIeeeMDI()
error_msg LLDP_createIeeeMDI (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createTia_Asset_ID()
error_msg LLDP_createTia_Asset_ID (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createTia_FW_Rev()
error_msg LLDP_createTia_FW_Rev (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createTia_HW_Rev()
error_msg LLDP_createTia_HW_Rev (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createTia_Manufacturer_Name()
error_msg LLDP_createTia_Manufacturer_Name (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createTia_Model_Name()
error_msg LLDP_createTia_Model_Name (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createTia_Net_pol()
error_msg LLDP_createTia_Net_pol (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createTia_PWR_MDI()
error_msg LLDP_createTia_PWR_MDI (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createTia_Srl_Num()
error_msg LLDP_createTia_Srl_Num (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createTia_SW_Rev()
error_msg LLDP_createTia_SW_Rev (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createTiaMED_cap()
error_msg LLDP_createTiaMED_cap (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
processCiscoPowerTlv()
error_msg processCiscoPowerTlv (uint8_t len, uint32_t oui, uint8_t orgSubtype)
processEnd()
bool processEnd (uint16_t tlvLength)
processError()
void processError (void )
processIEEE3PowerTlv()
error_msg processIEEE3PowerTlv (uint8_t len, uint32_t oui, uint8_t orgSubtype)
processMandatory()
void processMandatory (uint8_t tlvType, uint16_t tlvLength)
processOptional()
void processOptional (uint8_t tlvType, uint16_t tlvLength)
processSpecific()
void processSpecific (uint16_t tlvLength)
rxProcessFrame()
void rxProcessFrame (void )
rxStateMachine()
void rxStateMachine (void )
setTheTLV()
static error_msg setTheTLV (uint8_t sub, uint16_t buffLen, uint32_t orgOUI, char * val)[static]
swapEvenBytes()
static void swapEvenBytes (void * ptr, uint8_t len)[static]
tl_tlvConstruct()
uint8_t tl_tlvConstruct (uint8_t type, uint16_t length, uint8_t whichField)
txFrame()
void txFrame (void )
txStateMachine()
void txStateMachine (void )
txTimerInitializeLLDP()
void txTimerInitializeLLDP (void )
txTimerStateMachine()
void txTimerStateMachine (void )
2.9.4.15.8 Macro Definition Documentation
ADMIN_STATUS_RX_MASK
#define ADMIN_STATUS_RX_MASK 0x02
ADMIN_STATUS_TX_MASK
#define ADMIN_STATUS_TX_MASK 0x01
ARRAYSIZE
#define ARRAYSIZE( a) (sizeof(a)/sizeof(*(a)))
disableLLDP
#define disableLLDP( ) do{lldp_port.adminStatus=(lldp_admin_status)disabled;}while(0)
enableLLDP_rx
#define enableLLDP_rx( ) do{lldp_port.adminStatus=(lldp_admin_status)enabledRxOnly;}while(0)
enableLLDP_rx_tx
#define enableLLDP_rx_tx( ) do{lldp_port.adminStatus=(lldp_admin_status)enabledRxTx;}while(0)
enableLLDP_tx
#define enableLLDP_tx( ) do{lldp_port.adminStatus=(lldp_admin_status)enabledTxOnly;}while(0)
lengthField
#define lengthField 2
LLDP_isDisabled
#define LLDP_isDisabled( ) (lldp_port.adminStatus == 0)
LLDP_rxEnabled
#define LLDP_rxEnabled( ) ((lldp_port.adminStatus & ADMIN_STATUS_RX_MASK) != 0)
LLDP_txEnabled
#define LLDP_txEnabled( ) ((lldp_port.adminStatus & ADMIN_STATUS_TX_MASK) != 0)
logMsg
#define logMsg( msg, msgSeverity, msgLogDest)
typeField
#define typeField 1
2.9.4.15.9 Variable Documentation
AddressType
const uint8_t AddressType = 1
assetID
char* assetID =NULL
AssetID
const char AssetID[] ="V1234"
firmwarerev
char* firmwarerev =NULL
FirmwareRevision
const char FirmwareRevision[] ="Rev 1.0"
genericMAC
const mac48Address_t genericMAC ={{0X01,0X80,0XC2,0X00,0X00,0X0E}}[static]
hardwarerev
char* hardwarerev =NULL
HardwareRevision
const char HardwareRevision[] ="Rev 1.0"
lldp_port
lldp_per_port_t lldp_port
lldp_tx_timers
lldp_tx_timers_t lldp_tx_timers = {0,0,0,0,0}
lldpdu_end
bool lldpdu_end
manufacturer
char* manufacturer =NULL
Manufacturer
const char Manufacturer[] ="Vendor ID"
modelname
char* modelname =NULL
ModelName
const char ModelName[] ="LED-Dimmable"
mudext
char* mudext =NULL
MUDExt
const char MUDExt[] ="Add the mud info"
orgProcFlags
orgProcessFlags orgProcFlags[static]
portdescription
char* portdescription =NULL
PortDescription
const char PortDescription[] ="Vendor LED"
PortInterfaceName
char PortInterfaceName[7] ="Gi?/?"
rxState
uint8_t rxState
serialnumber
char* serialnumber =NULL
SerialNumber
const char SerialNumber[] ="US-1234"
softwarerev
char* softwarerev =NULL
SoftwareRevision
const char SoftwareRevision[] ="Rev 1.0"
throughTimes
uint8_t throughTimes
totalSize
uint16_t totalSize
txSizeCount
uint16_t txSizeCount
txTimerState
uint8_t txTimerState
2.9.4.16 source/lldp.h File Reference
#include "tcpip_types.h" #include "../ethernet/physical_layer_interface.h"
2.9.4.16.1 Data structures
struct lldp_tx_timers_t
LLDP TX timers.
struct createBasicTLV_t
Creates a basic Type-Length-Value (TLV).
struct createOrgTLV_t
Creates Organizationally Specific TLV.
struct orgSpecificTLVs_t
Initializes the Organizationally Specific TLV.
union orgProcessFlags
Process flags.
2.9.4.16.2 Functions
void LLDP_Packet (void)
Processes LLDP packets.
2.9.4.16.3 Macros
#define MAX_TXBUFF_SIZE 1500
#define txCreditMax 5
#define msgTxHold 4
#define msgTxInterval 30u
#define msgFastTx 1u
#define txFastInit 4
#define reinitDelay 2
#define MulticastMacAddr mac48Address_t
#define PORTID mac48Address_t
#define setLLDPTick() do{lldp_tx_timers.txTick=true;}while(0)
#define clrLLDPTick() do{lldp_tx_timers.txTick=false;}while(0)
#define error
2.9.4.16.4 Typedefs
typedef error_msg(* createBasicFuncPtr) (uint8_t, uint8_t, uint16_t)
typedef error_msg(* createOrgFuncPtr) (uint8_t, uint16_t, uint32_t)
typedef error_msg(* OrgFuncPtr) (uint8_t, uint32_t, uint8_t)
2.9.4.16.5 Enumerations
enum TLV_TYPES { END_LLDPDU_TLV =0, CHASSIS_ID_TLV, PORT_ID_TLV, TIME_TO_LIVE_TLV, PORT_DESCRIPTION_TLV, SYSTEM_NAME_TLV, SYSTEM_DESCRIPTION_TLV, SYSTEM_CAPABILITIES_TLV, MANAGEMENT_ADDRESS_TLV, ORG_SPECIFIC_TLV =127 }
Mandatory and optional TLV types from IEEE 802.1AB.
enum CHASSIS_SUBTYPE { CHASSIS_COMPONENT =1, CHASSIS_INTERFACE_ALIAS, CHASSIS_PORT_COMPONENT, CHASSIS_MAC_ADDRESS, CHASSIS_NETWORK_ADDRESS, CHASSIS_INTERFACE_NAME, CHASSIS_LOCALLY_ASSIGNED }
TLV subtypes from section 9 of IEEE 802.1AB.
enum PORT_SUBTYPE { reserved, PORT_INTERFACE_ALIAS =1, PORT_COMPONENT, PORT_MAC_ADDRESS, PORT_NETWORK_ADDRESS, PORT_INTERFACE_NAME, PORT_AGENT_CIRCUIT_ID, PORT_LOCALLY_ASSIGNED }
TLV subtypes from section 9 of IEEE 802.1AB.
enum ORG_IEEE_3_SUBTYPE { res, IEEE_3_MAC_PHY_CONFIG =1, IEEE_3_POWER_VIA_MDI, IEEE_3_LINK_AGGREGATION, IEEE_3_MAX_FRAME_SIZE, IEEE_3_ENERGY_EFFICIENT_ETHERNET }
Organizationally Specific TLVs from section 79.3 of IEEE 802.3.
enum ORG_TIA_SUBTYPE { res1, TIA_LLDP_MED =1, TIA_NETWORK_POLICY, TIA_LOCATION_ID, TIA_EXTENDED_POWER_VIA_MDI, TIA_INVENT_HW_REV, TIA_INVENT_FW_REV, TIA_INVENT_SW_REV, TIA_INVENT_SERIAL_NUM, TIA_INVENT_MANUFACT_NAME, TIA_INVENT_MODEL_NAME, TIA_INVENT_ASSET_ID }
Organizationally Specific TLVs from section 10 of ANSI-TIA_1057.
enum ORG_CISCO_SUBTYPE { res2 =0, CISCO_POWER_VIA_MDI =1, CISCO_OUI_TLV, CISCO_CLASS_TLV, CISCO_PROTOCOL_TLV }
Organizationally Specific TLVs from section 79.3 of IEEE 802.3.
enum ORG_MUD_CISCO_SUBTYPE { res3 =0, CISCO_MUD_TLV =1 }
Organizationally Specific TLVs from section 79.3 of IEEE 802.3.
2.9.4.16.6 Variables
2.9.4.16.7 Detailed Description
LLDP Protocol Header File
2.9.4.16.8 Macro Definition Documentation
clrLLDPTick
#define clrLLDPTick( ) do{lldp_tx_timers.txTick=false;}while(0)
error
#define error
MAX_TXBUFF_SIZE
#define MAX_TXBUFF_SIZE 1500
msgFastTx
#define msgFastTx 1u
IEEE 802.1AB 9.2.5.5, defualt 1 if fast transmit is required
msgTxHold
#define msgTxHold 4
IEEE 802.1AB 10.5.1, default 4
msgTxInterval
#define msgTxInterval 30u
IEEE 802.1AB 10.5.1, default 30s
MulticastMacAddr
#define MulticastMacAddr mac48Address_t
PORTID
#define PORTID mac48Address_t
reinitDelay
#define reinitDelay 2
IEEE 802.1AB 9.2.5.10*, default 2s
setLLDPTick
#define setLLDPTick( ) do{lldp_tx_timers.txTick=true;}while(0)
txCreditMax
#define txCreditMax 5
IEEE 802.1AB 9.2.5.17, default 5
txFastInit
#define txFastInit 4
IEEE 802.1AB 9.2.5.19, default 4
2.9.4.16.9 Typedef Documentation
createBasicFuncPtr
typedef error_msg(* createBasicFuncPtr) (uint8_t, uint8_t, uint16_t)
createOrgFuncPtr
typedef error_msg(* createOrgFuncPtr) (uint8_t, uint16_t, uint32_t)
OrgFuncPtr
typedef error_msg(* OrgFuncPtr) (uint8_t, uint32_t, uint8_t)
2.9.4.16.10 Variable Documentation
lldp_tx_timers
lldp_tx_timers_t lldp_tx_timers
2.9.4.17 source/lldp_tlv_handler_table.c File Reference
This file provides the API implementation for the LLDP TLV handler table.
#include "../lldp_tlv_handler_table.h"
2.9.4.17.1 Functions
error_msg LLDP_createCiscoMDI (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createIeeeMDI (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createTiaMED_cap (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createTiaMED (uint8_t, uint16_t, uint32_t)
error_msg LLDP_createIeeeConfig (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createTia_Net_pol (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createTia_PWR_MDI (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createTia_HW_Rev (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createTia_FW_Rev (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createTia_SW_Rev (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createTia_Srl_Num (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createTia_Manufacturer_Name (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createTia_Model_Name (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createTia_Asset_ID (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createCisco_MUD_Ext (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createCiscoOUI (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createCiscoClass (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg LLDP_createCiscoProtocol (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
error_msg createChassisTLV (uint8_t type, uint8_t sub, uint16_t buffLen)
error_msg createPortTLV (uint8_t type, uint8_t sub, uint16_t buffLen)
error_msg createTTLTLV (uint8_t type, uint8_t sub, uint16_t buffLen)
error_msg createPortDesc (uint8_t type, uint8_t sub, uint16_t buffLen)
error_msg createSysCap (uint8_t type, uint8_t sub, uint16_t buffLen)
error_msg createSystemDesc (uint8_t type, uint8_t sub, uint16_t buffLen)
error_msg createMgmtAddrTLV (uint8_t type, uint8_t sub, uint16_t buffLen)
error_msg processCiscoPowerTlv (uint8_t len, uint32_t oui, uint8_t orgSubtype)
error_msg processIEEE3PowerTlv (uint8_t len, uint32_t oui, uint8_t orgSubtype)
uint8_t get_org_tlvs_table_size (void)
Gets the size of the table that stores Organizationally Specific TLVs.
2.9.4.17.2 Variables
bool independentSparedArchitecture = true
const createBasicTLV_t lldpCallFixedTlvTable [BASIC_TLVS_TABLE_SIZE]
const createOrgTLV_t lldpCallOrgSpecTlvTable []
const orgSpecificTLVs_t lldporgProcessingTlvTable [2]
2.9.4.17.3 Detailed Description
This file provides the API implementation for the LLDP TLV handler table.
LLDP protocol v4 Implementation Source File
2.9.4.17.4 Function Documentation
createChassisTLV()
error_msg createChassisTLV (uint8_t type, uint8_t sub, uint16_t buffLen)
createMgmtAddrTLV()
error_msg createMgmtAddrTLV (uint8_t type, uint8_t sub, uint16_t buffLen)
createPortDesc()
error_msg createPortDesc (uint8_t type, uint8_t sub, uint16_t buffLen)
createPortTLV()
error_msg createPortTLV (uint8_t type, uint8_t sub, uint16_t buffLen)
createSysCap()
error_msg createSysCap (uint8_t type, uint8_t sub, uint16_t buffLen)
createSystemDesc()
error_msg createSystemDesc (uint8_t type, uint8_t sub, uint16_t buffLen)
createTTLTLV()
error_msg createTTLTLV (uint8_t type, uint8_t sub, uint16_t buffLen)
LLDP_createCisco_MUD_Ext()
error_msg LLDP_createCisco_MUD_Ext (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createCiscoClass()
error_msg LLDP_createCiscoClass (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createCiscoMDI()
error_msg LLDP_createCiscoMDI (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createCiscoOUI()
error_msg LLDP_createCiscoOUI (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createCiscoProtocol()
error_msg LLDP_createCiscoProtocol (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createIeeeConfig()
error_msg LLDP_createIeeeConfig (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createIeeeMDI()
error_msg LLDP_createIeeeMDI (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createTia_Asset_ID()
error_msg LLDP_createTia_Asset_ID (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createTia_FW_Rev()
error_msg LLDP_createTia_FW_Rev (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createTia_HW_Rev()
error_msg LLDP_createTia_HW_Rev (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createTia_Manufacturer_Name()
error_msg LLDP_createTia_Manufacturer_Name (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createTia_Model_Name()
error_msg LLDP_createTia_Model_Name (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createTia_Net_pol()
error_msg LLDP_createTia_Net_pol (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createTia_PWR_MDI()
error_msg LLDP_createTia_PWR_MDI (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createTia_Srl_Num()
error_msg LLDP_createTia_Srl_Num (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createTia_SW_Rev()
error_msg LLDP_createTia_SW_Rev (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
LLDP_createTiaMED()
error_msg LLDP_createTiaMED (uint8_t , uint16_t , uint32_t )
LLDP_createTiaMED_cap()
error_msg LLDP_createTiaMED_cap (uint8_t sub, uint16_t buffLen, uint32_t orgOUI)
processCiscoPowerTlv()
error_msg processCiscoPowerTlv (uint8_t len, uint32_t oui, uint8_t orgSubtype)
processIEEE3PowerTlv()
error_msg processIEEE3PowerTlv (uint8_t len, uint32_t oui, uint8_t orgSubtype)
2.9.4.17.5 Variable Documentation
independentSparedArchitecture
bool independentSparedArchitecture = true
lldpCallFixedTlvTable
const createBasicTLV_t lldpCallFixedTlvTable[BASIC_TLVS_TABLE_SIZE]
Initial value:
= { {0, CHASSIS_ID_TLV, CHASSIS_MAC_ADDRESS, 255, createChassisTLV }, {1, PORT_ID_TLV, PORT_INTERFACE_NAME, 255, createPortTLV }, {2, TIME_TO_LIVE_TLV, 0, 2, createTTLTLV }, {3, PORT_DESCRIPTION_TLV, 0, 255, createPortDesc }, {4, SYSTEM_CAPABILITIES_TLV, 0, 4, createSysCap }, {5, SYSTEM_DESCRIPTION_TLV, 0, 255, createSystemDesc }, {6, MANAGEMENT_ADDRESS_TLV, 0, 167, createMgmtAddrTLV } }
lldpCallOrgSpecTlvTable
const createOrgTLV_t lldpCallOrgSpecTlvTable[]
Initial value:
= { {0, IEEE_3_MAC_PHY_CONFIG, 5, IEEE802_3_OUI, LLDP_createIeeeConfig }, {1, CISCO_POWER_VIA_MDI , 1, CISCO_OUI, LLDP_createCiscoMDI }, {2, IEEE_3_POWER_VIA_MDI, 8, IEEE802_3_OUI, LLDP_createIeeeMDI }, {3, TIA_LLDP_MED, 3, TIA_OUI, LLDP_createTiaMED_cap }, {4, TIA_NETWORK_POLICY, 4, TIA_OUI, LLDP_createTia_Net_pol }, {5, TIA_EXTENDED_POWER_VIA_MDI, 3, TIA_OUI, LLDP_createTia_PWR_MDI }, {6, CISCO_OUI_TLV, 1, CISCO_OUI, LLDP_createCiscoOUI }, {7, CISCO_CLASS_TLV, 1, CISCO_OUI, LLDP_createCiscoClass }, {8, CISCO_PROTOCOL_TLV, 1, CISCO_OUI, LLDP_createCiscoProtocol }, {9, TIA_INVENT_HW_REV, 255, TIA_OUI, LLDP_createTia_HW_Rev }, {10, TIA_INVENT_FW_REV, 255, TIA_OUI, LLDP_createTia_FW_Rev }, {11, TIA_INVENT_SW_REV, 255, TIA_OUI, LLDP_createTia_SW_Rev }, {12, TIA_INVENT_SERIAL_NUM, 255, TIA_OUI, LLDP_createTia_Srl_Num }, {13, TIA_INVENT_MANUFACT_NAME, 255, TIA_OUI, LLDP_createTia_Manufacturer_Name }, {14, TIA_INVENT_MODEL_NAME, 255, TIA_OUI, LLDP_createTia_Model_Name }, {15, TIA_INVENT_ASSET_ID, 255, TIA_OUI, LLDP_createTia_Asset_ID }, {16, CISCO_MUD_TLV, 255, CISCO_ALT_OUI, LLDP_createCisco_MUD_Ext } }
lldporgProcessingTlvTable
const orgSpecificTLVs_t lldporgProcessingTlvTable[2]
Initial value:
= { {CISCO_OUI, (ORG_CISCO_SUBTYPE)CISCO_POWER_VIA_MDI, processCiscoPowerTlv}, {IEEE802_3_OUI, (ORG_IEEE_3_SUBTYPE)IEEE_3_POWER_VIA_MDI, processIEEE3PowerTlv} }
2.9.4.18 source/lldp_tlv_handler_table.h File Reference
This file provides the API implementation for the LLDP TLV handler table.
#include <stdint.h> #include <stdbool.h> #include "lldp.h"
2.9.4.18.1 Functions
uint8_t get_org_tlvs_table_size (void)
Gets the size of the table that stores Organizationally Specific TLVs.
void LLDP_Run (void)
Runs the LLDP.
void LLDP_InitRx (void)
Initializes the LLDP RX.
void LLDP_InitTx (void)
Initializes the LLDP TX.
void LLDP_InitRxTx (void)
Initializes the LLDP RX and TX.
void LLDP_DecTTR (void)
Decreases the LLDP TX timer value.
void LLDP_SetDesiredPower (uint16_t pwr)
Sets the LLDP desired power.
uint16_t LLDP_GetAllocatedPower (void)
Gets the LLDP allocated power.
void LLDP_setPortDescription (const char *val)
Sets the LLDP port description.
char * LLDP_getPortDescription (void)
Gets the LLDP port description.
char * LLDP_getInfo (char *Name)
Gets the LLDP information.
void LLDP_setAssetID (const char *val)
Sets the LLDP asset ID.
char * LLDP_getAssetID (void)
Gets the LLDP asset ID.
void LLDP_setModelName (const char *val)
Sets the LLDP module name.
char * LLDP_getModelName (void)
Gets the LLDP module name.
void LLDP_setManufacturer (const char *val)
Sets the LLDP manufacturer.
char * LLDP_getManufacturer (void)
Gets the LLDP manufacturer.
void LLDP_setSerialNumber (const char *val)
Sets the LLDP serial number.
char * LLDP_getSerialNumber (void)
Gets the LLDP serial number.
void LLDP_setSoftwareRevision (const char *val)
Sets the LLDP software revision.
char * LLDP_getSoftwareRevision (void)
Gets the LLDP software revision.
void LLDP_setHardwareRevision (const char *val)
Sets the LLDP hardware revision.
char * LLDP_getHardwareRevision (void)
Gets the LLDP hardware revision.
void LLDP_setFirmwareRevision (const char *val)
Sets the LLDP firmware revision.
char * LLDP_getFirmwareRevision (void)
Gets the LLDP firmware revision.
void LLDP_setMUDInfo (const char *val)
Sets the LLDP Manufacturer Usage Description (MUD) information.
MulticastMacAddr LLDP_SetDestAddress (void)
Sets the LLDP destination address.
2.9.4.18.2 Macros
#define CISCO_OUI 0x000142
#define CISCO_ALT_OUI 0x00005E
#define IEEE802_3_OUI 0x00120F
#define TIA_OUI 0x0012BB
#define BASIC_TLVS_TABLE_SIZE 7
#define PROCESSING_TLVS_TABLE_SIZE 2
2.9.4.18.3 Variables
2.9.4.18.4 Detailed Description
This file provides the API implementation for the LLDP TLV handler table.
LLDP TLV Handler Table Header File
2.9.4.18.5 Macro Definition Documentation
BASIC_TLVS_TABLE_SIZE
#define BASIC_TLVS_TABLE_SIZE 7
CISCO_ALT_OUI
#define CISCO_ALT_OUI 0x00005E
CISCO_OUI
#define CISCO_OUI 0x000142
IEEE802_3_OUI
#define IEEE802_3_OUI 0x00120F
PROCESSING_TLVS_TABLE_SIZE
#define PROCESSING_TLVS_TABLE_SIZE 2
TIA_OUI
#define TIA_OUI 0x0012BB
2.9.4.18.6 Variable Documentation
independentSparedArchitecture
bool independentSparedArchitecture
lldpCallFixedTlvTable
const createBasicTLV_t lldpCallFixedTlvTable[BASIC_TLVS_TABLE_SIZE]
lldpCallOrgSpecTlvTable
const createOrgTLV_t lldpCallOrgSpecTlvTable[]
lldporgProcessingTlvTable
const orgSpecificTLVs_t lldporgProcessingTlvTable[PROCESSING_TLVS_TABLE_SIZE]
2.9.4.19 source/log.c File Reference
This file provides the API implementation for message logging.
#include <time.h> #include <stdio.h> #include <string.h> #include <stdbool.h> #include "../rtcc.h" #include "../log.h" #include "../log_console.h" #include "../log_syslog.h"
2.9.4.19.1 Functions
void LOG_Init (void)
Initializes the service to send log messages. Testing for externals property is done in Subversion (SVN).
void logMessage (const char *message, LOG_FACILITY facility, LOG_SEVERITY severity, uint8_t logDest)
Creates a log message with specified fields.
2.9.4.19.2 Macros
#define LOG_PRIMASK 0x07
Mask to extract priority part (internal)
#define LOG_PRI(p) ((p) & LOG_PRIMASK)
Extract priority.
#define LOG_NFACILITIES 24
Current number of facilities.
#define LOG_FACMASK 0x03f8
Mask to extract facility part.
#define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3)
Facility of priority.
#define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri))
#define LOG_MASK(pri) (1 << (pri))
Mask for one priority.
#define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1)
All priorities through PRI.
#define LOG_NILVALUE "-"
2.9.4.19.3 Variables
const logFields_t severityThresholdTable []
Sets the severity threshold for each facility.
2.9.4.19.4 Detailed Description
This file provides the API implementation for message logging.
Message Logging Implementation Source File
2.9.4.19.5 Function Documentation
LOG_Init()
void LOG_Init (void )
Initializes the service to send log messages. Testing for externals property is done in Subversion (SVN).
None. |
None. |
logMessage()
void logMessage (const char * message, LOG_FACILITY facility, LOG_SEVERITY severity, uint8_t logDest)
Creates a log message with specified fields.
*message | |
facility |
Message facility |
severity |
Message severity |
logDest |
Message logging destination |
None. |
2.9.4.19.6 Macro Definition Documentation
LOG_FAC
#define LOG_FAC( p) (((p) & LOG_FACMASK) >> 3)
Facility of priority.
LOG_FACMASK
#define LOG_FACMASK 0x03f8
Mask to extract facility part.
LOG_MAKEPRI
#define LOG_MAKEPRI( fac, pri) (((fac) << 3) | (pri))
LOG_MASK
#define LOG_MASK( pri) (1 << (pri))
Mask for one priority.
LOG_NFACILITIES
#define LOG_NFACILITIES 24
Current number of facilities.
LOG_NILVALUE
#define LOG_NILVALUE "-"
LOG_PRI
#define LOG_PRI( p) ((p) & LOG_PRIMASK)
Extract priority.
LOG_PRIMASK
#define LOG_PRIMASK 0x07
Mask to extract priority part (internal)
LOG_UPTO
#define LOG_UPTO( pri) ((1 << ((pri)+1)) - 1)
All priorities through PRI.
2.9.4.19.7 Variable Documentation
limit
LOG_SEVERITY limit[LOG_LAST]
severityThresholdTable
severityThresholdTable[]
Initial value:
= { { LOG_KERN, LOG_INFO }, { LOG_DTLS, LOG_NOTICE }, { LOG_ECC, LOG_NOTICE }, { LOG_DAEMON, LOG_INFO }, { LOG_AUTH, LOG_NOTICE }, { LOG_SYSLOG, LOG_NOTICE }, { LOG_LPR, LOG_INFO }, { LOG_NEWS, LOG_NOTICE }, { LOG_TFTP, LOG_INFO }, { LOG_UUID, LOG_NOTICE }, { LOG_COAP, LOG_NOTICE }, { LOG_FTP, LOG_NOTICE }, { LOG_NTP, LOG_INFO }, { LOG_HTTP, LOG_NOTICE }, { LOG_SNMP, LOG_NOTICE }, { LOG_RTCC, LOG_NOTICE }, { LOG_CBOR, LOG_INFO }, { LOG_UDP, LOG_NOTICE }, { LOG_TCP, LOG_NOTICE }, { LOG_DHCP, LOG_INFO }, { LOG_DNS, LOG_NOTICE }, { LOG_LLDP, LOG_INFO }, { LOG_LINK, LOG_NOTICE }, { LOG_LAST, LOG_NOTICE } }
Sets the severity threshold for each facility.
2.9.4.20 source/log.h File Reference
This file provides the API implementation for sending log messages.
#include <stdint.h> #include <stdbool.h>
2.9.4.20.1 Data structures
struct logFields_t
Log fields.
2.9.4.20.2 Functions
void LOG_Init (void)
Initializes the service to send log messages. Testing for externals property is done in Subversion (SVN).
void logMessage (const char *message, LOG_FACILITY facility, LOG_SEVERITY severity, uint8_t logDest)
Creates a log message with specified fields.
2.9.4.20.3 Macros
#define LOG_DEST_ETHERNET 0b00000001
#define LOG_DEST_CONSOLE 0b00000010
#define LOG_DEST_EEPROM 0b00000100
#define LOG_ETHERNET_MASK(m) (m & LOG_DEST_ETHERNET)
#define LOG_CONSOLE_MASK(m) (m & LOG_DEST_CONSOLE)
#define LOG_EEPROM_MASK(m) (m & LOG_DEST_EEPROM)
#define SYSLOG_VERSION 1
#define LOG_NILVALUE "-"
2.9.4.20.4 Enumerations
enum LOG_SEVERITY { LOG_EMERGENCY = 0, LOG_ALERTS = 1, LOG_CRITICAL = 2, LOG_ERROR = 3, LOG_WARNING = 4, LOG_NOTICE = 5, LOG_INFO = 6, LOG_DEBUG = 7 }
PRI Priorities severity.
enum LOG_FACILITY { LOG_KERN, LOG_DTLS, LOG_ECC, LOG_DAEMON, LOG_AUTH, LOG_SYSLOG, LOG_LPR, LOG_NEWS, LOG_TFTP, LOG_UUID, LOG_COAP, LOG_FTP, LOG_NTP, LOG_HTTP, LOG_SNMP, LOG_RTCC, LOG_CBOR, LOG_UDP, LOG_TCP, LOG_DHCP, LOG_DNS, LOG_LLDP, LOG_LINK, LOG_LAST }
PRI facility codes These facility codes represent the Connected Lighting Stack. Facility codes MUST be in the range of 0 to 23 inclusive.
2.9.4.20.5 Variables
const char * LOG_Month []
const logFields_t severityThresholdTable []
Sets the severity threshold for each facility.
2.9.4.20.6 Detailed Description
This file provides the API implementation for sending log messages.
Log API Header File
2.9.4.20.7 Function Documentation
LOG_Init()
void LOG_Init (void )
Initializes the service to send log messages. Testing for externals property is done in Subversion (SVN).
None. |
None. |
logMessage()
void logMessage (const char * message, LOG_FACILITY facility, LOG_SEVERITY severity, uint8_t logDest)
Creates a log message with specified fields.
*message | |
facility |
Message facility |
severity |
Message severity |
logDest |
Message logging destination |
None. |
2.9.4.20.8 Macro Definition Documentation
LOG_CONSOLE_MASK
#define LOG_CONSOLE_MASK( m) (m & LOG_DEST_CONSOLE)
LOG_DEST_CONSOLE
#define LOG_DEST_CONSOLE 0b00000010
LOG_DEST_EEPROM
#define LOG_DEST_EEPROM 0b00000100
LOG_DEST_ETHERNET
#define LOG_DEST_ETHERNET 0b00000001
LOG_EEPROM_MASK
#define LOG_EEPROM_MASK( m) (m & LOG_DEST_EEPROM)
LOG_ETHERNET_MASK
#define LOG_ETHERNET_MASK( m) (m & LOG_DEST_ETHERNET)
LOG_NILVALUE
#define LOG_NILVALUE "-"
SYSLOG_VERSION
#define SYSLOG_VERSION 1
2.9.4.20.9 Enumeration Type Documentation
LOG_FACILITY
enum LOG_FACILITY
PRI facility codes These facility codes represent the Connected Lighting Stack. Facility codes MUST be in the range of 0 to 23 inclusive.
LOG_KERN |
Kernel messages |
LOG_DTLS |
DTLS messages |
LOG_ECC |
ECC system |
LOG_DAEMON |
System daemons |
LOG_AUTH |
Security/authorization messages |
LOG_SYSLOG |
Messages generated internally by syslogd |
LOG_LPR |
Line printer subsystem |
LOG_NEWS |
Network news subsystem |
LOG_TFTP |
TFTP service |
LOG_UUID |
UUID service |
LOG_COAP |
CoAP service |
LOG_FTP |
FTP daemon |
LOG_NTP |
NTP subsystem |
LOG_HTTP |
HTTP Server |
LOG_SNMP |
SNMP subsystem |
LOG_RTCC |
Real-Time Clock Service |
LOG_CBOR |
CBOR encoding and decoding |
LOG_UDP |
UDP system |
LOG_TCP |
TCP system |
LOG_DHCP |
DHCP service |
LOG_DNS |
DNS service |
LOG_LLDP |
LLDP service |
LOG_LINK |
URI service |
LOG_LAST |
To be kept at the end of the list |
LOG_SEVERITY
enum LOG_SEVERITY
PRI Priorities severity.
LOG_EMERGENCY |
System is unusable |
LOG_ALERTS |
Action must be taken immediately |
LOG_CRITICAL |
Critical conditions |
LOG_ERROR |
Error conditions |
LOG_WARNING |
Warning conditions |
LOG_NOTICE |
Normal but signification condition |
LOG_INFO |
Informational messages |
LOG_DEBUG |
Debug-level messages |
2.9.4.20.10 Variable Documentation
LOG_Month
const char* LOG_Month[]
severityThresholdTable
const logFields_t severityThresholdTable[]
Sets the severity threshold for each facility.
2.9.4.21 source/log_console.c File Reference
This file provides the API implementation for sending log messages to the console.
#include <time.h> #include <stdio.h> #include <stdint.h> #include "../../system/system.h" #include "../log.h" #include "../ip_database.h"
2.9.4.21.1 Functions
uint8_t logConsole (const char *message, uint8_t priorityVal)
Logs a message to console using UART.
2.9.4.21.2 Detailed Description
This file provides the API implementation for sending log messages to the console.
Log Console Source File
2.9.4.21.3 Function Documentation
logConsole()
uint8_t logConsole (const char * message, uint8_t priorityVal)
Logs a message to console using UART.
*message | |
priorityVal |
Message priority |
1 |
2.9.4.22 source/log_console.h File Reference
This file provides the API implementation for sending log messages to the console.
2.9.4.22.1 Functions
uint8_t logConsole (const char *message, uint8_t priorityVal)
Logs a message to console using UART.
2.9.4.22.2 Detailed Description
This file provides the API implementation for sending log messages to the console.
Log Console Header File
2.9.4.22.3 Function Documentation
logConsole()
uint8_t logConsole (const char * message, uint8_t priorityVal)
Logs a message to console using UART.
*message | |
priorityVal |
Message priority |
1 |
2.9.4.23 source/log_syslog.c File Reference
This file provides the API implementation for sending syslog messages.
#include <time.h> #include <stdio.h> #include <stdint.h> #include "../../system/system.h" #include "../log.h" #include "../tcpip_types.h" #include "../udpv4.h" #include "../udpv4_port_handler_table.h" #include "../ip_database.h" #include "../log_syslog.h"
2.9.4.23.1 Functions
2.9.4.23.2 Detailed Description
This file provides the API implementation for sending syslog messages.
Sending Syslog Source File
2.9.4.23.3 Function Documentation
logSyslog()
error_msg logSyslog (const char * message, uint8_t priorityVal)
Sends a syslog message.
*message | |
priorityVal |
Message priority |
Status of sending the message. Refer to the error description in tcpip_types.h. |
2.9.4.24 source/log_syslog.h File Reference
This file provides the API implementation for sending log messages using Ethernet (Syslog RFC 5424).
#include <stdint.h> #include "tcpip_types.h"
2.9.4.24.1 Functions
2.9.4.24.2 Macros
#define SOURCEPORT_SYSLOG 514
#define DESTPORT_SYSLOG 514
2.9.4.24.3 Detailed Description
This file provides the API implementation for sending log messages using Ethernet (Syslog RFC 5424).
Log Syslog Header File
2.9.4.24.4 Function Documentation
logSyslog()
error_msg logSyslog (const char * message, uint8_t priorityVal)
Sends a syslog message.
*message | |
priorityVal |
Message priority |
Status of sending the message. Refer to the error description in tcpip_types.h. |
2.9.4.24.5 Macro Definition Documentation
DESTPORT_SYSLOG
#define DESTPORT_SYSLOG 514
SOURCEPORT_SYSLOG
#define SOURCEPORT_SYSLOG 514
2.9.4.25 source/network.c File Reference
This file provides the network layer implementation for the TCP/IP stack.
#include <stdio.h> #include <stdbool.h> #include <string.h> #include <time.h> #include "../../system/system.h" #include "../network.h" #include "../tcpip_types.h" #include "../dhcp_client.h" #include "../arpv4.h" #include "../ipv4.h" #include "../tcpv4.h" #include "../rtcc.h" #include "../../ethernet/physical_layer_interface.h" #include "../log.h" #include "../lldp.h" #include "../lldp_tlv_handler_table.h" #include "../ip_database.h" #include "../dns_client.h"
2.9.4.25.1 Functions
static void Network_SaveStartPosition (void)
void Network_Init (void)
Initializes the network protocols.
void timersInit (void)
Initializes the timers.
void Network_WaitForLink (void)
Waits for the link by reading the PHY registers.
void Network_Manage (void)
Handles the packets in the network.
void Network_Read (void)
Reads the packets in the network.
uint16_t Network_GetStartPosition (void)
Returns the network start position.
2.9.4.25.2 Macros
#define logMsg(msg, msgSeverity, msgLogDest)
2.9.4.25.3 Variables
time_t arpTimer
uint16_t networkStartPosition
const char * network_errors []
2.9.4.25.4 Detailed Description
This file provides the network layer implementation for the TCP/IP stack.
Network Source File
2.9.4.25.5 Function Documentation
Network_GetStartPosition()
uint16_t Network_GetStartPosition (void )
Returns the network start position.
None. |
Start position. |
Network_Init()
void Network_Init (void )
Initializes the network protocols.
None. |
None. |
Network_Manage()
void Network_Manage (void )
Handles the packets in the network.
None. |
None. |
Network_Read()
void Network_Read (void )
Reads the packets in the network.
None. |
None. |
Network_SaveStartPosition()
static void Network_SaveStartPosition (void )[static]
Network_WaitForLink()
void Network_WaitForLink (void )
Waits for the link by reading the PHY registers.
None. |
None. |
timersInit()
void timersInit (void )
Initializes the timers.
None. |
None. |
2.9.4.25.6 Macro Definition Documentation
logMsg
#define logMsg( msg, msgSeverity, msgLogDest)
2.9.4.25.7 Variable Documentation
arpTimer
time_t arpTimer
network_errors
const char* network_errors[]
Initial value:
= { "ERROR", "SUCCESS", "LINK_NOT_FOUND", "BUFFER_BUSY", "TX_LOGIC_NOT_IDLE", "MAC_NOT_FOUND", "IP_WRONG_VERSION", "IPV4_CHECKSUM_FAILS", "DEST_IP_NOT_MATCHED", "ICMP_CHECKSUM_FAILS", "UDP_CHECKSUM_FAILS", "TCP_CHECKSUM_FAILS", "DMA_TIMEOUT", "PORT_NOT_AVAILABLE", "ARP_IP_NOT_MATCHED", "EAPol_PACKET_FAILURE"}
networkStartPosition
uint16_t networkStartPosition
2.9.4.26 source/network.h File Reference
This file provides the network layer implementation for the Transmission Control Protocol/Internet Protocol (TCP/IP) stack.
#include <stdint.h> #include "tcpip_types.h"
2.9.4.26.1 Functions
void Network_Init (void)
Initializes the network protocols.
void Network_Read (void)
Reads the packets in the network.
void Network_Manage (void)
Handles the packets in the network.
void Network_WaitForLink (void)
Waits for the link by reading the PHY registers.
uint16_t Network_GetStartPosition (void)
Returns the network start position.
void timersInit (void)
Initializes the timers.
2.9.4.26.2 Macros
#define byteSwap16(a) ((((uint16_t)a & (uint16_t)0xFF00) >> 8) | (((uint16_t)a & (uint16_t)0x00FF) << 8))
#define byteReverse32(a)
#define byteReverse24(a) (((((uint32_t)a & (uint32_t)0x00FF00) >> 8) | (((uint32_t)a & (uint32_t)0x0000FF) << 8)) << 8 | (uint32_t)a >> 0x10)
#define htons(a) byteSwap16(a)
#define ntohs(a) byteSwap16(a)
#define htonl(a) byteReverse32(a)
#define ntohl(a) byteReverse32(a)
#define convert_hton24(a) byteReverse24(a)
2.9.4.26.3 Detailed Description
This file provides the network layer implementation for the Transmission Control Protocol/Internet Protocol (TCP/IP) stack.
Network Header File
2.9.4.26.4 Function Documentation
Network_GetStartPosition()
uint16_t Network_GetStartPosition (void )
Returns the network start position.
None. |
Start position. |
Network_Init()
void Network_Init (void )
Initializes the network protocols.
None. |
None. |
Network_Manage()
void Network_Manage (void )
Handles the packets in the network.
None. |
None. |
Network_Read()
void Network_Read (void )
Reads the packets in the network.
None. |
None. |
Network_WaitForLink()
void Network_WaitForLink (void )
Waits for the link by reading the PHY registers.
None. |
None. |
timersInit()
void timersInit (void )
Initializes the timers.
None. |
None. |
2.9.4.26.5 Macro Definition Documentation
byteReverse24
#define byteReverse24( a) (((((uint32_t)a & (uint32_t)0x00FF00) >> 8) | (((uint32_t)a & (uint32_t)0x0000FF) << 8)) << 8 | (uint32_t)a >> 0x10)
byteReverse32
#define byteReverse32( a)
Value:
((((uint32_t)a & (uint32_t)0xff000000) >> 24) | \ (((uint32_t)a & (uint32_t)0x00ff0000) >> 8) | \ (((uint32_t)a & (uint32_t)0x0000ff00) << 8) | \ (((uint32_t)a & (uint32_t)0x000000ff) << 24))
byteSwap16
#define byteSwap16( a) ((((uint16_t)a & (uint16_t)0xFF00) >> 8) | (((uint16_t)a & (uint16_t)0x00FF) << 8))
convert_hton24
#define convert_hton24( a) byteReverse24(a)
htonl
#define htonl( a) byteReverse32(a)
htons
#define htons( a) byteSwap16(a)
ntohl
#define ntohl( a) byteReverse32(a)
ntohs
#define ntohs( a) byteSwap16(a)
2.9.4.27 source/ntp.c File Reference
This file provides the API implementation of the NTP client protocol.
#include <stdio.h> #include <string.h> #include <time.h> #include "../../system/system.h" #include "../ntp.h" #include "../udpv4.h" #include "../rtcc.h" #include "../log.h" #include "../ip_database.h"
2.9.4.27.1 Functions
void NTP_Request (void)
Sends the NTP request to the NTP server.
void NTP_Handler (int16_t length)
Receives and processes the NTP packet.
2.9.4.27.2 Macros
#define logMsg(msg, msgSeverity, msgLogDest)
#define NTP_PACKET_SIZE 48
#define NTP_TIME_OFFSET 2208988800
The time offset converts from unix time (seconds, since January 1, 1970) to RFC 868 time (seconds, since January 1, 1900). The RFC indicates that this is sufficient until 2036.
2.9.4.27.3 Detailed Description
This file provides the API implementation of the NTP client protocol.
NTP client Implementation Source File
2.9.4.27.4 Macro Definition Documentation
logMsg
#define logMsg( msg, msgSeverity, msgLogDest)
NTP_PACKET_SIZE
#define NTP_PACKET_SIZE 48
2.9.4.28 source/ntp.h File Reference
#include <time.h> #include <stdint.h>
2.9.4.28.1 Functions
void NTP_Request (void)
Sends the NTP request to the NTP server.
void NTP_Handler (int16_t length)
Receives and processes the NTP packet.
2.9.4.28.2 Detailed Description
NTP Client Protocol Header File
2.9.4.29 source/rtcc.c File Reference
This file provides the API implementation for the RTCC.
#include <time.h> #include <stdint.h> #include <stdbool.h> #include "../rtcc.h" #include "../../system/system.h"
2.9.4.29.1 Functions
void rtcc_init (void)
Initializes the clock calendar driver. This routine configures the basics of a software-driven RTCC peripheral. It relies upon a periodic timer event to provide time keeping. The appropriate timer needs to be selected in the TCP/IP Lite Dependency. Configure the selected timer to produce a time-out of 1s. Set the callback rate as 1, if required depending on the device.
void rtcc_handler (void)
Maintains the deviceTime (seconds) using the LCDIF flag/interrupt. This routine decrements seconds_counter until 0 and then increments deviceTime. seconds_counter reloads with CLOCK_PER_SEC. It uses the timer selected as the Dependency by the user.
void rtcc_set (time_t *t)
Sets the device time to the passed unix time value and updates the device time with the passed unix time. Interrupts are disabled during the copy and restored to the original on exit.
time_t time (time_t *t)
Returns the current device time. This routine retrieves the device time as either a return value or filling in a variable passed by reference. Interrupts are disabled during the copy and restored to the original on exit. time.h is a prerequisite for supporting the standard C time libraries and does not implement time, as it is application dependent.
2.9.4.29.2 Variables
volatile time_t deviceTime
volatile bool dirtyTime
volatile uint16_t seconds_counter
2.9.4.29.3 Detailed Description
This file provides the API implementation for the RTCC.
RTCC Implementation Source File
2.9.4.29.4 Function Documentation
rtcc_handler()
void rtcc_handler (void )
Maintains the deviceTime (seconds) using the LCDIF flag/interrupt. This routine decrements seconds_counter until 0 and then increments deviceTime. seconds_counter reloads with CLOCK_PER_SEC. It uses the timer selected as the Dependency by the user.
None. |
None. |
rtcc_init()
void rtcc_init (void )
Initializes the clock calendar driver. This routine configures the basics of a software-driven RTCC peripheral. It relies upon a periodic timer event to provide time keeping. The appropriate timer needs to be selected in the TCP/IP Lite Dependency. Configure the selected timer to produce a time-out of 1s. Set the callback rate as 1, if required depending on the device.
None. |
None. |
rtcc_set()
void rtcc_set (time_t * t)
Sets the device time to the passed unix time value and updates the device time with the passed unix time. Interrupts are disabled during the copy and restored to the original on exit.
*t |
A pointer of type time_t for the current time |
None. |
time()
time_t time (time_t * t)
Returns the current device time. This routine retrieves the device time as either a return value or filling in a variable passed by reference. Interrupts are disabled during the copy and restored to the original on exit. time.h is a prerequisite for supporting the standard C time libraries and does not implement time, as it is application dependent.
*t |
A pointer of type time_t for the current time |
Value of the current time. |
2.9.4.29.5 Variable Documentation
deviceTime
volatile time_t deviceTime
dirtyTime
volatile bool dirtyTime
seconds_counter
volatile uint16_t seconds_counter
2.9.4.30 source/rtcc.h File Reference
This file provides the API implementation for the Real-Time Clock/Calendar (RTCC).
#include <time.h> #include <stdint.h>
2.9.4.30.1 Functions
void rtcc_init (void)
Initializes the clock calendar driver. This routine configures the basics of a software-driven RTCC peripheral. It relies upon a periodic timer event to provide time keeping. The appropriate timer needs to be selected in the TCP/IP Lite Dependency. Configure the selected timer to produce a time-out of 1s. Set the callback rate as 1, if required depending on the device.
void rtcc_handler (void)
Maintains the deviceTime (seconds) using the LCDIF flag/interrupt. This routine decrements seconds_counter until 0 and then increments deviceTime. seconds_counter reloads with CLOCK_PER_SEC. It uses the timer selected as the Dependency by the user.
void rtcc_set (time_t *t)
Sets the device time to the passed unix time value and updates the device time with the passed unix time. Interrupts are disabled during the copy and restored to the original on exit.
time_t time (time_t *t)
Returns the current device time. This routine retrieves the device time as either a return value or filling in a variable passed by reference. Interrupts are disabled during the copy and restored to the original on exit. time.h is a prerequisite for supporting the standard C time libraries and does not implement time, as it is application dependent.
2.9.4.30.2 Variables
volatile bool dirtyTime
2.9.4.30.3 Detailed Description
This file provides the API implementation for the Real-Time Clock/Calendar (RTCC).
RTCC Header File
2.9.4.30.4 Function Documentation
rtcc_handler()
void rtcc_handler (void )
Maintains the deviceTime (seconds) using the LCDIF flag/interrupt. This routine decrements seconds_counter until 0 and then increments deviceTime. seconds_counter reloads with CLOCK_PER_SEC. It uses the timer selected as the Dependency by the user.
None. |
None. |
rtcc_init()
void rtcc_init (void )
Initializes the clock calendar driver. This routine configures the basics of a software-driven RTCC peripheral. It relies upon a periodic timer event to provide time keeping. The appropriate timer needs to be selected in the TCP/IP Lite Dependency. Configure the selected timer to produce a time-out of 1s. Set the callback rate as 1, if required depending on the device.
None. |
None. |
rtcc_set()
void rtcc_set (time_t * t)
Sets the device time to the passed unix time value and updates the device time with the passed unix time. Interrupts are disabled during the copy and restored to the original on exit.
*t |
A pointer of type time_t for the current time |
None. |
time()
time_t time (time_t * t)
Returns the current device time. This routine retrieves the device time as either a return value or filling in a variable passed by reference. Interrupts are disabled during the copy and restored to the original on exit. time.h is a prerequisite for supporting the standard C time libraries and does not implement time, as it is application dependent.
*t |
A pointer of type time_t for the current time |
Value of the current time. |
2.9.4.30.5 Variable Documentation
dirtyTime
volatile bool dirtyTime
2.9.4.31 source/tcpip_config.h File Reference
This file provides the API implementation for the TCP/IP Stack user configuration options.
2.9.4.31.1 Macros
#define MAKE_IPV4_ADDRESS(a, b, c, d) ((uint32_t)(((uint32_t)a << 24) | ((uint32_t)b<<16) | ((uint32_t)c << 8) | (uint32_t)d))
Build the IPv4 Address.
#define ARP_MAP_SIZE 8
#define DHCP_NAME_SIZE 20
Required since sizeof is not handled during the preprocessor stage.
#define SOURCEPORT_TFTP 65531
#define IPv4_TTL 64u
#define TCP_MAX_SEG_SIZE 1460u
TCP maximum segment size.
#define TICK_SECOND 1
#define TCP_START_TIMEOUT_VAL ((unsigned long)TICK_SECOND*2)
Time-out to retransmit unacked data.
#define TCP_MAX_RETRIES (5u)
Number of retransmission attempts.
#define TCP_MAX_SYN_RETRIES (3u)
than all other retries to reduce SYN flood DoS duration
#define LOCAL_TCP_PORT_START_NUMBER (1024u)
The lower port number to be used as a local port.
#define LOCAL_TCP_PORT_END_NUMBER (65535u)
The highest port number to be used as a local port.
2.9.4.31.2 Variables
const char dhcpName []
2.9.4.31.3 Detailed Description
This file provides the API implementation for the TCP/IP Stack user configuration options.
TCP/IP Stack User Configuration Options Header File
2.9.4.31.4 Macro Definition Documentation
ARP_MAP_SIZE
#define ARP_MAP_SIZE 8
DHCP_NAME_SIZE
#define DHCP_NAME_SIZE 20
Required since sizeof is not handled during the preprocessor stage.
IPv4_TTL
#define IPv4_TTL 64u
LOCAL_TCP_PORT_END_NUMBER
#define LOCAL_TCP_PORT_END_NUMBER (65535u)
The highest port number to be used as a local port.
LOCAL_TCP_PORT_START_NUMBER
#define LOCAL_TCP_PORT_START_NUMBER (1024u)
The lower port number to be used as a local port.
MAKE_IPV4_ADDRESS
#define MAKE_IPV4_ADDRESS( a, b, c, d) ((uint32_t)(((uint32_t)a << 24) | ((uint32_t)b<<16) | ((uint32_t)c << 8) | (uint32_t)d))
Build the IPv4 Address.
SOURCEPORT_TFTP
#define SOURCEPORT_TFTP 65531
TCP_MAX_RETRIES
#define TCP_MAX_RETRIES (5u)
Number of retransmission attempts.
TCP_MAX_SEG_SIZE
#define TCP_MAX_SEG_SIZE 1460u
TCP maximum segment size.
TCP_MAX_SYN_RETRIES
#define TCP_MAX_SYN_RETRIES (3u)
than all other retries to reduce SYN flood DoS duration
TCP_START_TIMEOUT_VAL
#define TCP_START_TIMEOUT_VAL ((unsigned long)TICK_SECOND*2)
Time-out to retransmit unacked data.
TICK_SECOND
#define TICK_SECOND 1
2.9.4.31.5 Variable Documentation
dhcpName
const char dhcpName[]
2.9.4.32 source/tcpip_types.h File Reference
This file provides the TCP/IP Stack type definitions.
#include <stdint.h>
2.9.4.32.1 Data structures
struct ethernetFrame_t
Ethernet frame information.
struct ipv4Header_t
IPv4 header information.
struct ipv4_pseudo_header_t
Pseudo header used for checksum calculation on UDP and TCP.
struct icmpHeader_t
ICMP header information.
struct udpHeader_t
UDP header information.
struct tcpHeader_t
TCP header information.
struct inAddr_t
INET address.
struct sockaddr_in4_t
INET4 socket address.
struct destIP_t
2.9.4.32.2 Macros
#define ETHERTYPE_IPV4 0x0800
#define ETHERTYPE_ARP 0x0806
#define ETHERTYPE_IPV6 0x86DD
#define ETHERTYPE_VLAN 0x8100
#define ETHERTYPE_LLDP 0x88CC
#define ETHERTYPE_EAPoL 0x888E
#define INETADDRESSTYPE_IPV4 1
#define INETADDRESSTYPE_IPV6 2
#define INETADDRESSTYPE_DNS 16
#define ETHERNET_ADDR_LEN 6
#define IP_ADDR_LEN 4
#define AF_INET 2
Internet IP Protocol.
#define AF_INET6 10
IP version 6.
-
Protocol families, same as address families.
#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
#define INET_ADDRSTRLEN 16
Length of the string form for IP.
#define INET6_ADDRSTRLEN 46
Length of the string form for IPv6.
2.9.4.32.3 Typedefs
typedef int8_t socklistsize_t
typedef void(* ip_receive_function_ptr) (int16_t)
Function pointer to the function that receives the payload.
2.9.4.32.4 Enumerations
enum tcbError_t { TCB_ERROR = -1, TCB_NO_ERROR = 0 }
enum icmpTypeCodes_t { ECHO_REPLY = 0x0000, DEST_NETWORK_UNREACHABLE = 0x0300, DEST_HOST_UNREACHABLE = 0x0301, DEST_PROTOCOL_UNREACHABLE = 0x0302, DEST_PORT_UNREACHABLE = 0x0303, FRAGMENTATION_REQUIRED = 0x0304, SOURCE_ROUTE_FAILED = 0x0305, DESTINATION_NETWORK_UNKNOWN = 0x0306, SOURCE_HOST_ISOLATED = 0x0307, NETWORK_ADMINISTRATIVELY_PROHIBITED = 0x0308, HOST_ADMINISTRATIVELY_PROHIBITED = 0x0309, NETWORK_UNREACHABLE_FOR_TOS = 0x030A, HOST_UNREACHABLE_FOR_TOS = 0x030B, COMMUNICATION_ADMINISTRATIVELY_PROHIBITED = 0x030C, HOST_PRECEDENCE_VIOLATION = 0x030D, PRECEDENCE_CUTOFF_IN_EFFECT = 0x030E, SOURCE_QUENCH = 0x0400, REDIRECT_DATAGRAM_FOR_THE_NETWORK = 0x0500, REDIRECT_DATAGRAM_FOR_THE_HOST = 0x0501, REDIRECT_DATAGRAM_FOR_THE_TOS_AND_NETWORK = 0x0502, REDIRECT_DATAGRAM_FOR_THE_TOS_AND_HOST = 0x0503, ALTERNATE_HOST_ADDRESS = 0x0600, ECHO_REQUEST = 0x0800, UNASSIGNED_ECHO_TYPE_CODE_REQUEST_1 = 0x082A, UNASSIGNED_ECHO_TYPE_CODE_REQUEST_2 = 0x08FC, ROUTER_ADVERTISEMENT = 0x0900, ROUTER_SOLICITATION = 0x0A00, TRACEROUTE = 0x3000 }
ICMP Types and Codes.
enum ipProtocolNumbers { HOPOPT_TCPIP = 0, ICMP_TCPIP = 1, IGMP_TCPIP = 2, GGP_TCPIP = 3, IPV4_TCPIP = 4, ST_TCPIP = 5, TCP_TCPIP = 6, CBT_TCPIP = 7, EGP_TCPIP = 8, IGP_TCPIP = 9, BBN_RCC_MON_TCPIP = 10, NVP_II_TCPIP = 11, PUP_TCPIP = 12, ARGUS_TCPIP = 13, EMCON_TCPIP = 14, XNET_TCPIP = 15, CHAOS_TCPIP = 16, UDP_TCPIP = 17, MUX_TCPIP = 18, DCN_MEAS_TCPIP = 19, HMP_TCPIP = 20, PRM_TCPIP = 21, XNS_IDP_TCPIP = 22, TRUNK_1_TCPIP = 23, TRUNK_2_TCPIP = 24, LEAF_1_TCPIP = 25, LEAF_2_TCPIP = 26, RDP_TCPIP = 27, IRTP_TCPIP = 28, ISO_TP4_TCPIP = 29, NETBLT_TCPIP = 30, MFE_NSP_TCPIP = 31, MERIT_INP_TCPIP = 32, DCCP_TCPIP = 33, THREEPC_TCPIP = 34, IDPR_TCPIP = 35, XTP_TCPIP = 36, DDP_TCPIP = 37, IDPR_CMTP_TCPIP = 38, TPpp_TCPIP = 39, IL_TCPIP = 40, IPV6_TUNNEL_TCPIP = 41, SDRP_TCPIP = 42, IPV6_Route_TCPIP = 43, IPV6_Frag_TCPIP = 44, IDRP_TCPIP = 45, RSVP_TCPIP = 46, GRE_TCPIP = 47, DSR_TCPIP = 48, BNA_TCPIP = 49, ESP_TCPIP = 50, AH_TCPIP = 51, I_NLSP_TCPIP = 52, SWIPE_TCPIP = 53, NARP_TCPIP = 54, MOBILE_TCPIP = 55, TLSP_TCPIP = 56, SKIP_TCPIP = 57, IPV6_ICMP_TCPIP = 58, IPV6_NoNxt_TCPIP = 59, IPV6_Opts_TCPIP = 60, CFTP_TCPIP = 62, SAT_EXPAK_TCPIP = 64, KRYPTOLAN_TCPIP = 65, RVD_TCPIP = 66, IPPC_TCPIP = 67, SAT_MON_TCPIP = 69, VISA_TCPIP = 70, IPCV_TCPIP = 71, CPNX_TCPIP = 72, CPHB_TCPIP = 73, WSN_TCPIP = 74, PVP_TCPIP = 75, BR_SAT_MON_TCPIP = 76, SUN_ND_TCPIP = 77, WB_MON_TCPIP = 78, WB_EXPAK_TCPIP = 79, ISO_IP_TCPIP = 80, VMTP_TCPIP = 81, SECURE_VMTP_TCPIP = 82, VINES_TCPIP = 83, TTP_TCPIP = 84, IPTM_TCPIP = 84, NSFNET_IGP_TCPIP = 85, DGP_TCPIP = 86, TCF_TCPIP = 87, EIGRP_TCPIP = 88, OSPFIGP_TCPIP = 89, Sprite_RPC_TCPIP = 90, LARP_TCPIP = 91, MTP_TCPIP = 92, AX25_TCPIP = 93, IPIP_TCPIP = 94, MICP_TCPIP = 95, SCC_SP_TCPIP = 96, ETHERIP_TCPIP = 97, ENCAP_TCPIP = 98, GMTP_TCPIP = 100, IFMP_TCPIP = 101, PNNI_TCPIP = 102, PIM_TCPIP = 103, ARIS_TCPIP = 104, SCPS_TCPIP = 105, QNX_TCPIP = 106, A_N_TCPIP = 107, IPComp_TCPIP = 108, SNP_TCPIP = 109, Compaq_Peer_TCPIP = 110, IPX_in_IP_TCPIP = 111, VRRP_TCPIP = 112, PGM_TCPIP = 113, L2TP_TCPIP = 115, DDX_TCPIP = 116, IATP_TCPIP = 117, STP_TCPIP = 118, SRP_TCPIP = 119, UTI_TCPIP = 120, SMP_TCPIP = 121, SM_TCPIP = 122, PTP_TCPIP = 123, ISIS_TCPIP = 124, FIRE_TCPIP = 125, CRTP_TCPIP = 126, CRUDP_TCPIP = 127, SSCOPMCE_TCPIP = 128, IPLT_TCPIP = 129, SPS_TCPIP = 130, PIPE_TCPIP = 131, SCTP_TCPIP = 132, FC_TCPIP = 133 }
IP Protocol Numbers. List from RFC5237 http://www.iana.org/assignments/protocol-numbers/protocol-numbers.txt.
enum error_msg { ERROR = 0, SUCCESS, LINK_NOT_FOUND, BUFFER_BUSY, TX_LOGIC_NOT_IDLE, TX_QUEUED, DMA_TIMEOUT, MAC_NOT_FOUND, IP_WRONG_VERSION, IPV4_CHECKSUM_FAILS, DEST_IP_NOT_MATCHED, ICMP_CHECKSUM_FAILS, UDP_CHECKSUM_FAILS, TCP_CHECKSUM_FAILS, PORT_NOT_AVAILABLE, ARP_IP_NOT_MATCHED, EAPoL_PACKET_FAILURE, INCORRECT_IPV4_HLEN, IPV4_NO_OPTIONS, IPV6_CHECKSUM_FAILS, IPV6_LOCAL_ADDR_RESOLVE, IPV6_LOCAL_ADDR_INVALID, NO_GATEWAY, ADDRESS_RESOLUTION, GLOBAL_DESTINATION, ARP_WRONG_HARDWARE_ADDR_TYPE, ARP_WRONG_PROTOCOL_TYPE, ARP_WRONG_HARDWARE_ADDR_LEN, ARP_WRONG_PROTOCOL_LEN }
Error message.
2.9.4.32.5 Variables
const char * network_errors []
2.9.4.32.6 Detailed Description
This file provides the TCP/IP Stack type definitions.
TCP/IP Stack User Types Header File
2.9.4.32.7 Macro Definition Documentation
AF_INET
#define AF_INET 2
Internet IP Protocol.
AF_INET6
#define AF_INET6 10
IP version 6.
ETHERNET_ADDR_LEN
#define ETHERNET_ADDR_LEN 6
ETHERTYPE_ARP
#define ETHERTYPE_ARP 0x0806
ETHERTYPE_EAPoL
#define ETHERTYPE_EAPoL 0x888E
ETHERTYPE_IPV4
#define ETHERTYPE_IPV4 0x0800
ETHERTYPE_IPV6
#define ETHERTYPE_IPV6 0x86DD
ETHERTYPE_LLDP
#define ETHERTYPE_LLDP 0x88CC
ETHERTYPE_VLAN
#define ETHERTYPE_VLAN 0x8100
IN6ADDR_ANY_INIT
#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
IN6ADDR_LOOPBACK_INIT
#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
INET6_ADDRSTRLEN
#define INET6_ADDRSTRLEN 46
Length of the string form for IPv6.
INET_ADDRSTRLEN
#define INET_ADDRSTRLEN 16
Length of the string form for IP.
INETADDRESSTYPE_DNS
#define INETADDRESSTYPE_DNS 16
INETADDRESSTYPE_IPV4
#define INETADDRESSTYPE_IPV4 1
INETADDRESSTYPE_IPV6
#define INETADDRESSTYPE_IPV6 2
IP_ADDR_LEN
#define IP_ADDR_LEN 4
PF_INET
#define PF_INET AF_INET
Protocol families, same as address families.
PF_INET6
#define PF_INET6 AF_INET6
2.9.4.32.8 Typedef Documentation
ip_receive_function_ptr
ip_receive_function_ptr
Function pointer to the function that receives the payload.
int16_t |
Available bytes for the payload |
None. |
socklistsize_t
typedef int8_t socklistsize_t
2.9.4.32.9 Enumeration Type Documentation
error_msg
enum error_msg
Error message.
ERROR | |
SUCCESS | |
LINK_NOT_FOUND | |
BUFFER_BUSY | |
TX_LOGIC_NOT_IDLE | |
TX_QUEUED | |
DMA_TIMEOUT | |
MAC_NOT_FOUND | |
IP_WRONG_VERSION | |
IPV4_CHECKSUM_FAILS | |
DEST_IP_NOT_MATCHED | |
ICMP_CHECKSUM_FAILS | |
UDP_CHECKSUM_FAILS | |
TCP_CHECKSUM_FAILS | |
PORT_NOT_AVAILABLE | |
ARP_IP_NOT_MATCHED | |
EAPoL_PACKET_FAILURE | |
INCORRECT_IPV4_HLEN | |
IPV4_NO_OPTIONS | |
IPV6_CHECKSUM_FAILS | |
IPV6_LOCAL_ADDR_RESOLVE | |
IPV6_LOCAL_ADDR_INVALID | |
NO_GATEWAY | |
ADDRESS_RESOLUTION | |
GLOBAL_DESTINATION | |
ARP_WRONG_HARDWARE_ADDR_TYPE | |
ARP_WRONG_PROTOCOL_TYPE | |
ARP_WRONG_HARDWARE_ADDR_LEN | |
ARP_WRONG_PROTOCOL_LEN |
icmpTypeCodes_t
enum icmpTypeCodes_t
ICMP Types and Codes.
ECHO_REPLY |
Echo reply |
DEST_NETWORK_UNREACHABLE |
Destination network unreachable |
DEST_HOST_UNREACHABLE |
Destination host unreachable |
DEST_PROTOCOL_UNREACHABLE |
Destination protocol unreachable |
DEST_PORT_UNREACHABLE |
Destination port unreachable |
FRAGMENTATION_REQUIRED |
Fragmentation required |
SOURCE_ROUTE_FAILED |
Fragmentation failed |
DESTINATION_NETWORK_UNKNOWN |
Unknown destination network |
SOURCE_HOST_ISOLATED |
Source host isolated |
NETWORK_ADMINISTRATIVELY_PROHIBITED |
Network administratively prohibited |
HOST_ADMINISTRATIVELY_PROHIBITED |
Host administratively prohibited |
NETWORK_UNREACHABLE_FOR_TOS |
Network unreachable for TOS |
HOST_UNREACHABLE_FOR_TOS |
Host unreachable for TOS |
COMMUNICATION_ADMINISTRATIVELY_PROHIBITED |
Communication administratively prohibited |
HOST_PRECEDENCE_VIOLATION |
Host precedence violation |
PRECEDENCE_CUTOFF_IN_EFFECT |
Precedence cutoff in effect |
SOURCE_QUENCH |
Source quench |
REDIRECT_DATAGRAM_FOR_THE_NETWORK |
Redirect message for the network |
REDIRECT_DATAGRAM_FOR_THE_HOST |
Redirect message for the host |
REDIRECT_DATAGRAM_FOR_THE_TOS_AND_NETWORK |
Redirect message for the TOS and network |
REDIRECT_DATAGRAM_FOR_THE_TOS_AND_HOST |
Redirect message for the TOS and host |
ALTERNATE_HOST_ADDRESS |
Alternate host address |
ECHO_REQUEST |
Echo Request: Ask for a ping! |
UNASSIGNED_ECHO_TYPE_CODE_REQUEST_1 |
Unassigned codes |
UNASSIGNED_ECHO_TYPE_CODE_REQUEST_2 |
Unassigned codes |
ROUTER_ADVERTISEMENT |
Router advertisement |
ROUTER_SOLICITATION |
Router solicitaion |
TRACEROUTE |
Trace route |
ipProtocolNumbers
enum ipProtocolNumbers
IP Protocol Numbers. List from RFC5237 http://www.iana.org/assignments/protocol-numbers/protocol-numbers.txt.
HOPOPT_TCPIP |
IPv6 Hop-by-Hop Option [RFC2460] |
ICMP_TCPIP |
Internet Control Message [RFC792] |
IGMP_TCPIP |
Internet Group Management [RFC1112] |
GGP_TCPIP |
Gateway-to-Gateway [RFC823] |
IPV4_TCPIP |
IPv4 encapsulation [RFC2003] |
ST_TCPIP |
Stream [RFC1190][RFC1819] |
TCP_TCPIP |
Transmission Control [RFC793] |
CBT_TCPIP |
CBT [Tony_Ballardie] |
EGP_TCPIP |
Exterior Gateway Protocol [RFC888][David_Mills] |
IGP_TCPIP |
Any private interior gateway (used by Cisco for their IGRP) [Internet_Assigned_Numbers_Authority] |
BBN_RCC_MON_TCPIP |
BBN RCC Monitoring [Steve_Chipman] |
NVP_II_TCPIP |
Network Voice Protocol [RFC741][Steve_Casner] |
PUP_TCPIP |
PUP [Boggs, D., J. Shoch, E. Taft, and R. Metcalfe, "PUP: An Internetwork Architecture", XEROX Palo Alto Research Center, CSL-79-10, July 1979; also in IEEE Transactions on Communication, Volume COM-28, Number 4, April 1980.][[XEROX]] |
ARGUS_TCPIP |
ARGUS [Robert_W_Scheifler] |
EMCON_TCPIP |
EMCON [<mystery contact>="">] |
XNET_TCPIP |
Cross Net Debugger [Haverty, J., "XNET Formats for Internet Protocol Version 4", IEN 158, October 1980.][Jack_Haverty] |
CHAOS_TCPIP |
Chaos [J_Noel_Chiappa] |
UDP_TCPIP |
User Datagram [RFC768][Jon_Postel] |
MUX_TCPIP |
Multiplexing [Cohen, D. and J. Postel, "Multiplexing Protocol", IEN 90, USC/Information Sciences Institute, May 1979.][Jon_Postel] |
DCN_MEAS_TCPIP |
DCN Measurement Subsystems [David_Mills] |
HMP_TCPIP |
Host Monitoring [RFC869][Robert_Hinden] |
PRM_TCPIP |
Packet Radio Measurement [Zaw_Sing_Su] |
XNS_IDP_TCPIP |
XEROX NS IDP ["The Ethernet, A Local Area Network: Data Link Layer and Physical Layer Specification", AA-K759B-TK, Digital Equipment Corporation, Maynard, MA. Also as: "The Ethernet - A Local Area Network", Version 1.0, Digital Equipment Corporation, Intel Corporation, Xerox Corporation, September 1980. And: "The Ethernet, A Local Area Network: Data Link Layer and Physical Layer Specifications", Digital, Intel and Xerox, November 1982. And: XEROX, "The Ethernet, A Local Area Network: Data Link Layer and Physical Layer Specification", X3T51/80-50, Xerox Corporation, Stamford, CT., October 1980.][[XEROX]] |
TRUNK_1_TCPIP |
Trunk-1 [Barry_Boehm] |
TRUNK_2_TCPIP |
Trunk-2 [Barry_Boehm] |
LEAF_1_TCPIP |
Leaf-1 [Barry_Boehm] |
LEAF_2_TCPIP |
Leaf-2 [Barry_Boehm] |
RDP_TCPIP |
Reliable Data Protocol [RFC908][Robert_Hinden] |
IRTP_TCPIP |
Internet Reliable Transaction [RFC938][Trudy_Miller] |
ISO_TP4_TCPIP |
ISO Transport Protocol Class 4 [RFC905][<mystery contact>="">] |
NETBLT_TCPIP |
Bulk Data Transfer Protocol [RFC969][David_Clark] |
MFE_NSP_TCPIP |
MFE Network Services Protocol [Shuttleworth, B., "A Documentary of MFENet, a National Computer Network", UCRL-52317, Lawrence Livermore Labs, Livermore, California, June 1977.][Barry_Howard] |
MERIT_INP_TCPIP |
MERIT Internodal Protocol [Hans_Werner_Braun] |
DCCP_TCPIP |
Datagram Congestion Control Protocol [RFC4340] |
THREEPC_TCPIP |
Third Party Connect Protocol [Stuart_A_Friedberg] |
IDPR_TCPIP |
Inter-Domain Policy Routing Protocol [Martha_Steenstrup] |
XTP_TCPIP |
XTP [Greg_Chesson] |
DDP_TCPIP |
Datagram Delivery Protocol [Wesley_Craig] |
IDPR_CMTP_TCPIP |
IDPR Control Message Transport Proto [Martha_Steenstrup] |
TPpp_TCPIP |
TP++ Transport Protocol [Dirk_Fromhein] |
IL_TCPIP |
IL Transport Protocol [Dave_Presotto] |
IPV6_TUNNEL_TCPIP |
IPv6 encapsulation [RFC2473] |
SDRP_TCPIP |
Source Demand Routing Protocol [Deborah_Estrin] |
IPV6_Route_TCPIP |
Routing Header for IPv6 [Steve_Deering] |
IPV6_Frag_TCPIP |
Fragment Header for IPv6 [Steve_Deering] |
IDRP_TCPIP |
Inter-Domain Routing Protocol [Sue_Hares] |
RSVP_TCPIP |
Reservation Protocol [RFC2205][RFC3209][Bob_Braden] |
GRE_TCPIP |
Generic Routing Encapsulation [RFC1701][Tony_Li] |
DSR_TCPIP |
Dynamic Source Routing Protocol [RFC4728] |
BNA_TCPIP |
BNA [Gary Salamon] |
ESP_TCPIP |
Encap Security Payload RFC4303] |
AH_TCPIP |
Authentication Header [RFC4302] |
I_NLSP_TCPIP |
Integrated Net Layer Security TUBA [K_Robert_Glenn] |
SWIPE_TCPIP |
IP with Encryption [John_Ioannidis] |
NARP_TCPIP |
NBMA Address Resolution Protocol [RFC1735] |
MOBILE_TCPIP |
IP Mobility [Charlie_Perkins] |
TLSP_TCPIP |
Transport Layer Security Protocol using Kryptonet key management [Christer_Oberg] |
SKIP_TCPIP |
SKIP [Tom_Markson] |
IPV6_ICMP_TCPIP |
ICMP for IPv6 [RFC2460] |
IPV6_NoNxt_TCPIP |
No Next Header for IPv6 [RFC2460] |
IPV6_Opts_TCPIP |
Destination Options for IPv6 [RFC2460] |
CFTP_TCPIP |
CFTP [Forsdick, H., "CFTP", Network Message, Bolt Beranek and Newman, January 1982.][Harry_Forsdick] |
SAT_EXPAK_TCPIP |
SATNET and Backroom EXPAK [Steven_Blumenthal] |
KRYPTOLAN_TCPIP |
Kryptolan [Paul Liu] |
RVD_TCPIP |
MIT Remote Virtual Disk Protocol [Michael_Greenwald] |
IPPC_TCPIP |
Internet Pluribus Packet Core [Steven_Blumenthal] |
SAT_MON_TCPIP |
SATNET Monitoring [Steven_Blumenthal] |
VISA_TCPIP |
VISA Protocol [Gene_Tsudik] |
IPCV_TCPIP |
Internet Packet Core Utility [Steven_Blumenthal] |
CPNX_TCPIP |
Computer Protocol Network Executive [David Mittnacht] |
CPHB_TCPIP |
Computer Protocol Heart Beat [David Mittnacht] |
WSN_TCPIP |
Wang Span Network [Victor Dafoulas] |
PVP_TCPIP |
Packet Video Protocol [Steve_Casner] |
BR_SAT_MON_TCPIP |
Backroom SATNET Monitoring [Steven_Blumenthal] |
SUN_ND_TCPIP |
SUN ND PROTOCOL-Temporary [William_Melohn] |
WB_MON_TCPIP |
WIDEBAND Monitoring [Steven_Blumenthal] |
WB_EXPAK_TCPIP |
WIDEBAND EXPAK [Steven_Blumenthal] |
ISO_IP_TCPIP |
ISO Internet Protocol [Marshall_T_Rose] |
VMTP_TCPIP |
VMTP [Dave_Cheriton] |
SECURE_VMTP_TCPIP |
SECURE-VMTP [Dave_Cheriton] |
VINES_TCPIP |
VINES [Brian Horn] |
TTP_TCPIP |
TTP [Jim_Stevens] |
IPTM_TCPIP |
Protocol Internet Protocol Traffic Manager [Jim_Stevens] |
NSFNET_IGP_TCPIP |
NSFNET-IGP [Hans_Werner_Braun] |
DGP_TCPIP |
Dissimilar Gateway Protocol [M/A-COM Government Systems, "Dissimilar Gateway Protocol Specification, Draft Version", Contract no. CS901145, November 16, 1987.][Mike_Little] |
TCF_TCPIP |
TCF [Guillermo_A_Loyola] |
EIGRP_TCPIP |
EIGRP [Cisco Systems, "Gateway Server Reference Manual", Manual Revision B, January 10, 1988.][Guenther_Schreiner] |
OSPFIGP_TCPIP |
OSPFIGP [RFC1583][RFC2328][RFC5340][John_Moy] |
Sprite_RPC_TCPIP |
Sprite RPC Protocol [Welch, B., "The Sprite Remote Procedure Call System", Technical Report, UCB/Computer Science Dept., 86/302, University of California at Berkeley, June 1986.][Bruce Willins] |
LARP_TCPIP |
Locus Address Resolution Protocol [Brian Horn] |
MTP_TCPIP |
Multicast Transport Protocol [Susie_Armstrong] |
AX25_TCPIP |
AX.25 Frames [Brian_Kantor] |
IPIP_TCPIP |
IP-within-IP Encapsulation Protocol [John_Ioannidis] |
MICP_TCPIP |
Mobile Internetworking Control Pro. [John_Ioannidis] |
SCC_SP_TCPIP |
Semaphore Communications Sec. Pro. [Howard_Hart] |
ETHERIP_TCPIP |
Ethernet-within-IP Encapsulation [RFC3378] |
ENCAP_TCPIP |
Encapsulation Header [RFC1241][Robert_Woodburn] |
GMTP_TCPIP |
GMTP [[RXB5]] |
IFMP_TCPIP |
Ipsilon Flow Management Protocol [Bob_Hinden][November 1995, 1997.] |
PNNI_TCPIP |
PNNI over IP [Ross_Callon] |
PIM_TCPIP |
Protocol Independent Multicast [RFC4601][Dino_Farinacci] |
ARIS_TCPIP |
ARIS [Nancy_Feldman] |
SCPS_TCPIP |
SCPS [Robert_Durst] |
QNX_TCPIP |
QNX [Michael_Hunter] |
A_N_TCPIP |
Active Networks [Bob_Braden] |
IPComp_TCPIP |
IP Payload Compression Protocol [RFC2393] |
SNP_TCPIP |
Sitara Networks Protocol [Manickam_R_Sridhar] |
Compaq_Peer_TCPIP |
Compaq Peer Protocol [Victor_Volpe] |
IPX_in_IP_TCPIP |
IPX in IP [CJ_Lee] |
VRRP_TCPIP |
Virtual Router Redundancy Protocol [RFC5798] |
PGM_TCPIP |
PGM Reliable Transport Protocol [Tony_Speakman] |
L2TP_TCPIP |
Layer Two Tunneling Protocol [RFC3931][Bernard_Aboba] |
DDX_TCPIP |
D-II Data Exchange (DDX) [John_Worley] |
IATP_TCPIP |
Interactive Agent Transfer Protocol [John_Murphy] |
STP_TCPIP |
Schedule Transfer Protocol [Jean_Michel_Pittet] |
SRP_TCPIP |
SpectraLink Radio Protocol [Mark_Hamilton] |
UTI_TCPIP |
UTI [Peter_Lothberg] |
SMP_TCPIP |
Simple Message Protocol [Leif_Ekblad] |
SM_TCPIP |
SM [Jon_Crowcroft] |
PTP_TCPIP |
Performance Transparency Protocol [Michael_Welzl] |
ISIS_TCPIP |
Over IPv4 [Tony_Przygienda] |
FIRE_TCPIP |
[Criag_Partridge] |
CRTP_TCPIP |
Combat Radio Transport Protocol [Robert_Sautter] |
CRUDP_TCPIP |
Combat Radio User Datagram [Robert_Sautter] |
SSCOPMCE_TCPIP |
[Kurt_Waber] |
IPLT_TCPIP |
[[Hollbach]] |
SPS_TCPIP |
Secure Packet Shield [Bill_McIntosh] |
PIPE_TCPIP |
Private IP Encapsulation within IP [Bernhard_Petri] |
SCTP_TCPIP |
Stream Control Transmission Protocol [Randall_R_Stewart] |
FC_TCPIP |
Fibre Channel [Murali_Rajagopal][RFC6172] |
tcbError_t
enum tcbError_t
TCB_ERROR | |
TCB_NO_ERROR |
2.9.4.32.10 Variable Documentation
network_errors
const char* network_errors[]
2.9.4.33 source/tcpv4.c File Reference
This file provides the API implementation for the TCPv4 stack.
#include <stdio.h> #include <stddef.h> #include <string.h> #include "../ipv4.h" #include "../tcpv4.h" #include "../network.h" #include "../../ethernet/physical_layer_interface.h" #include "../tcpip_types.h" #include "../log.h" #include "../tcpip_config.h" #include "../icmp.h"
2.9.4.33.1 Functions
static error_msg TCP_FiniteStateMachine (void)
TCP stack state machine called upon the occurrence of each event (e.g., opening/closing a connection, receiving a TCP packet).
static error_msg TCP_TimoutRetransmit (void)
Retransmits TCP packets after timeout.
static void TCB_Insert (tcpTCB_t *ptr)
Inserts a pointer to the new TCB into the TCB pointer list.
static void TCB_Remove (tcpTCB_t *ptr)
Removes a pointer to a TCB from the TCB pointer list and connects its adjacent items together.
static void TCB_Reset (tcpTCB_t *tcbPtr)
Resets the socket to a known state.
static error_msg TCB_Check (tcpTCB_t *ptr)
Check if there is a pointer to a socket/TCB. If the pointer is in the TCB list, then it is a valid socket.
static error_msg TCP_Snd (tcpTCB_t *tcbPtr)
Internal function of the TCP stack to send a TCP packet.
error_msg TCP_PayloadSave (uint16_t len)
Copies the TCP packet payload to the socket RX buffer. This routine also sends the ACK for the received packet and any data ready to be sent.
static error_msg TCP_ParseTCPOptions (void)
Reads and parses the Options field in the TCP header. This routine reads only the ones that have SYN or SYN + ACK. For the other TCP headers the field will be skipped.
void TCP_Recv (uint32_t remoteAddress, uint16_t length)
Identifies the destination socket and parses the TCP header. This routine is called by the IP layer for each received TCP packet.
void TCP_Init (void)
Initializes TCP structures, meaning certain internal TCP stack variables.
error_msg TCP_SocketInit (tcpTCB_t *tcbPtr)
Initializes the TCB and adds it to the list of TCB pointers. The socket needs to be put in the Closed state. The user is responsible to manage memory allocation and release.
error_msg TCP_SocketRemove (tcpTCB_t *tcbPtr)
Removes the socket pointer from the TCP stack, and the list of TCB pointers, respectively. After calling this routine the memory is ready to be used again.
socketState_t TCP_SocketPoll (tcpTCB_t *socket_ptr)
Provides an interface to read the status of the socket. This routine also checks if the pointer is already in the TCB list. This means that the socket is "in use". If the socket is in the TCB list, the socket status will be returned.
error_msg TCP_Bind (tcpTCB_t *tcbPtr, uint16_t port)
Assigns a port number to the specified socket. This is used for configuring the local port of a socket.
error_msg TCP_Listen (tcpTCB_t *tcbPtr)
Listens for connections on a socket. This routine marks the socket as passive, meaning that it will be used to accept incoming connection requests.
error_msg TCP_Connect (tcpTCB_t *tcbPtr, sockaddr_in4_t *srvaddr)
Starts the client for a particular socket.
error_msg TCP_Close (tcpTCB_t *tcbPtr)
Closes the TCP connection. This initiates the closing sequence for the TCP connection.
error_msg TCP_Send (tcpTCB_t *tcbPtr, uint8_t *data, uint16_t dataLen)
Sends a buffer to a remote machine using a TCP connection. This routine adds the buffer to the socket and the payload is sent as soon as possible.
error_msg TCP_SendDone (tcpTCB_t *tcbPtr)
Checks if the TX buffer was sent. This means that the data was received correctly by the remote machine and the TX buffer memory can be reused by the application.
error_msg TCP_InsertRxBuffer (tcpTCB_t *tcbPtr, uint8_t *data, uint16_t data_len)
Adds the RX buffer to the socket.
int16_t TCP_GetReceivedData (tcpTCB_t *tcbPtr)
Reads the available data from the socket. This routine provides the start address of the received buffer to the user.
int16_t TCP_GetRxLength (tcpTCB_t *tcbPtr)
Checks and returns the number of available bytes received on a socket.
void TCP_Update (void)
Handles the TCP stack time-outs for each available socket. This routine needs to be called periodically.
2.9.4.33.2 Macros
#define logMsg(msg, msgSeverity, msgLogDest)
2.9.4.33.3 Variables
static tcpHeader_t tcpHeader
static uint16_t nextAvailablePort
static uint32_t nextSequenceNumber
static uint32_t receivedRemoteAddress
static uint16_t rcvPayloadLen
static uint16_t tcpMss = 536
static uint16_t tcpDataLength
static uint16_t bytesToSendForRetransmit = 0
static uint8_t * txBufferPtrForRetransmit
static uint32_t localSeqnoForRetransmit
static uint32_t lastAckNumber
2.9.4.33.4 Detailed Description
This file provides the API implementation for the TCPv4 stack.
Transmission Control Protocol version4 (TCPv4) Implementation Source File
2.9.4.33.5 Macro Definition Documentation
logMsg
#define logMsg( msg, msgSeverity, msgLogDest)
2.9.4.33.6 Variable Documentation
bytesToSendForRetransmit
uint16_t bytesToSendForRetransmit = 0[static]
currentTCB
tcpTCB_t* currentTCB
lastAckNumber
uint32_t lastAckNumber[static]
localSeqnoForRetransmit
uint32_t localSeqnoForRetransmit[static]
nextAvailablePort
uint16_t nextAvailablePort[static]
nextSequenceNumber
uint32_t nextSequenceNumber[static]
rcvPayloadLen
uint16_t rcvPayloadLen[static]
receivedRemoteAddress
uint32_t receivedRemoteAddress[static]
tcbList
tcpTCB_t* tcbList
tcbListSize
socklistsize_t tcbListSize
tcpDataLength
uint16_t tcpDataLength[static]
tcpHeader
tcpHeader_t tcpHeader[static]
tcpMss
uint16_t tcpMss = 536[static]
txBufferPtrForRetransmit
uint8_t* txBufferPtrForRetransmit[static]
2.9.4.34 source/tcpv4.h File Reference
#include <stdbool.h> #include "tcpip_types.h"
2.9.4.34.1 Data structures
struct tcpSocket_t
struct tcpTCB_t
Defines TCP Transmission Control Block.
2.9.4.34.2 Functions
void TCP_Init (void)
Initializes TCP structures, meaning certain internal TCP stack variables.
error_msg TCP_SocketInit (tcpTCB_t *tcbPtr)
Initializes the TCB and adds it to the list of TCB pointers. The socket needs to be put in the Closed state. The user is responsible to manage memory allocation and release.
error_msg TCP_SocketRemove (tcpTCB_t *tcbPtr)
Removes the socket pointer from the TCP stack, and the list of TCB pointers, respectively. After calling this routine the memory is ready to be used again.
socketState_t TCP_SocketPoll (tcpTCB_t *socket_ptr)
Provides an interface to read the status of the socket. This routine also checks if the pointer is already in the TCB list. This means that the socket is "in use". If the socket is in the TCB list, the socket status will be returned.
error_msg TCP_Bind (tcpTCB_t *tcbPtr, uint16_t port)
Assigns a port number to the specified socket. This is used for configuring the local port of a socket.
error_msg TCP_Listen (tcpTCB_t *tcbPtr)
Listens for connections on a socket. This routine marks the socket as passive, meaning that it will be used to accept incoming connection requests.
error_msg TCP_Connect (tcpTCB_t *tcbPtr, sockaddr_in4_t *srvaddr)
Starts the client for a particular socket.
error_msg TCP_Close (tcpTCB_t *tcbPtr)
Closes the TCP connection. This initiates the closing sequence for the TCP connection.
error_msg TCP_Send (tcpTCB_t *tcbPtr, uint8_t *data, uint16_t dataLen)
Sends a buffer to a remote machine using a TCP connection. This routine adds the buffer to the socket and the payload is sent as soon as possible.
error_msg TCP_SendDone (tcpTCB_t *tcbPtr)
Checks if the TX buffer was sent. This means that the data was received correctly by the remote machine and the TX buffer memory can be reused by the application.
error_msg TCP_InsertRxBuffer (tcpTCB_t *tcbPtr, uint8_t *data, uint16_t data_len)
Adds the RX buffer to the socket.
int16_t TCP_GetReceivedData (tcpTCB_t *tcbPtr)
Reads the available data from the socket. This routine provides the start address of the received buffer to the user.
int16_t TCP_GetRxLength (tcpTCB_t *tcbPtr)
Checks and returns the number of available bytes received on a socket.
void TCP_Update (void)
Handles the TCP stack time-outs for each available socket. This routine needs to be called periodically.
2.9.4.34.3 Macros
#define TCP_FIN_FLAG 0x01U
#define TCP_SYN_FLAG 0x02U
#define TCP_RST_FLAG 0x04U
#define TCP_PSH_FLAG 0x08U
#define TCP_ACK_FLAG 0x10U
#define TCP_URG_FLAG 0x20U
#define TCP_ECE_FLAG 0x40U
#define TCP_CWR_FLAG 0x80U
2.9.4.34.4 Enumerations
enum tcp_fsm_states_t { CLOSED = 0, LISTEN, SYN_SENT, SYN_RECEIVED, ESTABLISHED, FIN_WAIT_1, FIN_WAIT_2, CLOSE_WAIT, CLOSING, LAST_ACK, TIME_WAIT }
TCP Finite State Machine (FSM) states.
enum tcpEvent_t { CLOSE = 0, ACTIVE_OPEN, PASIVE_OPEN, RCV_SYN, RCV_ACK, RCV_SYNACK, RCV_FIN, RCV_FINACK, RX_PACKET, RCV_RST, RCV_RSTACK, RCV_PSHACK, TIMEOUT, NOP }
TCP events.
enum socketState_t { NOT_A_SOCKET = 0, SOCKET_CLOSED, SOCKET_IN_PROGRESS, SOCKET_CONNECTED, SOCKET_CLOSING }
Socket states to be used in the application.
enum tcpBufferState_t { NO_BUFF = 0, RX_BUFF_IN_USE, TX_BUFF_IN_USE }
TCP Buffer state.
enum tcp_options_t { TCP_EOP = 0u, TCP_NOP = 1u, TCP_MSS = 2u }
TCP options.
2.9.4.34.5 Detailed Description
Transmission Control Protocol (TCP) v4 Header File
2.9.4.34.6 Macro Definition Documentation
TCP_ACK_FLAG
#define TCP_ACK_FLAG 0x10U
TCP_CWR_FLAG
#define TCP_CWR_FLAG 0x80U
TCP_ECE_FLAG
#define TCP_ECE_FLAG 0x40U
TCP_FIN_FLAG
#define TCP_FIN_FLAG 0x01U
TCP_PSH_FLAG
#define TCP_PSH_FLAG 0x08U
TCP_RST_FLAG
#define TCP_RST_FLAG 0x04U
TCP_SYN_FLAG
#define TCP_SYN_FLAG 0x02U
TCP_URG_FLAG
#define TCP_URG_FLAG 0x20U
2.9.4.35 source/tftp.c File Reference
This file provides the API implementation of the TFTP client.
#include <string.h> #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <stdbool.h> #include "../tcpip_types.h" #include "../tcpip_config.h" #include "../tftp.h" #include "../tftp_handler_table.h" #include "../udpv4.h"
2.9.4.35.1 Functions
void TFTP_Configure (uint32_t tftp_server_address, char *tftp_filename, char *tftp_block_size)
Allows the user to configure the TFTP server options.
error_msg TFTP_Read_Write_Request (uint8_t opcode)
Sends a read or write request to the TFTP server depending on the opcode.
void TFTP_Ack (uint8_t opcode)
Sends an acknowledgement on receiving a packet from a TFTP Server.
void TFTP_Handler (int16_t length)
Processes a TFTP message as per the opcode in the packet.
void Process_TFTP_Data (uint32_t address, char *data, uint16_t length)
Processes TFTP packets with 'data' opcode and blocks of the specified size. Depending on TFTP_callBackTable, the storage can be in EEPROM, Flash, etc.
2.9.4.35.2 Macros
#define TFTP_OPCODE_SIZE 2
#define TFTP_PACKET_SIZE (TFTP_OPCODE_SIZE + 2)
#define TFTP_BLOCK_SIZE 2
2.9.4.35.3 Variables
const char * tftp_modes [] = {"netascii", "octet", "mail"}
const char tftp_option [] = "blksize"
volatile bool last_block = false
static uint16_t current_block = 0x0000
static uint16_t prev_block = 0x0000
static uint16_t next_block = 0x0000
uint32_t tftp_last_address = 0x00020000
2.9.4.35.4 Detailed Description
This file provides the API implementation of the TFTP client.
TFTP client Implementation Source File
2.9.4.35.5 Macro Definition Documentation
TFTP_BLOCK_SIZE
#define TFTP_BLOCK_SIZE 2
TFTP_OPCODE_SIZE
#define TFTP_OPCODE_SIZE 2
TFTP_PACKET_SIZE
#define TFTP_PACKET_SIZE (TFTP_OPCODE_SIZE + 2)
2.9.4.35.6 Variable Documentation
current_block
uint16_t current_block = 0x0000[static]
last_block
volatile bool last_block = false
next_block
uint16_t next_block = 0x0000[static]
prev_block
uint16_t prev_block = 0x0000[static]
tftp_last_address
uint32_t tftp_last_address = 0x00020000
tftp_modes
const char* tftp_modes[] = {"netascii", "octet", "mail"}
tftp_msg
tftp_t tftp_msg
tftp_option
const char tftp_option[] = "blksize"
2.9.4.36 source/tftp.h File Reference
#include <stdbool.h>
2.9.4.36.1 Data structures
struct tftp_t
2.9.4.36.2 Functions
void TFTP_Ack (uint8_t opcode)
Sends an acknowledgement on receiving a packet from a TFTP Server.
error_msg TFTP_Read_Write_Request (uint8_t opcode)
Sends a read or write request to the TFTP server depending on the opcode.
void TFTP_Handler (int16_t length)
Processes a TFTP message as per the opcode in the packet.
void Process_TFTP_Data (uint32_t address, char *data, uint16_t length)
Processes TFTP packets with 'data' opcode and blocks of the specified size. Depending on TFTP_callBackTable, the storage can be in EEPROM, Flash, etc.
void TFTP_Configure (uint32_t tftp_server_address, char *tftp_filename, char *tftp_block_size)
Allows the user to configure the TFTP server options.
2.9.4.36.3 Macros
#define DESTPORT_TFTP 69
2.9.4.36.4 Enumerations
enum tftp_client_state { tftp_read = 1, tftp_write, tftp_data, tftp_ack, tftp_error, tftp_optack }
TFTP Client state.
enum tftp_opcode { TFTP_READ_REQUEST =0x0001, TFTP_WRITE_REQUEST, TFTP_DATA, TFTP_ACK, TFTP_ERROR, TFTP_OPTACK }
TFTP opcode.
2.9.4.36.5 Variables
uint32_t tftp_last_address
volatile bool last_block
2.9.4.36.6 Detailed Description
TFTP Client Protocol Header File
2.9.4.36.7 Macro Definition Documentation
DESTPORT_TFTP
#define DESTPORT_TFTP 69
2.9.4.36.8 Variable Documentation
last_block
volatile bool last_block
tftp_last_address
uint32_t tftp_last_address
tftp_msg
tftp_t tftp_msg
2.9.4.37 source/tftp_handler_table.h File Reference
This file contains the TFTP application callback table.
#include <stdint.h>
2.9.4.37.1 Data structures
struct store_handler_t
Storage handler.
2.9.4.37.2 Macros
#define tableSize (sizeof(TFTP_callBackTable)/sizeof(*TFTP_callBackTable))
#define DEFAULT 0
#define EEPROM 1
#define EXTERNAL_STORAGE 2
2.9.4.37.3 Typedefs
typedef uint8_t(* TFTP_receive_function_ptr) (uint32_t, char *, uint16_t)
2.9.4.37.4 Variables
uint16_t store_type = 0
const store_handler_t TFTP_callBackTable []
2.9.4.37.5 Detailed Description
This file contains the TFTP application callback table.
TFTP Port Handler Header File
2.9.4.37.6 Macro Definition Documentation
DEFAULT
#define DEFAULT 0
EEPROM
#define EEPROM 1
EXTERNAL_STORAGE
#define EXTERNAL_STORAGE 2
tableSize
#define tableSize (sizeof(TFTP_callBackTable)/sizeof(*TFTP_callBackTable))
2.9.4.37.7 Typedef Documentation
TFTP_receive_function_ptr
typedef uint8_t(* TFTP_receive_function_ptr) (uint32_t, char *, uint16_t)
2.9.4.37.8 Variable Documentation
TFTP_callBackTable
const store_handler_t TFTP_callBackTable[]
Initial value:
= { }
2.9.4.38 source/udpv4.c File Reference
This file provides the API implementation for the User Datagram Protocol version 4 (UDP v4).
#include <stdio.h> #include <stdbool.h> #include <stddef.h> #include "../ipv4.h" #include "../udpv4.h" #include "../udpv4_port_handler_table.h" #include "../network.h" #include "../../ethernet/physical_layer_interface.h" #include "../tcpip_types.h" #include "../icmp.h"
2.9.4.38.1 Functions
2.9.4.38.2 Variables
uint16_t destPort
2.9.4.38.3 Detailed Description
This file provides the API implementation for the User Datagram Protocol version 4 (UDP v4).
UDP Protocol v4 Source File
2.9.4.38.4 Variable Documentation
destPort
uint16_t destPort
udpHeader
udpHeader_t udpHeader
2.9.4.39 source/udpv4.h File Reference
#include <stdbool.h> #include "tcpip_types.h" #include "../ethernet/physical_layer_interface.h"
2.9.4.39.1 Functions
2.9.4.39.2 Macros
#define UDP_ReadBlock(data, length) ETH_ReadBlock(data,length)
#define UDP_Read8() ETH_Read8()
#define UDP_Read16() ETH_Read16()
#define UDP_Read24() ETH_Read24()
#define UDP_Read32() ETH_Read32()
#define UDP_Write8(data) ETH_Write8(data)
#define UDP_Write16(data) ETH_Write16(data)
#define UDP_Write24(data) ETH_Write24(data)
#define UDP_Write32(data) ETH_Write32(data)
#define UDP_WriteBlock(data, length) ETH_WriteBlock(data,length)
#define UDP_WriteString(data) ETH_WriteString(data)
#define UDP_GetDestPort() (destPort)
#define UDP_GetSrcPort() (udpHeader.dstPort)
#define UDP_GetDestIP() (ipv4Header.srcIpAddress)
#define UDP_GetSrcIP() (ipv4Header.dstIpAddress)
#define UDP_DataLength() ((udpHeader.length) - 8)
#define UDP_FlushTXPackets() ETH_TxReset()
#define UDP_FlushRxdPacket() ETH_Flush()
2.9.4.39.3 Variables
uint16_t destPort
2.9.4.39.4 Detailed Description
UDP v4 Protocol Header File
2.9.4.39.5 Macro Definition Documentation
UDP_DataLength
#define UDP_DataLength( ) ((udpHeader.length) - 8)
UDP_FlushRxdPacket
#define UDP_FlushRxdPacket( ) ETH_Flush()
UDP_FlushTXPackets
#define UDP_FlushTXPackets( ) ETH_TxReset()
UDP_GetDestIP
#define UDP_GetDestIP( ) (ipv4Header.srcIpAddress)
UDP_GetDestPort
#define UDP_GetDestPort( ) (destPort)
UDP_GetSrcIP
#define UDP_GetSrcIP( ) (ipv4Header.dstIpAddress)
UDP_GetSrcPort
#define UDP_GetSrcPort( ) (udpHeader.dstPort)
UDP_Read16
#define UDP_Read16( ) ETH_Read16()
UDP_Read24
#define UDP_Read24( ) ETH_Read24()
UDP_Read32
#define UDP_Read32( ) ETH_Read32()
UDP_Read8
#define UDP_Read8( ) ETH_Read8()
UDP_ReadBlock
#define UDP_ReadBlock( data, length) ETH_ReadBlock(data,length)
UDP_Write16
#define UDP_Write16( data) ETH_Write16(data)
UDP_Write24
#define UDP_Write24( data) ETH_Write24(data)
UDP_Write32
#define UDP_Write32( data) ETH_Write32(data)
UDP_Write8
#define UDP_Write8( data) ETH_Write8(data)
UDP_WriteBlock
#define UDP_WriteBlock( data, length) ETH_WriteBlock(data,length)
UDP_WriteString
#define UDP_WriteString( data) ETH_WriteString(data)
2.9.4.39.6 Variable Documentation
destPort
uint16_t destPort
ipv4Header
ipv4Header_t ipv4Header
udpHeader
udpHeader_t udpHeader
2.9.4.40 source/udpv4_port_handler_table.c File Reference
This file provides the API implementation for the UDP v4 protocol.
#include <stdio.h> #include "../tcpip_config.h" #include "../dns_client.h" #include "../dhcp_client.h" #include "../ntp.h" #include "../udpv4_port_handler_table.h" #include "../tftp.h"
2.9.4.40.1 Functions
udp_table_iterator_t udp_table_getIterator (void)
Returns the UDP table iterator.
udp_table_iterator_t udp_table_nextEntry (udp_table_iterator_t i)
Returns the UDP table next entry.
2.9.4.40.2 Variables
const udp_handler_t UDP_CallBackTable []
2.9.4.40.3 Detailed Description
This file provides the API implementation for the UDP v4 protocol.
UDP Port Handler Source File
2.9.4.40.4 Variable Documentation
UDP_CallBackTable
const udp_handler_t UDP_CallBackTable[]
Initial value:
= { {53, DNS_Handler}, {68, DHCP_Handler}, {123, NTP_Handler}, {SOURCEPORT_TFTP, TFTP_Handler}, }
2.9.4.41 source/udpv4_port_handler_table.h File Reference
This file contains the UDP callback table.
#include "tcpip_types.h"
2.9.4.41.1 Data structures
struct udp_handler_t
UDP handler types.
2.9.4.41.2 Functions
udp_table_iterator_t udp_table_getIterator (void)
Returns the UDP table iterator.
udp_table_iterator_t udp_table_nextEntry (udp_table_iterator_t i)
Returns the UDP table next entry.
2.9.4.41.3 Variables
const typedef udp_handler_t * udp_table_iterator_t
2.9.4.41.4 Detailed Description
This file contains the UDP callback table.
UDP Port Handler Header File
2.9.4.41.5 Variable Documentation
udp_table_iterator_t
const typedef udp_handler_t* udp_table_iterator_t