/********************************************************************************* File: opentcp.h Date: 22.1.2004 Version: 0.1 Author: Jari Lahti (jari.lahti@violasystems.com) Description: General definions, bindings and includes of OpenTCP. Processor depended stuff like enable/disable IRQs. Helper functions. Version Info: 22.1.2004 - First version (JaL) *********************************************************************************/ #ifndef __INCLUDE_OPENTCP_H__ #define __INCLUDE_OPENTCP_H__ /* target specific */ #include "mcf5xxx.h" #include "runtm.h" /* motorola fec driver */ #include "nbuf.h" #include "nif.h" #include "fec.h" #include "datatypes.h" #include "eth_stub.h" #include "debug.h" #include "timers.h" #include "tcp_ip.h" #include "arp.h" #include "http.h" #include "firewall.h" #include "bootp.h" #include "tftps.h" #include "smtp_client.h" #include "pop3_client.h" /* System functions */ #define RESET_SYSTEM() {} #define DISABLE_INTERRUPTS() {} #define ENABLE_INTERRUPTS() {} #define DISABLE_TIMER_IRQ() {} #define ENABLE_TIMER_IRQ() {} #if 0 #define DISABLE_TIMER_IRQ() MCF5282_INTC0_IMRH |= MCF5282_INTC_IMRH_INT55 #define ENABLE_TIMER_IRQ() MCF5282_INTC0_IMRH &= ~MCF5282_INTC_IMRH_INT55 #define DISABLE_TIMER_IRQ() MCF_INTC0_IMRH |= MCF_INTC0_IMRH_INT_MASK36 #define ENABLE_TIMER_IRQ() MCF_INTC0_IMRH &= ~MCF_INTC0_IMRH_INT_MASK36 #endif /* the network interface for motorola code */ extern NIF fec_nif; /* and for OpenTCP internals */ extern struct netif localmachine; /* rx & tx ethernet frames on OpenTCP */ extern struct otcp_ethframe otcp_rxframe; /* Frame we receive */ extern struct otcp_ethframe otcp_txframe; /* Frame we send */ /* rx & tx IP frames on OpenTCP */ extern struct IPFrame ReceivedIPPacket; extern struct IPFrame SendIPPacket; /* Network tx assemble buf */ extern UINT8 otcp_netbuf[]; #define OTCP_TXBUF otcp_netbuf /* TCP frame */ extern struct TCPFrame ReceivedTCPPacket; /* Bindings of OpenTCP network macros */ #define RECEIVE_NETWORK_B() eth_stub_read(&fec_nif) #define RECEIVE_NETWORK_BUF(c,d) eth_stub_read_buf(&fec_nif, c, d) #define SEND_NETWORK_B(c) eth_stub_write(&fec_nif, c) #define SEND_NETWORK_BUF(c,d) eth_stub_write_buf(&fec_nif, c, d) #define NETWORK_CHECK_IF_RECEIVED() eth_stub_isframe(&fec_nif) #define NETWORK_RECEIVE_INITIALIZE(c) eth_stub_seekread(&fec_nif, c) #define NETWORK_RECEIVE_END() eth_stub_dumpframe(&fec_nif) #define NETWORK_SEND_INITIALIZE(c) eth_stub_txalloc(&fec_nif) #define NETWORK_ADD_DATALINK(c) eth_stub_writeheader(&fec_nif, c) #define NETWORK_COMPLETE_SEND(c) eth_stub_send(&fec_nif, c) /* Helper functions */ /******************************************************************************** Function: otcp_strlen Parameters: UINT8* str - start address of string buffer UINT16 len - buffer length Return val: INT16 - (-1) Not a string (>=0) Length of string Date: 12.8.2002 Desc: Calculates the length of given string *********************************************************************************/ INT16 otcp_strlen(UINT8* buf, UINT16 len); /******************************************************************************** Function: otcp_bufsearch Parameters: UINT8* startadr - start address of given buffer UINT16 len - buffer length UINT8* str - given searchstring UINT8 caps - 0-actual(case sensitive), 1-case insensitive Return val: INT16 - (-1) Not found (>=0) Start of matched string from startadr Date: 12.7.2002 Desc: Seeks given string from given buffer *********************************************************************************/ INT16 otcp_bufsearch(UINT8* startadr, UINT16 len, UINT8* str, UINT8 caps); /******************************************************************************** Function: otcp_toupper Parameters: UINT8 ch - ASCII character to be converted UPPERCASE Return val: UINT8 - converted character Date: 21.8.2002 Desc: If ch is lowercase letter it is converted to UPPERCASE and returned. Otherwise original character is returned *********************************************************************************/ UINT8 otcp_toupper(UINT8 ch); /******************************************************************************** Function: otcp_tolower Parameters: UINT8 ch - ASCII character to be converted lowercase Return val: UINT8 - converted character Date: 21.8.2002 Desc: If ch is UPPERCASE letter it is converted to lowercase and returned. Otherwise original character is returned *********************************************************************************/ UINT8 otcp_tolower(UINT8 ch); /* Convert ASCII character to numerical */ /* e.g. '1' -> 0x01, 'A' ->0x0A */ UINT8 otcp_asciitohex(UINT8 ch); /* Take one byte and return its two ASCII */ /* values for both nibbles */ UINT16 otcp_hextoascii(UINT8 c); /* Is the given ASCII code numerical */ /* e.g. '0','1','2' ... '9' */ UINT8 otcp_isnumeric(UINT8 ch); /* Long to Ascii */ void otcp_ltoa(UINT32 nmbr, UINT8 *ch ); #endif //guard /* EOF */