⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 socket.h

📁 dvr
💻 H
字号:
/*
********************************************************************************
*
* (c) Copyright 2002, Vineyard Technologies, Inc.
*
* Filename : socket.h
* Programmer(s): Steve KyeongHyeon Lee
* Created : 2003/02/17
* Modified :
*
* Description : Header file of W3100A for 8052 core
********************************************************************************
*/
#include "types.h"	// Our global types

#ifdef LANIF

#ifndef	__SOCKET_H__
#define	__SOCKET_H__


/*
###############################################################################
Public types of socket
###############################################################################
*/

//typedef unsigned char  u_char;
//typedef unsigned short u_int;
//typedef unsigned long  u_long;
//typedef unsigned int   UINT;

typedef unsigned char SOCKET;

/* Type for treating 4 byte variables with byte by byte */
typedef union un_l2cval {
	u32	lVal;
	u8	cVal[4];
};

/* Type for treating 2 byte variables with byte by byte */
typedef union un_i2cval {
	u16	iVal;
	u8	cVal[2];
};

#define VIDEO_BUF_SIZE		2048			// 4096			// 2048
#define VIDEO_BUF_SZMK		0x000007FF		// 0x00000FFF	// 0x000007FF


/* Interrupt Status Variables */
#define SSYS_INIT_OK	0x01			// Completion of CSYS_INIT command
#define SSOCK_INIT_OK	0x02			// Completion of CSOCK_INIT command
#define SESTABLISHED	0x04			// Completion of connection setup
#define SCLOSED			0x08			// Completion of CCLOSED command
#define STIMEOUT		0x10			// Timeout
#define SSEND_OK		0x20			// Completion of sending data
#define SRECV_OK		0x40			// Completion of receiving data

/* Distinguish TCP / UDP / IP RAW / MAC RAW (Setting OPT_PROTOCOL REG.) */
#define	SOCK_CLOSEDM	0x00			// unused socket
#define	SOCK_STREAM		0x01			// TCP
#define	SOCK_DGRAM		0x02			// UDP
#define	SOCK_IPL_RAW	0x03			// IP LAYER RAW SOCK
#define	SOCK_MACL_RAW	0x04			// MAC LAYER RAW SOCK

/* Setting IP PROTOCOL */
#define IPPROTO_IP      0               // dummy for IP 
#define IPPROTO_ICMP    1               // control message protocol 
#define IPPROTO_IGMP    2               // internet group management protocol 
#define IPPROTO_GGP     3               // gateway^2 (deprecated) 
#define IPPROTO_TCP     6               // tcp 
#define IPPROTO_PUP     12              // pup
#define IPPROTO_UDP     17              // user datagram protocol 
#define IPPROTO_IDP     22              // xns idp 
#define IPPROTO_ND      77              // UNOFFICIAL net disk proto
#define IPPROTO_RAW     255             // raw IP packet 

/* Select parameter to use */
#define SEL_CONTROL		0				//Confirm socket status
#define SEL_SEND		1				// Confirm Tx free buffer size
#define SEL_RECV		2				// Confirm Rx data size

/* Socket Status Vabiables */
#define SOCK_CLOSED			0x00		// Status of connection closed
#define SOCK_ARP			0x01		// Status of ARP
#define SOCK_LISTEN			0x02		// Status of waiting for TCP connection setup
#define SOCK_SYNSENT		0x03		// Status of setting up TCP connection
#define SOCK_SYNSENT_ACK	0x04		// Status of setting up TCP connection
#define SOCK_SYNRECV		0x05		// Status of setting up TCP connection
#define SOCK_ESTABLISHED	0x06		// Status of TCP connection established
#define SOCK_CLOSE_WAIT		0x07		// Status of closing TCP connection
#define SOCK_LAST_ACK		0x08		// Status of closing TCP connection
#define SOCK_FIN_WAIT1		0x09		// Status of closing TCP connection
#define SOCK_FIN_WAIT2		0x0A		// Status of closing TCP connection
#define SOCK_CLOSING		0x0B		// Status of closing TCP connection
#define SOCK_TIME_WAIT		0x0C		// Status of closing TCP connection
#define SOCK_RESET			0x0D		// Status of closing TCP connection
#define SOCK_INIT			0x0E		// Status of socket initialization
#define SOCK_UDP			0x0F		// Status of UDP
#define SOCK_RAW			0x10		// Status of IP RAW


#define SEND_NODELAY	0x00
#define SEND_DELAY		0x01
/*
###############################################################################
Public function prototypes
###############################################################################
*/
void 	SOCK_ISR_W3100A(u8* status);
void 	SOCK_softreset_W3100A(u32 seqnum);
void 	SOCK_setsubmask(u8 * addr);
void 	SOCK_setgateway(u8 * addr);
void 	SOCK_setMACAddr(u8 * addr);
void 	SOCK_setIP(u8 * addr);
void 	SOCK_sysinit(void);
void	SOCK_update_mac(void);
u8	 	SOCK_setINTMask(u8 mask);
//void 	SOCK_setINTMask_enable(void);
void 	SOCK_settimeout(u8 * val);
char 	SOCK_socket(SOCKET s, u8 protocol, u16 port, u8 flag);
void 	SOCK_close(SOCKET s);
u16 	SOCK_select(SOCKET s, u8 func);
void 	SOCK_NBlisten(SOCKET s);
void 	SOCK_get_netbuf_addr(u8* addr_h, u8* addr_l);
void	SOCK_send_enable(SOCKET s);

int 	SOCK_send(SOCKET s, u8 * buf, u16 len, u8 flag, u8 isTcp);
int 	SOCK_recv(SOCKET s, u8 * buf, u16 len);
void	SOCK_getDIP(SOCKET s, u8* dip);

#ifdef DEBUG_IDM_AUTO
void idm_auto_inc_test(void);
#endif

#ifdef DEBUG_LANRPT
void SOCK_dump_channel(u8 i);
//void SOCK_dump_config(void);
#endif

#ifdef DEBUG_WIZINT
extern xdata u8 debug_wizint_ch;
extern xdata u8 debug_wizint_stat;
#endif

u8 		idmr(u16 addr);
void 	idmw(u16 addr, u8 val);
void	idm_save(void);
void	idm_restore(void);


#ifdef DEBUG_CTRL_RX_CNT
extern xdata u16 gv_socket_ctrl_rx_cnt;
#endif

#endif	// __SOCKET_H__

#endif // LANIF

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -