URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
Compare Revisions
- This comparison shows the changes necessary to convert path
/or1k/trunk/ecos-2.0/packages/redboot/v2_0/include/net
- from Rev 1254 to Rev 1765
- ↔ Reverse comparison
Rev 1254 → Rev 1765
/tftp_support.h
0,0 → 1,100
//========================================================================== |
// |
// net/tftp_support.h |
// |
// Stand-alone TFTP support for RedBoot |
// |
//========================================================================== |
//####ECOSGPLCOPYRIGHTBEGIN#### |
// ------------------------------------------- |
// This file is part of eCos, the Embedded Configurable Operating System. |
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
// Copyright (C) 2002 Gary Thomas |
// |
// eCos is free software; you can redistribute it and/or modify it under |
// the terms of the GNU General Public License as published by the Free |
// Software Foundation; either version 2 or (at your option) any later version. |
// |
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with eCos; if not, write to the Free Software Foundation, Inc., |
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
// |
// As a special exception, if other files instantiate templates or use macros |
// or inline functions from this file, or you compile this file and link it |
// with other works to produce a work based on this file, this file does not |
// by itself cause the resulting work to be covered by the GNU General Public |
// License. However the source code for this file must still be made available |
// in accordance with section (3) of the GNU General Public License. |
// |
// This exception does not invalidate any other reasons why a work based on |
// this file might be covered by the GNU General Public License. |
// |
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
// at http://sources.redhat.com/ecos/ecos-license/ |
// ------------------------------------------- |
//####ECOSGPLCOPYRIGHTEND#### |
//========================================================================== |
//#####DESCRIPTIONBEGIN#### |
// |
// Author(s): gthomas |
// Contributors: gthomas |
// Date: 2000-07-14 |
// Purpose: |
// Description: |
// |
// This code is part of RedBoot (tm). |
// |
//####DESCRIPTIONEND#### |
// |
//========================================================================== |
|
#ifndef _TFTP_SUPPORT_H_ |
#define _TFTP_SUPPORT_H_ |
|
#include "net.h" |
|
/* |
* File transfer modes |
*/ |
#define TFTP_NETASCII 0 // Text files |
#define TFTP_OCTET 1 // Binary files |
|
/* |
* Errors |
*/ |
#define TFTP_ENOTFOUND 1 /* file not found */ |
#define TFTP_EACCESS 2 /* access violation */ |
#define TFTP_ENOSPACE 3 /* disk full or allocation exceeded */ |
#define TFTP_EBADOP 4 /* illegal TFTP operation */ |
#define TFTP_EBADID 5 /* unknown transfer ID */ |
#define TFTP_EEXISTS 6 /* file already exists */ |
#define TFTP_ENOUSER 7 /* no such user */ |
#define TFTP_TIMEOUT 8 /* operation timed out */ |
#define TFTP_NETERR 9 /* some sort of network error */ |
#define TFTP_INVALID 10 /* invalid parameter */ |
#define TFTP_PROTOCOL 11 /* protocol violation */ |
#define TFTP_TOOLARGE 12 /* file is larger than buffer */ |
|
/* |
* Client support |
*/ |
|
extern int tftp_stream_open(connection_info_t *info, int *err); |
extern int tftp_stream_read(char *buf, int len, int *err); |
extern void tftp_stream_close(int *err); |
extern char *tftp_error(int err); |
|
#define TFTP_TIMEOUT_PERIOD 5 |
#define TFTP_TIMEOUT_MAX 15 |
#define TFTP_RETRIES_MAX 5 |
|
#define TFTP_PORT 69 |
|
extern getc_io_funcs_t tftp_io; |
|
#endif // _TFTP_SUPPORT_H_ |
/tftp.h
0,0 → 1,146
//========================================================================== |
// |
// net/tftp.h |
// |
// Stand-alone TFTP support for RedBoot |
// |
//========================================================================== |
//####ECOSGPLCOPYRIGHTBEGIN#### |
// ------------------------------------------- |
// This file is part of eCos, the Embedded Configurable Operating System. |
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
// Copyright (C) 2002 Gary Thomas |
// |
// eCos is free software; you can redistribute it and/or modify it under |
// the terms of the GNU General Public License as published by the Free |
// Software Foundation; either version 2 or (at your option) any later version. |
// |
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with eCos; if not, write to the Free Software Foundation, Inc., |
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
// |
// As a special exception, if other files instantiate templates or use macros |
// or inline functions from this file, or you compile this file and link it |
// with other works to produce a work based on this file, this file does not |
// by itself cause the resulting work to be covered by the GNU General Public |
// License. However the source code for this file must still be made available |
// in accordance with section (3) of the GNU General Public License. |
// |
// This exception does not invalidate any other reasons why a work based on |
// this file might be covered by the GNU General Public License. |
// |
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
// at http://sources.redhat.com/ecos/ecos-license/ |
// ------------------------------------------- |
//####ECOSGPLCOPYRIGHTEND#### |
//####BSDCOPYRIGHTBEGIN#### |
// |
// ------------------------------------------- |
// |
// Portions of this software may have been derived from OpenBSD or other sources, |
// and are covered by the appropriate copyright disclaimers included herein. |
// |
// ------------------------------------------- |
// |
//####BSDCOPYRIGHTEND#### |
//========================================================================== |
//#####DESCRIPTIONBEGIN#### |
// |
// Author(s): gthomas |
// Contributors: gthomas |
// Date: 2000-07-14 |
// Purpose: |
// Description: |
// |
// This code is part of RedBoot (tm). |
// |
//####DESCRIPTIONEND#### |
// |
//========================================================================== |
|
/* |
* Copyright (c) 1983 Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* @(#)tftp.h 5.4 (Berkeley) 4/3/91 |
*/ |
|
#ifndef _ARPA_TFTP_H_ |
#define _ARPA_TFTP_H_ |
|
/* |
* Trivial File Transfer Protocol (IEN-133) |
* Now, rev 2 - RFC 1350 |
*/ |
#define SEGSIZE 512 /* data segment size */ |
|
/* |
* Packet types. |
*/ |
#define RRQ 01 /* read request */ |
#define WRQ 02 /* write request */ |
#define DATA 03 /* data packet */ |
#define ACK 04 /* acknowledgement */ |
#define ERROR 05 /* error code */ |
|
struct tftphdr { |
short th_opcode; /* packet type */ |
union { |
unsigned short tu_block; /* block # */ |
short tu_code; /* error code */ |
char tu_stuff[1]; /* request packet stuff */ |
} __attribute__ ((packed)) th_u; |
char th_data[0]; /* data or error string */ |
} __attribute__ ((packed)); |
|
#define th_block th_u.tu_block |
#define th_code th_u.tu_code |
#define th_stuff th_u.tu_stuff |
#define th_msg th_data |
|
/* |
* Error codes. |
*/ |
#define EUNDEF 0 /* not defined */ |
#define ENOTFOUND 1 /* file not found */ |
#define EACCESS 2 /* access violation */ |
#define ENOSPACE 3 /* disk full or allocation exceeded */ |
#define EBADOP 4 /* illegal TFTP operation */ |
#define EBADID 5 /* unknown transfer ID */ |
#define EEXISTS 6 /* file already exists */ |
#define ENOUSER 7 /* no such user */ |
|
#endif /* !_ARPA_TFTP_H_ */ |
/http.h
0,0 → 1,70
//========================================================================== |
// |
// net/http.h |
// |
// Stand-alone HTTP (client) support for RedBoot |
// |
//========================================================================== |
//####ECOSGPLCOPYRIGHTBEGIN#### |
// ------------------------------------------- |
// This file is part of eCos, the Embedded Configurable Operating System. |
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
// Copyright (C) 2002 Gary Thomas |
// |
// eCos is free software; you can redistribute it and/or modify it under |
// the terms of the GNU General Public License as published by the Free |
// Software Foundation; either version 2 or (at your option) any later version. |
// |
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with eCos; if not, write to the Free Software Foundation, Inc., |
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
// |
// As a special exception, if other files instantiate templates or use macros |
// or inline functions from this file, or you compile this file and link it |
// with other works to produce a work based on this file, this file does not |
// by itself cause the resulting work to be covered by the GNU General Public |
// License. However the source code for this file must still be made available |
// in accordance with section (3) of the GNU General Public License. |
// |
// This exception does not invalidate any other reasons why a work based on |
// this file might be covered by the GNU General Public License. |
// |
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
// at http://sources.redhat.com/ecos/ecos-license/ |
// ------------------------------------------- |
//####ECOSGPLCOPYRIGHTEND#### |
//========================================================================== |
//#####DESCRIPTIONBEGIN#### |
// |
// Author(s): gthomas |
// Contributors: gthomas |
// Date: 2002-05-22 |
// Purpose: |
// Description: |
// |
// This code is part of RedBoot (tm). |
// |
//####DESCRIPTIONEND#### |
// |
//========================================================================== |
|
#ifndef _HTTP_H_ |
#define _HTTP_H_ |
|
extern int http_stream_open(connection_info_t *info, int *err); |
extern int http_stream_read(char *buf, int len, int *err); |
extern void http_stream_close(int *err); |
extern char *http_error(int err); |
|
#define HTTP_NOERR 0 // No error |
#define HTTP_BADHDR 1 // Invalid HTTP header (response) |
#define HTTP_OPEN 2 // Problems opening connection |
#define HTTP_IO 3 // Misc I/O problems |
|
extern getc_io_funcs_t http_io; |
#endif // _HTTP_H_ |
/bootp.h
0,0 → 1,310
//========================================================================== |
// |
// net/bootp.h |
// |
// Stand-alone BOOTP support for RedBoot |
// |
//========================================================================== |
//####ECOSGPLCOPYRIGHTBEGIN#### |
// ------------------------------------------- |
// This file is part of eCos, the Embedded Configurable Operating System. |
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
// Copyright (C) 2002 Gary Thomas |
// |
// eCos is free software; you can redistribute it and/or modify it under |
// the terms of the GNU General Public License as published by the Free |
// Software Foundation; either version 2 or (at your option) any later version. |
// |
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with eCos; if not, write to the Free Software Foundation, Inc., |
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
// |
// As a special exception, if other files instantiate templates or use macros |
// or inline functions from this file, or you compile this file and link it |
// with other works to produce a work based on this file, this file does not |
// by itself cause the resulting work to be covered by the GNU General Public |
// License. However the source code for this file must still be made available |
// in accordance with section (3) of the GNU General Public License. |
// |
// This exception does not invalidate any other reasons why a work based on |
// this file might be covered by the GNU General Public License. |
// |
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
// at http://sources.redhat.com/ecos/ecos-license/ |
// ------------------------------------------- |
//####ECOSGPLCOPYRIGHTEND#### |
//========================================================================== |
//#####DESCRIPTIONBEGIN#### |
// |
// Author(s): gthomas |
// Contributors: gthomas |
// Date: 2000-07-14 |
// Purpose: |
// Description: |
// |
// This code is part of RedBoot (tm). |
// |
//####DESCRIPTIONEND#### |
// |
//========================================================================== |
|
/************************************************************************ |
Copyright 1988, 1991 by Carnegie Mellon University |
|
All Rights Reserved |
|
Permission to use, copy, modify, and distribute this software and its |
documentation for any purpose and without fee is hereby granted, provided |
that the above copyright notice appear in all copies and that both that |
copyright notice and this permission notice appear in supporting |
documentation, and that the name of Carnegie Mellon University not be used |
in advertising or publicity pertaining to distribution of the software |
without specific, written prior permission. |
|
CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS |
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. |
IN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL |
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS |
ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS |
SOFTWARE. |
************************************************************************/ |
|
#ifndef _BOOTP_H_ |
#define _BOOTP_H_ |
|
/* |
* Bootstrap Protocol (BOOTP). RFC951 and RFC1395. |
* |
* This file specifies the "implementation-independent" BOOTP protocol |
* information which is common to both client and server. |
* |
*/ |
|
#define BP_CHADDR_LEN 16 |
#define BP_SNAME_LEN 64 |
#define BP_FILE_LEN 128 |
#define BP_VEND_LEN 312 |
#define BP_MINPKTSZ 300 /* to check sizeof(struct bootp) */ |
#define BP_MIN_VEND_SIZE 64 /* minimum actual vendor area */ |
|
typedef struct bootp { |
unsigned char bp_op; /* packet opcode type */ |
unsigned char bp_htype; /* hardware addr type */ |
unsigned char bp_hlen; /* hardware addr length */ |
unsigned char bp_hops; /* gateway hops */ |
unsigned int bp_xid; /* transaction ID */ |
unsigned short bp_secs; /* seconds since boot began */ |
unsigned short bp_flags; /* RFC1532 broadcast, etc. */ |
struct in_addr bp_ciaddr; /* client IP address */ |
struct in_addr bp_yiaddr; /* 'your' IP address */ |
struct in_addr bp_siaddr; /* server IP address */ |
struct in_addr bp_giaddr; /* gateway IP address */ |
unsigned char bp_chaddr[BP_CHADDR_LEN]; /* client hardware address */ |
char bp_sname[BP_SNAME_LEN]; /* server host name */ |
char bp_file[BP_FILE_LEN]; /* boot file name */ |
unsigned char bp_vend[BP_VEND_LEN]; /* vendor-specific area */ |
/* note that bp_vend can be longer, extending to end of packet. */ |
} bootp_header_t; |
|
/* |
* UDP port numbers, server and client. |
*/ |
#define IPPORT_BOOTPS 67 |
#define IPPORT_BOOTPC 68 |
|
#define BOOTREPLY 2 |
#define BOOTREQUEST 1 |
|
/* |
* Hardware types from Assigned Numbers RFC. |
*/ |
#define HTYPE_ETHERNET 1 |
#define HTYPE_EXP_ETHERNET 2 |
#define HTYPE_AX25 3 |
#define HTYPE_PRONET 4 |
#define HTYPE_CHAOS 5 |
#define HTYPE_IEEE802 6 |
#define HTYPE_ARCNET 7 |
|
/* |
* Vendor magic cookie (v_magic) for CMU |
*/ |
#define VM_CMU "CMU" |
|
/* |
* Vendor magic cookie (v_magic) for RFC1048 |
*/ |
#define VM_RFC1048 { 99, 130, 83, 99 } |
|
|
|
/* |
* Tag values used to specify what information is being supplied in |
* the vendor (options) data area of the packet. |
*/ |
/* RFC 1048 */ |
/* End of cookie */ |
#define TAG_END ((unsigned char) 255) |
/* padding for alignment */ |
#define TAG_PAD ((unsigned char) 0) |
/* Subnet mask */ |
#define TAG_SUBNET_MASK ((unsigned char) 1) |
/* Time offset from UTC for this system */ |
#define TAG_TIME_OFFSET ((unsigned char) 2) |
/* List of routers on this subnet */ |
#define TAG_GATEWAY ((unsigned char) 3) |
/* List of rfc868 time servers available to client */ |
#define TAG_TIME_SERVER ((unsigned char) 4) |
/* List of IEN 116 name servers */ |
#define TAG_NAME_SERVER ((unsigned char) 5) |
/* List of DNS name servers */ |
#define TAG_DOMAIN_SERVER ((unsigned char) 6) |
/* List of MIT-LCS UDL log servers */ |
#define TAG_LOG_SERVER ((unsigned char) 7) |
/* List of rfc865 cookie servers */ |
#define TAG_COOKIE_SERVER ((unsigned char) 8) |
/* List of rfc1179 printer servers (in order to try) */ |
#define TAG_LPR_SERVER ((unsigned char) 9) |
/* List of Imagen Impress servers (in prefered order) */ |
#define TAG_IMPRESS_SERVER ((unsigned char) 10) |
/* List of rfc887 Resourse Location servers */ |
#define TAG_RLP_SERVER ((unsigned char) 11) |
/* Hostname of client */ |
#define TAG_HOST_NAME ((unsigned char) 12) |
/* boot file size */ |
#define TAG_BOOT_SIZE ((unsigned char) 13) |
/* RFC 1395 */ |
/* path to dump to in case of crash */ |
#define TAG_DUMP_FILE ((unsigned char) 14) |
/* domain name for use with the DNS */ |
#define TAG_DOMAIN_NAME ((unsigned char) 15) |
/* IP address of the swap server for this machine */ |
#define TAG_SWAP_SERVER ((unsigned char) 16) |
/* The path name to the root filesystem for this machine */ |
#define TAG_ROOT_PATH ((unsigned char) 17) |
/* RFC 1497 */ |
/* filename to tftp with more options in it */ |
#define TAG_EXTEN_FILE ((unsigned char) 18) |
/* RFC 1533 */ |
/* The following are in rfc1533 and may be used by BOOTP/DHCP */ |
/* IP forwarding enable/disable */ |
#define TAG_IP_FORWARD ((unsigned char) 19) |
/* Non-Local source routing enable/disable */ |
#define TAG_IP_NLSR ((unsigned char) 20) |
/* List of pairs of addresses/masks to allow non-local source routing to */ |
#define TAG_IP_POLICY_FILTER ((unsigned char) 21) |
/* Maximum size of datagrams client should be prepared to reassemble */ |
#define TAG_IP_MAX_DRS ((unsigned char) 22) |
/* Default IP TTL */ |
#define TAG_IP_TTL ((unsigned char) 23) |
/* Timeout in seconds to age path MTU values found with rfc1191 */ |
#define TAG_IP_MTU_AGE ((unsigned char) 24) |
/* Table of MTU sizes to use when doing rfc1191 MTU discovery */ |
#define TAG_IP_MTU_PLAT ((unsigned char) 25) |
/* MTU to use on this interface */ |
#define TAG_IP_MTU ((unsigned char) 26) |
/* All subnets are local option */ |
#define TAG_IP_SNARL ((unsigned char) 27) |
/* broadcast address */ |
#define TAG_IP_BROADCAST ((unsigned char) 28) |
/* perform subnet mask discovery using ICMP */ |
#define TAG_IP_SMASKDISC ((unsigned char) 29) |
/* act as a subnet mask server using ICMP */ |
#define TAG_IP_SMASKSUPP ((unsigned char) 30) |
/* perform rfc1256 router discovery */ |
#define TAG_IP_ROUTERDISC ((unsigned char) 31) |
/* address to send router solicitation requests */ |
#define TAG_IP_ROUTER_SOL_ADDR ((unsigned char) 32) |
/* list of static routes to addresses (addr, router) pairs */ |
#define TAG_IP_STATIC_ROUTES ((unsigned char) 33) |
/* use trailers (rfc893) when using ARP */ |
#define TAG_IP_TRAILER_ENC ((unsigned char) 34) |
/* timeout in seconds for ARP cache entries */ |
#define TAG_ARP_TIMEOUT ((unsigned char) 35) |
/* use either Ethernet version 2 (rfc894) or IEEE 802.3 (rfc1042) */ |
#define TAG_ETHER_IEEE ((unsigned char) 36) |
/* default TCP TTL when sending TCP segments */ |
#define TAG_IP_TCP_TTL ((unsigned char) 37) |
/* time for client to wait before sending a keepalive on a TCP connection */ |
#define TAG_IP_TCP_KA_INT ((unsigned char) 38) |
/* don't send keepalive with an octet of garbage for compatability */ |
#define TAG_IP_TCP_KA_GARBAGE ((unsigned char) 39) |
/* NIS domainname */ |
#define TAG_NIS_DOMAIN ((unsigned char) 40) |
/* list of NIS servers */ |
#define TAG_NIS_SERVER ((unsigned char) 41) |
/* list of NTP servers */ |
#define TAG_NTP_SERVER ((unsigned char) 42) |
/* and stuff vendors may want to add */ |
#define TAG_VEND_SPECIFIC ((unsigned char) 43) |
/* NetBios over TCP/IP name server */ |
#define TAG_NBNS_SERVER ((unsigned char) 44) |
/* NetBios over TCP/IP NBDD servers (rfc1001/1002) */ |
#define TAG_NBDD_SERVER ((unsigned char) 45) |
/* NetBios over TCP/IP node type option for use with above */ |
#define TAG_NBOTCP_OTPION ((unsigned char) 46) |
/* NetBios over TCP/IP scopt option for use with above */ |
#define TAG_NB_SCOPE ((unsigned char) 47) |
/* list of X Window system font servers */ |
#define TAG_XFONT_SERVER ((unsigned char) 48) |
/* list of systems running X Display Manager (xdm) available to this client */ |
#define TAG_XDISPLAY_SERVER ((unsigned char) 49) |
|
/* While the following are only allowed for DHCP */ |
/* DHCP requested IP address */ |
#define TAG_DHCP_REQ_IP ((unsigned char) 50) |
/* DHCP time for lease of IP address */ |
#define TAG_DHCP_LEASE_TIME ((unsigned char) 51) |
/* DHCP options overload */ |
#define TAG_DHCP_OPTOVER ((unsigned char) 52) |
/* DHCP message type */ |
#define TAG_DHCP_MESS_TYPE ((unsigned char) 53) |
/* DHCP server identification */ |
#define TAG_DHCP_SERVER_ID ((unsigned char) 54) |
/* DHCP ordered list of requested parameters */ |
#define TAG_DHCP_PARM_REQ_LIST ((unsigned char) 55) |
/* DHCP reply message */ |
#define TAG_DHCP_TEXT_MESSAGE ((unsigned char) 56) |
/* DHCP maximum packet size willing to accept */ |
#define TAG_DHCP_MAX_MSGSZ ((unsigned char) 57) |
/* DHCP time 'til client needs to renew */ |
#define TAG_DHCP_RENEWAL_TIME ((unsigned char) 58) |
/* DHCP time 'til client needs to rebind */ |
#define TAG_DHCP_REBIND_TIME ((unsigned char) 59) |
/* DHCP class identifier */ |
#define TAG_DHCP_CLASSID ((unsigned char) 60) |
/* DHCP client unique identifier */ |
#define TAG_DHCP_CLIENTID ((unsigned char) 61) |
|
/* XXX - Add new tags here */ |
|
|
/* |
* "vendor" data permitted for CMU bootp clients. |
*/ |
|
struct cmu_vend { |
char v_magic[4]; /* magic number */ |
unsigned int v_flags; /* flags/opcodes, etc. */ |
struct in_addr v_smask; /* Subnet mask */ |
struct in_addr v_dgate; /* Default gateway */ |
struct in_addr v_dns1, v_dns2; /* Domain name servers */ |
struct in_addr v_ins1, v_ins2; /* IEN-116 name servers */ |
struct in_addr v_ts1, v_ts2; /* Time servers */ |
int v_unused[6]; /* currently unused */ |
}; |
|
|
/* v_flags values */ |
#define VF_SMASK 1 /* Subnet mask field contains valid data */ |
|
#define IPPORT_BOOTPS 67 |
#define IPPORT_BOOTPC 68 |
|
#endif // _BOOTP_H_ |
/net.h
0,0 → 1,633
//========================================================================== |
// |
// net/net.h |
// |
// Stand-alone networking support for RedBoot |
// |
//========================================================================== |
//####ECOSGPLCOPYRIGHTBEGIN#### |
// ------------------------------------------- |
// This file is part of eCos, the Embedded Configurable Operating System. |
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
// Copyright (C) 2002 Gary Thomas |
// |
// eCos is free software; you can redistribute it and/or modify it under |
// the terms of the GNU General Public License as published by the Free |
// Software Foundation; either version 2 or (at your option) any later version. |
// |
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with eCos; if not, write to the Free Software Foundation, Inc., |
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
// |
// As a special exception, if other files instantiate templates or use macros |
// or inline functions from this file, or you compile this file and link it |
// with other works to produce a work based on this file, this file does not |
// by itself cause the resulting work to be covered by the GNU General Public |
// License. However the source code for this file must still be made available |
// in accordance with section (3) of the GNU General Public License. |
// |
// This exception does not invalidate any other reasons why a work based on |
// this file might be covered by the GNU General Public License. |
// |
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
// at http://sources.redhat.com/ecos/ecos-license/ |
// ------------------------------------------- |
//####ECOSGPLCOPYRIGHTEND#### |
//========================================================================== |
//#####DESCRIPTIONBEGIN#### |
// |
// Author(s): gthomas |
// Contributors: gthomas |
// Date: 2000-07-14 |
// Purpose: |
// Description: |
// |
// This code is part of RedBoot (tm). |
// |
//####DESCRIPTIONEND#### |
// |
//========================================================================== |
|
#ifndef _NET_H_ |
#define _NET_H_ |
|
#include <pkgconf/system.h> |
#include <pkgconf/redboot.h> |
#include <cyg/hal/hal_arch.h> |
#include <cyg/hal/basetype.h> |
#include <string.h> |
|
extern bool net_debug; |
#ifdef CYGPKG_IO_ETH_DRIVERS |
# include <pkgconf/io_eth_drivers.h> |
# ifdef CYGDBG_IO_ETH_DRIVERS_DEBUG |
extern int cyg_io_eth_net_debug; |
# endif |
#endif |
|
extern unsigned long do_ms_tick(void); |
extern unsigned long get_ms_ticks(void); |
#define MS_TICKS() get_ms_ticks() |
#define MS_TICKS_DELAY() do_ms_tick() |
|
/* #define NET_SUPPORT_RARP 1 */ |
#define NET_SUPPORT_ICMP 1 |
#define NET_SUPPORT_UDP 1 |
#define NET_SUPPORT_TCP 1 |
|
#if (CYG_BYTEORDER == CYG_LSBFIRST) |
#ifndef __LITTLE_ENDIAN__ |
#define __LITTLE_ENDIAN__ |
#endif |
extern unsigned long ntohl(unsigned long x); |
extern unsigned long ntohs(unsigned short x); |
#else |
#define ntohl(x) (x) |
#define ntohs(x) (x) |
#endif |
|
#define htonl(x) ntohl(x) |
#define htons(x) ntohs(x) |
|
/* |
* Minimum ethernet packet length. |
*/ |
#define ETH_MIN_PKTLEN 60 |
#define ETH_MAX_PKTLEN (1540-14) |
#define ETH_HDR_SIZE 14 |
|
typedef unsigned char enet_addr_t[6]; |
typedef unsigned char ip_addr_t[4]; |
|
typedef unsigned char octet; |
typedef unsigned short word; |
typedef unsigned int dword; |
|
#ifndef NULL |
#define NULL 0 |
#endif |
|
// IPv4 support |
typedef struct in_addr { |
unsigned long s_addr; // IPv4 address |
} in_addr_t; |
|
// Socket/connection information |
struct sockaddr_in { |
struct in_addr sin_addr; |
unsigned short sin_port; |
unsigned short sin_family; |
short sin_len; |
}; |
#define AF_INET 1 |
#define INADDR_ANY 0 |
|
struct timeval { |
unsigned long tv_sec; |
unsigned long tv_usec; |
}; |
|
/* |
* Simple timer support structure. |
*/ |
typedef void (*tmr_handler_t)(void *user_data); |
|
/* |
* Timer structure. |
* When expiration time is met or exceeded, the handler is |
* called and the timer struct is removed from the list. |
*/ |
typedef struct _timer { |
struct _timer *next; /* next timer in list */ |
unsigned long delay; /* expiration time relative to start time */ |
unsigned long start; /* when the timer was set */ |
tmr_handler_t handler; /* user procedure to call when timer 'fires' */ |
void *user_data; /* user pointer passed to above procedure */ |
} timer_t; |
|
|
/* |
* Ethernet header. |
*/ |
typedef struct { |
enet_addr_t destination; |
enet_addr_t source; |
word type; |
#define ETH_TYPE_IP 0x800 |
#define ETH_TYPE_ARP 0x806 |
#define ETH_TYPE_RARP 0x8053 |
} eth_header_t; |
|
|
/* |
* ARP/RARP header. |
*/ |
typedef struct { |
word hw_type; |
#define ARP_HW_ETHER 1 |
#define ARP_HW_EXP_ETHER 2 |
word protocol; |
octet hw_len; |
octet proto_len; |
word opcode; |
#define ARP_REQUEST 1 |
#define ARP_REPLY 2 |
#define RARP_REQUEST 3 |
#define RARP_REPLY 4 |
enet_addr_t sender_enet; |
ip_addr_t sender_ip; |
enet_addr_t target_enet; |
ip_addr_t target_ip; |
} arp_header_t; |
|
|
#define ARP_PKT_SIZE (sizeof(arp_header_t) + ETH_HDR_SIZE) |
|
/* |
* Internet Protocol header. |
*/ |
typedef struct { |
#ifdef __LITTLE_ENDIAN__ |
octet hdr_len:4, |
version:4; |
#else |
octet version:4, |
hdr_len:4; |
#endif |
octet tos; |
word length; |
word ident; |
word fragment; |
octet ttl; |
octet protocol; |
#define IP_PROTO_ICMP 1 |
#define IP_PROTO_TCP 6 |
#define IP_PROTO_UDP 17 |
word checksum; |
ip_addr_t source; |
ip_addr_t destination; |
} ip_header_t; |
|
|
#define IP_PKT_SIZE (60 + ETH_HDR_SIZE) |
|
|
/* |
* A IP<->ethernet address mapping. |
*/ |
typedef struct { |
ip_addr_t ip_addr; |
enet_addr_t enet_addr; |
} ip_route_t; |
|
|
/* |
* UDP header. |
*/ |
typedef struct { |
word src_port; |
word dest_port; |
word length; |
word checksum; |
} udp_header_t; |
|
|
/* |
* TCP header. |
*/ |
typedef struct { |
word src_port; |
word dest_port; |
dword seqnum; |
dword acknum; |
#ifdef __LITTLE_ENDIAN__ |
octet reserved:4, |
hdr_len:4; |
#else |
octet hdr_len:4, |
reserved:4; |
#endif |
octet flags; |
#define TCP_FLAG_FIN 1 |
#define TCP_FLAG_SYN 2 |
#define TCP_FLAG_RST 4 |
#define TCP_FLAG_PSH 8 |
#define TCP_FLAG_ACK 16 |
#define TCP_FLAG_URG 32 |
word window; |
word checksum; |
word urgent; |
} tcp_header_t; |
|
|
/* |
* ICMP header. |
*/ |
typedef struct { |
octet type; |
#define ICMP_TYPE_ECHOREPLY 0 |
#define ICMP_TYPE_ECHOREQUEST 8 |
octet code; |
word checksum; |
word ident; |
word seqnum; |
} icmp_header_t; |
|
typedef struct _pktbuf { |
struct _pktbuf *next; |
union { |
ip_header_t *__iphdr; /* pointer to IP header */ |
arp_header_t *__arphdr; /* pointer to ARP header */ |
} u1; |
#define ip_hdr u1.__iphdr |
#define arp_hdr u1.__arphdr |
union { |
udp_header_t *__udphdr; /* pointer to UDP header */ |
tcp_header_t *__tcphdr; /* pointer to TCP header */ |
icmp_header_t *__icmphdr; /* pointer to ICMP header */ |
} u2; |
#define udp_hdr u2.__udphdr |
#define tcp_hdr u2.__tcphdr |
#define icmp_hdr u2.__icmphdr |
word pkt_bytes; /* number of data bytes in buf */ |
word bufsize; /* size of buf */ |
word *buf; |
} pktbuf_t; |
|
|
/* protocol handler */ |
typedef void (*pkt_handler_t)(pktbuf_t *pkt, eth_header_t *eth_hdr); |
|
/* ICMP fielder */ |
typedef void (*icmp_handler_t)(pktbuf_t *pkt, ip_route_t *src_route); |
|
typedef struct _udp_socket { |
struct _udp_socket *next; |
word our_port; |
word pad; |
void (*handler)(struct _udp_socket *skt, char *buf, int len, |
ip_route_t *src_route, word src_port); |
} udp_socket_t; |
|
|
typedef void (*udp_handler_t)(udp_socket_t *skt, char *buf, int len, |
ip_route_t *src_route, word src_port); |
|
|
typedef struct _tcp_socket { |
struct _tcp_socket *next; |
int state; /* connection state */ |
#define _CLOSED 0 |
#define _LISTEN 1 |
#define _SYN_RCVD 2 |
#define _SYN_SENT 3 |
#define _ESTABLISHED 4 |
#define _CLOSE_WAIT 5 |
#define _LAST_ACK 6 |
#define _FIN_WAIT_1 7 |
#define _FIN_WAIT_2 8 |
#define _CLOSING 9 |
#define _TIME_WAIT 10 |
ip_route_t his_addr; /* address of other end of connection */ |
word our_port; |
word his_port; |
word data_bytes; /* number of data bytes in pkt */ |
char reuse; /* SO_REUSEADDR, no 2MSL */ |
timer_t timer; |
pktbuf_t pkt; /* dedicated xmit packet */ |
pktbuf_t *rxlist; /* list of unread incoming data packets */ |
char *rxptr; /* pointer to next byte to read */ |
int rxcnt; /* bytes left in current read packet */ |
dword ack; |
dword seq; |
char pktbuf[ETH_MAX_PKTLEN]; |
} tcp_socket_t; |
|
/* |
* Our address. |
*/ |
extern enet_addr_t __local_enet_addr; |
extern ip_addr_t __local_ip_addr; |
#ifdef CYGSEM_REDBOOT_NETWORKING_USE_GATEWAY |
extern ip_addr_t __local_ip_gate; |
extern ip_addr_t __local_ip_mask; |
#endif |
|
/* |
* Set a timer. Caller is responsible for providing the timer_t struct. |
*/ |
extern void __timer_set(timer_t *t, unsigned long delay, |
tmr_handler_t handler, void *user_data); |
|
/* |
* Cancel the given timer. |
*/ |
extern void __timer_cancel(timer_t *t); |
|
/* |
* Poll timer list for timer expirations. |
*/ |
extern void __timer_poll(void); |
|
/* |
* Initialize the free list. |
*/ |
extern void __pktbuf_init(void); |
|
/* |
* simple pktbuf allocation. |
* allocates at least nbytes for packet data including ethernet header. |
*/ |
extern pktbuf_t *__pktbuf_alloc(int nbytes); |
|
/* |
* return a pktbuf for reuse. |
*/ |
extern void __pktbuf_free(pktbuf_t *pkt); |
|
/* |
* Dump packet structures (debug, in case of running out) |
*/ |
extern void __pktbuf_dump(void); |
|
|
/* |
* Install handlers for ethernet packets. |
* Returns old handler. |
*/ |
extern pkt_handler_t __eth_install_listener(int eth_type, |
pkt_handler_t handler); |
extern void __eth_remove_listener(int eth_type); |
|
/* |
* Non-blocking poll of ethernet link. Processes all pending |
* input packets. |
*/ |
extern void __enet_poll(void); |
|
/* |
* Send an ethernet packet. |
*/ |
extern void __enet_send(pktbuf_t *pkt, enet_addr_t *dest, int eth_type); |
|
#ifdef CYGSEM_REDBOOT_NETWORKING_USE_GATEWAY |
/* |
* return true if addr is on local subnet |
*/ |
extern int __ip_addr_local(ip_addr_t *addr); |
#endif |
|
/* |
* Handle incoming ARP packets. |
*/ |
extern void __arp_handler(pktbuf_t *pkt); |
|
/* |
* Find the ethernet address of the machine with the given |
* ip address. |
* Return true and fills in 'eth_addr' if successful, false |
* if unsuccessful. |
*/ |
extern int __arp_request(ip_addr_t *ip_addr, enet_addr_t *eth_addr); |
|
/* |
* Lookup an address from the local ARP cache. If not found, |
* then call 'arp_request' to find it. [Basically just a cached |
* version of 'arp_request'] |
*/ |
extern int __arp_lookup(ip_addr_t *host, ip_route_t *rt); |
|
/* |
* Do a one's complement checksum. |
* The data being checksum'd is in network byte order. |
* The returned checksum is in network byte order. |
*/ |
extern unsigned short __sum(word *w, int len, int init_sum); |
|
/* |
* Compute a partial checksum for the UDP/TCP pseudo header. |
*/ |
extern int __pseudo_sum(ip_header_t *ip); |
|
/* |
* Handle IP packets coming from the polled ethernet interface. |
*/ |
extern void __ip_handler(pktbuf_t *pkt, enet_addr_t *src_enet_addr); |
|
/* |
* Send an IP packet. |
* |
* The IP data field should contain pkt->pkt_bytes of data. |
* pkt->[udp|tcp|icmp]_hdr points to the IP data field. Any |
* IP options are assumed to be already in place in the IP |
* options field. Returns 0 for success. |
*/ |
extern int __ip_send(pktbuf_t *pkt, int protocol, ip_route_t *dest); |
|
/* |
* Abort connection. |
*/ |
extern void __tcp_abort(tcp_socket_t *s, unsigned long delay); |
|
/* |
* Handle incoming ICMP packets. |
*/ |
extern void __icmp_handler(pktbuf_t *pkt, ip_route_t *r); |
extern int __icmp_install_listener(icmp_handler_t handler); |
extern void __icmp_remove_listener(void); |
|
/* |
* Handle incoming UDP packets. |
*/ |
extern void __udp_handler(pktbuf_t *pkt, ip_route_t *r); |
|
/* |
* Install a handler for incoming udp packets. |
* Caller provides the udp_socket_t structure. |
* Returns zero if successful, -1 if socket is already used. |
*/ |
extern int __udp_install_listener(udp_socket_t *s, word port, |
udp_handler_t handler); |
|
/* |
* Remove the handler for the given socket. |
*/ |
extern void __udp_remove_listener(word port); |
|
/* |
* Send a UDP packet. |
*/ |
extern int __udp_send(char *buf, int len, ip_route_t *dest_ip, |
word dest_port, word src_port); |
|
// Send a UDP packet |
extern int __udp_sendto(char *buf, int len, |
struct sockaddr_in *server, struct sockaddr_in *local); |
|
// Receive a UDP packet |
extern int __udp_recvfrom(char *buf, int len, |
struct sockaddr_in *from, struct sockaddr_in *local, |
struct timeval *timeout); |
|
/* |
* TCP poll function. Should be called as often as possible. |
*/ |
extern void __tcp_poll(void); |
|
/* |
* Initiate outgoing connection, waiting for at most timeout seconds. |
*/ |
extern int __tcp_open(tcp_socket_t *s, struct sockaddr_in *host, |
word port, int timeout, int *err); |
|
/* |
* Set up a listening socket on the given port. |
* Does not block. |
*/ |
extern int __tcp_listen(tcp_socket_t *s, word port); |
|
/* |
* SO_REUSEADDR, no 2MSL. |
*/ |
extern void __tcp_so_reuseaddr(tcp_socket_t *s); |
|
/* |
* Block while waiting for all outstanding socket data to |
* be transmitted. |
*/ |
extern void __tcp_drain(tcp_socket_t *s); |
|
/* |
* Initiate connection close. |
*/ |
extern void __tcp_close(tcp_socket_t *s); |
|
/* |
* Wait until connection has fully closed. |
*/ |
extern void __tcp_close_wait(tcp_socket_t *s); |
|
/* |
* Read up to 'len' bytes without blocking. |
* Returns number of bytes read. |
* If connection is closed, returns -1. |
*/ |
extern int __tcp_read(tcp_socket_t *s, char *buf, int len); |
|
/* |
* Write up to 'len' bytes without blocking. |
* Returns number of bytes written. |
* If connection is closed, returns -1. |
*/ |
extern int __tcp_write(tcp_socket_t *s, char *buf, int len); |
|
/* |
* Write up to 'len' bytes, blocking until sent (not ACK'd). |
* Returns number of bytes written. |
* If connection is closed, returns -1. |
*/ |
extern int __tcp_write_block(tcp_socket_t *s, char *buf, int len); |
|
|
/* |
* The following are a higher-level tcp socket interface. |
*/ |
|
/* |
* Initialize a socket for given port. |
*/ |
extern void __skt_init(tcp_socket_t *s, unsigned short port); |
|
/* |
* Return true if socket connection is closed. |
*/ |
#define __skt_is_closed(s) (((tcp_socket_t *)(s))->state == _CLOSED) |
|
/* |
* Block while listening for an incoming connection. |
*/ |
extern void __skt_wait_for_connect(tcp_socket_t *s); |
|
/* |
* Read up to 'len' bytes from the given socket. |
* Returns number of bytes read. |
* Doesn't block. |
*/ |
extern int __skt_read(tcp_socket_t *s, char *buf, int len); |
|
/* |
* Write 'len' bytes to the given socket. |
* Returns number of bytes written. |
* May not write all data if connection closes. |
*/ |
extern int __skt_write(tcp_socket_t *s, char *buf, int len); |
|
// Initialize the network stack - logical driver layer, etc. |
extern void net_init(void); |
|
// Test for new network I/O connections |
extern void net_io_test(bool is_idle); |
|
// Conversion between IP addresses and printable strings |
extern bool inet_aton(const char *, in_addr_t *); |
extern char *inet_ntoa(in_addr_t *); |
|
// FIXME |
/* #define NET_SUPPORT_RARP 1 */ |
#define NET_SUPPORT_ICMP 1 |
#define NET_SUPPORT_UDP 1 |
#define NET_SUPPORT_TCP 1 |
|
#ifdef BSP_LOG |
#define BSPLOG(x) { int old_console = start_console(); x; end_console(old_console); } |
#define bsp_log diag_printf |
#else |
#define BSPLOG(x) |
#endif |
|
#endif // _NET_H_ |