source: edk_user_repository/WARP/sw_services/WARPxilnet_v2_00_a/src/include/net/xilsock.h

Last change on this file was 526, checked in by murphpo, 17 years ago

Adding custom version of Xilinx's xilnet (WARPxilnet); it's required for the PHY prototyping project

File size: 5.4 KB
Line 
1////////////////////////////////////////////////////////////////////////////////
2// Copyright (c) 2004 Xilinx, Inc.  All rights reserved.
3//
4// Xilinx, Inc.
5// XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A
6// COURTESY TO YOU.  BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS
7// ONE POSSIBLE   IMPLEMENTATION OF THIS FEATURE, APPLICATION OR
8// STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION
9// IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE
10// FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION.
11// XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO
12// THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO
13// ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE
14// FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY
15// AND FITNESS FOR A PARTICULAR PURPOSE.
16//
17// File   : xilsock.h
18// Date   : 2002, March 20.
19// Author : Sathya Thammanur
20// Company: Xilinx
21// Group  : Emerging Software Technologies
22//
23// Summary:
24// Header file for Xilinx internal socket structure definitions
25//
26// $Id: xilsock.h,v 1.2.8.6 2005/11/15 23:41:10 salindac Exp $
27//
28////////////////////////////////////////////////////////////////////////////////
29
30#ifndef _XILSOCK_H_
31#define _XILSOCK_H_
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37#include <net/eth.h>
38#include <net/arp.h>
39#include <net/ip.h>
40#include <net/tcp.h>
41#include <net/udp.h>
42#include <net/icmp.h>
43#include <net/in.h>
44#include <net/socket.h>
45#include <string.h>
46
47// definitions for connections
48#define TRUE                  1
49#define FALSE                 0
50
51/* Data Link Layer definitions
52 * Add #if's for PPP header lengths
53 */
54
55#define LINK_HDR_LEN          ETH_HDR_LEN
56#define LINK_FRAME_LEN     ETH_FRAME_LEN
57
58// msg structure
59struct xilsock_buf {
60   unsigned char *buf;
61   int size;
62};
63
64
65// internal socket structure
66struct xilsock_socket {
67   int type;
68   int domain;
69   int proto;
70   // status of socket
71   unsigned char listen:1;
72   unsigned char bound:1;
73   unsigned char accept:1;
74   unsigned char connect:1;
75   unsigned char free:1;
76   unsigned char closing:1;
77   unsigned char closed:1;
78   union {
79      struct xilnet_tcp_conn *tcp_conn;
80      struct xilnet_udp_conn *udp_conn;
81   } conn;
82   int *if_addr;                 // interface base addr
83   struct xilsock_buf recvbuf;     // structure for recv/send msgs
84};
85
86#define NO_OF_XILSOCKS   (MAX_TCP_CONNS+MAX_UDP_CONNS)
87extern struct xilsock_socket xilsock_sockets[NO_OF_XILSOCKS];
88
89
90/* #defines for TCP communication */
91#define XILSOCK_NEW_CONN        0x1
92#define XILSOCK_SYNACK_RCVD     0x2
93#define XILSOCK_TCP_DATA        0x4
94#define XILSOCK_TCP_ACK         0x8
95#define XILSOCK_EXISTING_CONN   0x10
96#define XILSOCK_CLOSE_CONN      0x20
97
98/* Functions of xilsock sockets */
99
100//#define xilsock_recvfrom xilsock_recv
101
102extern int xilsock_init(void);
103extern void xilsock_rel_socket(int);
104extern int xilsock_socket(int, int, int);
105extern int xilsock_bind(int, struct sockaddr*, int);
106extern int xilsock_listen(int, int);
107extern int xilsock_accept(int, struct sockaddr*, int*);
108extern int xilsock_recv(int, unsigned char*, unsigned int);
109extern int xilsock_recvfrom(int, unsigned char*, unsigned int, struct sockaddr* from, unsigned int *fromlen);
110extern int xilsock_sendto(int, unsigned char*, unsigned int, struct sockaddr* to, unsigned int tolen);
111extern int xilsock_send(int, unsigned char*, unsigned int);
112extern void xilsock_close(int);
113
114/*
115 * TCP/IP functions Prototype
116 */
117
118// Ethernet functions
119extern int xilnet_eth_recv_frame(unsigned char *, int);
120extern int xilnet_eth_send_frame(unsigned char *, int, unsigned char*, void*, unsigned short);
121extern void xilnet_eth_update_hw_tbl(unsigned char *, int);
122extern void xilnet_add_hw_tbl_entry(unsigned char *, unsigned char *);
123extern int xilnet_eth_get_hw_addr(unsigned char *);
124extern void xilnet_eth_init_hw_addr_tbl(void);
125extern int xilnet_eth_find_old_entry(void);
126
127// ARP functions
128extern int xilnet_arp(unsigned char*, int);
129extern void xilnet_arp_reply(unsigned char*, int);
130
131// IP functions
132extern void xilnet_ip_init(unsigned char*);
133extern int xilnet_ip(unsigned char*, int);
134extern void xilnet_ip_header(unsigned char*, int, int, unsigned char*);
135extern unsigned short xilnet_ip_calc_chksum(unsigned char*, int);
136
137// TCP/UDP/ICMP functions
138extern int xilnet_udp(unsigned char*, int);
139extern void xilnet_udp_header(struct xilnet_udp_conn*, unsigned char*, int);
140extern unsigned short xilnet_udp_tcp_calc_chksum(unsigned char*, int, unsigned char*, unsigned char*, unsigned short);
141extern void xilnet_udp_init_conns();
142extern int xilnet_udp_open_conn(unsigned short);
143extern int xilnet_udp_close_conn(struct xilnet_udp_conn*);
144extern void xilnet_icmp_echo_reply(unsigned char *, unsigned int);
145extern int xilnet_icmp(unsigned char *, int);
146extern int xilnet_tcp(unsigned char*, int);
147extern void xilnet_tcp_header(struct xilnet_tcp_conn*, unsigned char*, int, unsigned char);
148extern void xilnet_tcp_send_pkt(struct xilnet_tcp_conn*, unsigned char*, int, unsigned char);
149extern void xilnet_tcp_init_conns();
150extern int xilnet_tcp_open_conn(unsigned short);
151extern int xilnet_tcp_close_conn(struct xilnet_tcp_conn*);
152
153/* buffers for sending and receiving packets */
154extern unsigned char recvbuf[];
155extern unsigned char sendbuf[];
156extern unsigned char mb_ip_addr[IP_VERSION];
157extern unsigned char mb_hw_addr[ETH_ADDR_LEN];
158extern int xilsock_status_flag;
159
160extern unsigned char magicSync_ip_addr[IP_VERSION];
161
162#ifdef __cplusplus
163}
164#endif
165
166#endif /* _XILSOCK_H_ */
Note: See TracBrowser for help on using the repository browser.