[1740] | 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 | |
---|
[1749] | 30 | //////////////////////////////////////////////////////////////////////////////// |
---|
| 31 | // see copyright.txt for Rice University/Mango Communications modifications |
---|
| 32 | //////////////////////////////////////////////////////////////////////////////// |
---|
| 33 | |
---|
[1740] | 34 | #ifndef _XILSOCK_H_ |
---|
| 35 | #define _XILSOCK_H_ |
---|
| 36 | |
---|
| 37 | #ifdef __cplusplus |
---|
| 38 | extern "C" { |
---|
| 39 | #endif |
---|
| 40 | |
---|
[1745] | 41 | #include <xilnet_eth.h> |
---|
| 42 | #include <xilnet_arp.h> |
---|
| 43 | #include <xilnet_ip.h> |
---|
| 44 | #include <xilnet_tcp.h> |
---|
| 45 | #include <xilnet_udp.h> |
---|
| 46 | #include <xilnet_icmp.h> |
---|
| 47 | #include <xilnet_in.h> |
---|
| 48 | #include <xilnet_socket.h> |
---|
[1746] | 49 | #include <string.h> |
---|
[1740] | 50 | |
---|
| 51 | // definitions for connections |
---|
| 52 | #define TRUE 1 |
---|
| 53 | #define FALSE 0 |
---|
| 54 | |
---|
| 55 | /* Data Link Layer definitions |
---|
| 56 | * Add #if's for PPP header lengths |
---|
| 57 | */ |
---|
| 58 | |
---|
| 59 | #define LINK_HDR_LEN ETH_HDR_LEN |
---|
| 60 | #define LINK_FRAME_LEN ETH_FRAME_LEN |
---|
| 61 | |
---|
| 62 | // msg structure |
---|
| 63 | struct xilsock_buf { |
---|
| 64 | unsigned char *buf; |
---|
| 65 | int size; |
---|
| 66 | }; |
---|
| 67 | |
---|
| 68 | |
---|
| 69 | // internal socket structure |
---|
| 70 | struct xilsock_socket { |
---|
| 71 | int type; |
---|
| 72 | int domain; |
---|
| 73 | int proto; |
---|
| 74 | // status of socket |
---|
| 75 | unsigned char listen:1; |
---|
| 76 | unsigned char bound:1; |
---|
| 77 | unsigned char accept:1; |
---|
| 78 | unsigned char connect:1; |
---|
| 79 | unsigned char free:1; |
---|
| 80 | unsigned char closing:1; |
---|
| 81 | unsigned char closed:1; |
---|
| 82 | union { |
---|
| 83 | struct xilnet_tcp_conn *tcp_conn; |
---|
| 84 | struct xilnet_udp_conn *udp_conn; |
---|
| 85 | } conn; |
---|
| 86 | int *if_addr; // interface base addr |
---|
| 87 | struct xilsock_buf recvbuf; // structure for recv/send msgs |
---|
| 88 | }; |
---|
| 89 | |
---|
| 90 | #define NO_OF_XILSOCKS (MAX_TCP_CONNS+MAX_UDP_CONNS) |
---|
| 91 | extern struct xilsock_socket xilsock_sockets[NO_OF_XILSOCKS]; |
---|
| 92 | |
---|
| 93 | |
---|
| 94 | /* #defines for TCP communication */ |
---|
| 95 | #define XILSOCK_NEW_CONN 0x1 |
---|
| 96 | #define XILSOCK_SYNACK_RCVD 0x2 |
---|
| 97 | #define XILSOCK_TCP_DATA 0x4 |
---|
| 98 | #define XILSOCK_TCP_ACK 0x8 |
---|
| 99 | #define XILSOCK_EXISTING_CONN 0x10 |
---|
| 100 | #define XILSOCK_CLOSE_CONN 0x20 |
---|
| 101 | |
---|
| 102 | /* Functions of xilsock sockets */ |
---|
| 103 | |
---|
| 104 | //#define xilsock_recvfrom xilsock_recv |
---|
| 105 | |
---|
| 106 | extern int xilsock_init(void); |
---|
| 107 | extern void xilsock_rel_socket(int); |
---|
| 108 | extern int xilsock_socket(int, int, int); |
---|
| 109 | extern int xilsock_bind(int, struct sockaddr*, int); |
---|
| 110 | extern int xilsock_listen(int, int); |
---|
| 111 | extern int xilsock_accept(int, struct sockaddr*, int*); |
---|
| 112 | extern int xilsock_recv(int, unsigned char*, unsigned int); |
---|
| 113 | extern int xilsock_recvfrom(int, unsigned char*, unsigned int, struct sockaddr* from, unsigned int *fromlen); |
---|
| 114 | extern int xilsock_sendto(int, unsigned char*, unsigned int, struct sockaddr* to, unsigned int tolen); |
---|
| 115 | extern int xilsock_send(int, unsigned char*, unsigned int); |
---|
| 116 | extern void xilsock_close(int); |
---|
| 117 | |
---|
| 118 | /* |
---|
| 119 | * TCP/IP functions Prototype |
---|
| 120 | */ |
---|
| 121 | |
---|
| 122 | // Ethernet functions |
---|
| 123 | extern int xilnet_eth_recv_frame(unsigned char *, int); |
---|
| 124 | extern int xilnet_eth_send_frame(unsigned char *, int, unsigned char*, void*, unsigned short); |
---|
| 125 | extern void xilnet_eth_update_hw_tbl(unsigned char *, int); |
---|
| 126 | extern void xilnet_add_hw_tbl_entry(unsigned char *, unsigned char *); |
---|
| 127 | extern int xilnet_eth_get_hw_addr(unsigned char *); |
---|
| 128 | extern void xilnet_eth_init_hw_addr_tbl(void); |
---|
| 129 | extern int xilnet_eth_find_old_entry(void); |
---|
| 130 | |
---|
| 131 | // ARP functions |
---|
| 132 | extern int xilnet_arp(unsigned char*, int); |
---|
| 133 | extern void xilnet_arp_reply(unsigned char*, int); |
---|
| 134 | |
---|
| 135 | // IP functions |
---|
| 136 | extern void xilnet_ip_init(unsigned char*); |
---|
| 137 | extern int xilnet_ip(unsigned char*, int); |
---|
| 138 | extern void xilnet_ip_header(unsigned char*, int, int, unsigned char*); |
---|
| 139 | extern unsigned short xilnet_ip_calc_chksum(unsigned char*, int); |
---|
| 140 | |
---|
| 141 | // TCP/UDP/ICMP functions |
---|
| 142 | extern int xilnet_udp(unsigned char*, int); |
---|
| 143 | extern void xilnet_udp_header(struct xilnet_udp_conn*, unsigned char*, int); |
---|
| 144 | extern unsigned short xilnet_udp_tcp_calc_chksum(unsigned char*, int, unsigned char*, unsigned char*, unsigned short); |
---|
| 145 | extern void xilnet_udp_init_conns(); |
---|
| 146 | extern int xilnet_udp_open_conn(unsigned short); |
---|
| 147 | extern int xilnet_udp_close_conn(struct xilnet_udp_conn*); |
---|
| 148 | extern void xilnet_icmp_echo_reply(unsigned char *, unsigned int); |
---|
| 149 | extern int xilnet_icmp(unsigned char *, int); |
---|
| 150 | extern int xilnet_tcp(unsigned char*, int); |
---|
| 151 | extern void xilnet_tcp_header(struct xilnet_tcp_conn*, unsigned char*, int, unsigned char); |
---|
| 152 | extern void xilnet_tcp_send_pkt(struct xilnet_tcp_conn*, unsigned char*, int, unsigned char); |
---|
| 153 | extern void xilnet_tcp_init_conns(); |
---|
| 154 | extern int xilnet_tcp_open_conn(unsigned short); |
---|
| 155 | extern int xilnet_tcp_close_conn(struct xilnet_tcp_conn*); |
---|
| 156 | |
---|
| 157 | /* buffers for sending and receiving packets */ |
---|
| 158 | extern unsigned char recvbuf[]; |
---|
| 159 | extern unsigned char sendbuf[]; |
---|
| 160 | extern unsigned char mb_ip_addr[IP_VERSION]; |
---|
| 161 | extern unsigned char mb_hw_addr[ETH_ADDR_LEN]; |
---|
| 162 | extern int xilsock_status_flag; |
---|
| 163 | |
---|
[1749] | 164 | extern unsigned char sync_IP_octet; |
---|
[1740] | 165 | |
---|
| 166 | #ifdef __cplusplus |
---|
| 167 | } |
---|
| 168 | #endif |
---|
| 169 | |
---|
| 170 | #endif /* _XILSOCK_H_ */ |
---|