📄 eth_stub.h
字号:
/***************************************************************************************
File: eth_stub.h
Date: 22.1.2004
Version: 0.1
Author: Jari Lahti (jari.lahti@violasystems.com)
Description: Wrapper functions between Motorola fec & nif code and OpenTCP
internals
Version Info: 22.1.2004 - First version (JaL)
***************************************************************************************/
#ifndef __INCLUDE_ETH_STUB_H__
#define __INCLUDE_ETH_STUB_H__
#include "datatypes.h"
/* Symbolic constants */
#define ETH_ADDRESS_LEN 6
/* Structure for passing frame fields */
struct otcp_ethframe
{
UINT8 destination[ETH_ADDRESS_LEN];
UINT8 source[ETH_ADDRESS_LEN];
UINT16 framesize;
UINT16 protocol;
UINT16 bufindex;
};
/* Frame we receive */
extern struct otcp_ethframe otcp_rxframe;
/* Frame we send */
extern struct otcp_ethframe otcp_txframe;
/********************************************************************************
Function: eth_stub_init
Parameters: void
Return val: void
Date: 22.1.2004
Desc: Call this function on init before entering to main loop.
Just initializes the eth_wrapper
*********************************************************************************/
void eth_stub_init(void);
/********************************************************************************
Function: opentcp_fechandler
Parameters: NIF *nif - network interface
Return val: void
Date: 22.1.2004
Desc: This function is called by nif_protocol_handler in order to
supply received Ethernet packet. We just increase the number of
unprocessed packets OpenTCP to poll.
*********************************************************************************/
void opentcp_fechandler(NIF *nif);
/********************************************************************************
Function: eth_stub_isframe
Parameters: NIF *nif - network interface
Return val: INT16 : (<0) - Error
(0) - No pending frames
(>0) - There are pending frames
Date: 22.1.2004
Desc: Checks do we have any pending frame
*********************************************************************************/
INT16 eth_stub_isframe(NIF *nif);
/********************************************************************************
Function: eth_stub_dumpframe
Parameters: NIF *nif - network interface
Return val: INT16 : (<0) - Error
(=>0) - OK, frame released
Date: 22.1.2004
Desc: Releases the frame and decreases the number of pending packets
*********************************************************************************/
INT16 eth_stub_dumpframe(NIF *nif);
/********************************************************************************
Function: eth_stub_seekread
Parameters: NIF *nif - network interface
UINT16 pos - position from the start of read buffer
Return val: INT16 : (<0) - Error
(=>0) - OK
Date: 22.1.2004
Desc: Moves the read pointer to the given position from start
*********************************************************************************/
INT16 eth_stub_seekread(NIF *nif, UINT16 pos);
/********************************************************************************
Function: eth_stub_read
Parameters: NIF *nif - network interface
Return val: UINT8 - read data
Date: 22.1.2004
Desc: Return one byte of data from rx buffer and advances read pointer.
TODO:More efficient to make this a MACRO
*********************************************************************************/
UINT8 eth_stub_read(NIF *nif);
/********************************************************************************
Function: eth_stub_read_buf
Parameters: NIF *nif - network interface
UINT8* buf - buffer for data
UINT16 buflen - number of bytes requested
Return val: INT16: (-1) - Error
(>=0) - Number of bytes read
Date: 22.1.2004
Desc: Reads multiple bytes from rx buffer and advances read pointer
*********************************************************************************/
INT16 eth_stub_read_buf(NIF *nif, UINT8* buf, UINT16 buflen);
/********************************************************************************
Function: eth_stub_txalloc
Parameters: NIF *nif - network interface
Return val: INT16: (-1) - Error
(>=0) - OK, tx buffer allocated
Date: 22.1.2004
Desc: Allocates tx buffer from nbuf
*********************************************************************************/
INT16 eth_stub_txalloc(NIF *nif);
/********************************************************************************
Function: eth_stub_writeheader
Parameters: NIF *nif - network interface
struct otcp_ethframe* frame - ethernet header info
Return val: INT16: (-1) - Error
(>=0) - OK
Date: 22.1.2004
Desc: Writes ethernet header to tx buffer
*********************************************************************************/
INT16 eth_stub_writeheader(NIF *nif, struct otcp_ethframe* frame);
/********************************************************************************
Function: eth_stub_send
Parameters: NIF *nif - network interface
UINT16 len - length of packet without the eth header & CRR
Return val: INT16: (-1) - Error
(>=0) - OK (number of bytes written)
Date: 22.1.2004
Desc: Sends the ethernet frame
*********************************************************************************/
INT16 eth_stub_send(NIF *nif, UINT16 len);
/********************************************************************************
Function: eth_stub_write
Parameters: NIF *nif - network interface
UINT8 dat - data byte to write
Return val: INT16: (-1) - Error
(>=0) - OK (number of bytes written)
Date: 22.1.2004
Desc: Writes single byte to tx buffer and increases write pointer
*********************************************************************************/
INT16 eth_stub_write(NIF *nif, UINT8 dat);
/********************************************************************************
Function: eth_stub_write_buf
Parameters: NIF *nif - network interface
UINT8* buf - data to write
UINT16 buflen - number of bytes to write
Return val: INT16: (-1) - Error
(>=0) - OK (number of bytes written)
Date: 22.1.2004
Desc: Writes multiple bytes to tx buffer and increases write pointer
*********************************************************************************/
INT16 eth_stub_write_buf(NIF *nif, UINT8* buf, UINT16 buflen);
#endif
/* EOF */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -