[2229] | 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 | //////////////////////////////////////////////////////////////////////////////// |
---|
| 31 | // see copyright.txt for Rice University/Mango Communications modifications |
---|
| 32 | //////////////////////////////////////////////////////////////////////////////// |
---|
| 33 | |
---|
| 34 | #ifndef _XILSOCK_H_ |
---|
| 35 | #define _XILSOCK_H_ |
---|
| 36 | |
---|
| 37 | #ifdef __cplusplus |
---|
| 38 | extern "C" { |
---|
| 39 | #endif |
---|
| 40 | |
---|
| 41 | #include <xilnet_eth.h> |
---|
| 42 | #include <xilnet_arp.h> |
---|
| 43 | #include <xilnet_ip.h> |
---|
| 44 | #include <xilnet_udp.h> |
---|
| 45 | #include <xilnet_icmp.h> |
---|
| 46 | #include <xilnet_in.h> |
---|
| 47 | #include <xilnet_socket.h> |
---|
| 48 | #include <string.h> |
---|
| 49 | #include <xil_io.h> |
---|
| 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 | #define LINK_HDR_LEN ETH_HDR_LEN |
---|
| 58 | #define LINK_FRAME_LEN ETH_FRAME_LEN |
---|
| 59 | |
---|
| 60 | // #defines for TCP communication |
---|
| 61 | #define XILSOCK_NEW_CONN 0x1 |
---|
| 62 | #define XILSOCK_SYNACK_RCVD 0x2 |
---|
| 63 | #define XILSOCK_TCP_DATA 0x4 |
---|
| 64 | #define XILSOCK_TCP_ACK 0x8 |
---|
| 65 | #define XILSOCK_EXISTING_CONN 0x10 |
---|
| 66 | #define XILSOCK_CLOSE_CONN 0x20 |
---|
| 67 | |
---|
| 68 | |
---|
| 69 | /* Structures for xilsock sockets */ |
---|
| 70 | |
---|
| 71 | // msg structure |
---|
| 72 | struct xilsock_buf { |
---|
| 73 | unsigned char *buf; |
---|
| 74 | int size; |
---|
| 75 | }; |
---|
| 76 | |
---|
| 77 | // internal socket structure |
---|
| 78 | struct xilsock_socket { |
---|
| 79 | int type; |
---|
| 80 | int domain; |
---|
| 81 | int proto; |
---|
| 82 | // status of socket |
---|
| 83 | unsigned char listen:1; |
---|
| 84 | unsigned char bound:1; |
---|
| 85 | unsigned char accept:1; |
---|
| 86 | unsigned char connect:1; |
---|
| 87 | unsigned char free:1; |
---|
| 88 | unsigned char closing:1; |
---|
| 89 | unsigned char closed:1; |
---|
| 90 | union { |
---|
| 91 | struct xilnet_tcp_conn *tcp_conn; |
---|
| 92 | struct xilnet_udp_conn *udp_conn; |
---|
| 93 | } conn; |
---|
| 94 | int *if_addr; // interface base addr |
---|
| 95 | struct xilsock_buf recvbuf; // structure for recv/send msgs |
---|
| 96 | }; |
---|
| 97 | |
---|
| 98 | |
---|
| 99 | /* Functions of xilsock sockets */ |
---|
| 100 | |
---|
| 101 | extern int xilsock_init(unsigned int); |
---|
| 102 | extern void xilsock_rel_socket(int, unsigned int); |
---|
| 103 | extern int xilsock_socket(int, int, int, unsigned int); |
---|
| 104 | int xilsock_bind(int sd, struct sockaddr* addr, int addrlen, void (*callback) (), unsigned int); |
---|
| 105 | extern int xilsock_listen(int, int, unsigned int); |
---|
| 106 | extern int xilsock_recv(int, unsigned char*, unsigned int, unsigned int); |
---|
| 107 | extern int xilsock_recvfrom(int, unsigned char*, unsigned int, struct sockaddr*, unsigned int *, unsigned int); |
---|
| 108 | extern int xilsock_sendto(int, unsigned char*, unsigned int, struct sockaddr*, unsigned int); |
---|
| 109 | extern int xilsock_send(int, unsigned char*, unsigned int, unsigned int); |
---|
| 110 | extern void xilsock_close(int, unsigned int); |
---|
| 111 | |
---|
| 112 | /* |
---|
| 113 | * TCP/IP functions Prototype |
---|
| 114 | */ |
---|
| 115 | |
---|
| 116 | // Ethernet Device functions |
---|
| 117 | extern int xilnet_eth_device_init(unsigned int, unsigned int, unsigned char *, unsigned char *); |
---|
| 118 | extern int xilnet_eth_device_start(unsigned int); |
---|
| 119 | extern int xilnet_eth_set_inf_hw_info( unsigned int, unsigned char *, unsigned char *); |
---|
| 120 | extern int xilnet_eth_get_inf_ip_addr( unsigned int, unsigned char *); |
---|
| 121 | extern int xilnet_eth_get_inf_hw_addr( unsigned int, unsigned char *); |
---|
| 122 | |
---|
| 123 | |
---|
| 124 | // Ethernet functions |
---|
| 125 | extern unsigned int xilnet_eth_recv_frame(unsigned int); |
---|
| 126 | extern int xilnet_eth_send_frame(unsigned char *, int, unsigned char*, void*, unsigned short, unsigned int); |
---|
| 127 | extern void xilnet_eth_update_hw_tbl(unsigned char *, int, unsigned int); |
---|
| 128 | extern void xilnet_eth_add_hw_tbl_entry(unsigned char *, unsigned char *, unsigned int); |
---|
| 129 | extern int xilnet_eth_get_hw_addr(unsigned char *, unsigned int); |
---|
| 130 | extern void xilnet_eth_init_hw_addr_tbl(unsigned int); |
---|
| 131 | extern int xilnet_eth_find_old_entry(unsigned int); |
---|
| 132 | |
---|
| 133 | // ARP functions |
---|
| 134 | extern int xilnet_arp(unsigned char*, int, unsigned int); |
---|
| 135 | extern void xilnet_arp_reply(unsigned char*, int, unsigned int); |
---|
| 136 | |
---|
| 137 | // IP functions |
---|
| 138 | extern void xilnet_ip_init(unsigned char*, unsigned int); |
---|
| 139 | extern int xilnet_ip(unsigned char*, int, unsigned int); |
---|
| 140 | extern void xilnet_ip_header(unsigned char*, int, int, unsigned char*, unsigned int); |
---|
| 141 | extern unsigned short xilnet_ip_calc_chksum(unsigned char*, int); |
---|
| 142 | |
---|
| 143 | // UDP/ICMP functions |
---|
| 144 | extern int xilnet_udp(unsigned char*, int, unsigned int); |
---|
| 145 | extern void xilnet_udp_header(struct xilnet_udp_conn*, unsigned char*, int, unsigned int); |
---|
| 146 | extern unsigned short xilnet_udp_tcp_calc_chksum(unsigned char*, int, unsigned char*, unsigned char*, unsigned short); |
---|
| 147 | extern void xilnet_udp_init_conns(unsigned int); |
---|
| 148 | int xilnet_udp_open_conn(unsigned short port,void (*callback) (), unsigned int); |
---|
| 149 | extern int xilnet_udp_close_conn(struct xilnet_udp_conn*, unsigned int); |
---|
| 150 | extern void xilnet_icmp_echo_reply(unsigned char *, unsigned int, unsigned int); |
---|
| 151 | extern int xilnet_icmp(unsigned char *, int, unsigned int); |
---|
| 152 | |
---|
| 153 | |
---|
| 154 | |
---|
| 155 | #ifdef __cplusplus |
---|
| 156 | } |
---|
| 157 | #endif |
---|
| 158 | |
---|
| 159 | #endif /* _XILSOCK_H_ */ |
---|