OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [net/] [common/] [current/] [include/] [tftp_support.h] - Blame information for rev 857

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      include/tftp_support.h
4
//
5
//      TFTP support
6
//
7
//==========================================================================
8
// ####BSDALTCOPYRIGHTBEGIN####                                             
9
// -------------------------------------------                              
10
// Portions of this software may have been derived from FreeBSD, OpenBSD,   
11
// or other sources, and if so are covered by the appropriate copyright     
12
// and license included herein.                                             
13
// -------------------------------------------                              
14
// ####BSDALTCOPYRIGHTEND####                                               
15
//==========================================================================
16
//#####DESCRIPTIONBEGIN####
17
//
18
// Author(s):    gthomas
19
// Contributors: gthomas, andrew.lunn@ascom.ch
20
// Date:         2000-04-06
21
// Purpose:      
22
// Description:  
23
//              
24
//
25
//####DESCRIPTIONEND####
26
//
27
//==========================================================================
28
 
29
#ifndef _TFTP_SUPPORT_H_
30
#define _TFTP_SUPPORT_H_
31
 
32
#include <fcntl.h> // O_RDONLY
33
/*
34
 * File transfer modes
35
 */
36
#define TFTP_NETASCII   0              // Text files
37
#define TFTP_OCTET      1              // Binary files
38
 
39
/*
40
 * Errors
41
 */
42
 
43
// These initial 7 are passed across the net in "ERROR" packets.
44
#define TFTP_ENOTFOUND   1   /* file not found */
45
#define TFTP_EACCESS     2   /* access violation */
46
#define TFTP_ENOSPACE    3   /* disk full or allocation exceeded */
47
#define TFTP_EBADOP      4   /* illegal TFTP operation */
48
#define TFTP_EBADID      5   /* unknown transfer ID */
49
#define TFTP_EEXISTS     6   /* file already exists */
50
#define TFTP_ENOUSER     7   /* no such user */
51
// These extensions are return codes in our API, *never* passed on the net.
52
#define TFTP_TIMEOUT     8   /* operation timed out */
53
#define TFTP_NETERR      9   /* some sort of network error */
54
#define TFTP_INVALID    10   /* invalid parameter */
55
#define TFTP_PROTOCOL   11   /* protocol violation */
56
#define TFTP_TOOLARGE   12   /* file is larger than buffer */
57
 
58
/*
59
 * Server support
60
 */
61
 
62
struct tftpd_fileops {
63
    int (*open)(const char *, int);
64
    int (*close)(int);
65
    int (*write)(int, const void *, int);
66
    int (*read)(int, void *, int);
67
};
68
 
69
__externC int tftpd_start(int, struct tftpd_fileops *);
70
__externC int tftpd_stop(int);
71
 
72
/*
73
 * Client support
74
 */
75
 
76
/* IPv4 and IPv6 */
77
__externC int tftp_client_get(const char * const filename,
78
                              const char * const server,
79
                              const int port,
80
                              char * buff,
81
                              int len,
82
                              const int mode,
83
                              int * const err);
84
 
85
__externC int tftp_client_put(const char * const filename,
86
                              const char * const server,
87
                              const int port,
88
                              const char * buf,
89
                              int len,
90
                              const int mode,
91
                              int * const err);
92
 
93
/* IPv4 only */
94
__externC int tftp_get(const char * const filename,
95
                       const struct sockaddr_in * const server,
96
                       char * buf,
97
                       int len,
98
                       const int mode,
99
                       int * const error);
100
 
101
__externC int tftp_put(const char * const filename,
102
                       const struct sockaddr_in * const server,
103
                       const char * buffer,
104
                       int len,
105
                       const int mode,
106
                       int * const err);
107
 
108
#define TFTP_TIMEOUT_PERIOD  5          // Seconds between retries
109
#define TFTP_TIMEOUT_MAX    50          // Max timeouts over all blocks
110
#define TFTP_RETRIES_MAX     5          // retries per block before giving up
111
 
112
#endif // _TFTP_SUPPORT_H_

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.