Subversion Repositories Spectranet

[/] [trunk/] [tnfs/] [tnfsd/] [tnfs.h] - Blame information for rev 570

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 291 winston
#ifndef _TNFS_H
2
#define _TNFS_H
3
 
4
/* The MIT License
5
 *
6
 * Copyright (c) 2010 Dylan Smith
7
 *
8
 * Permission is hereby granted, free of charge, to any person obtaining a copy
9
 * of this software and associated documentation files (the "Software"), to deal
10
 * in the Software without restriction, including without limitation the rights
11
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
 * copies of the Software, and to permit persons to whom the Software is
13
 * furnished to do so, subject to the following conditions:
14
 *
15
 * The above copyright notice and this permission notice shall be included in
16
 * all copies or substantial portions of the Software.
17
 *
18
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
 * THE SOFTWARE.
25
 *
26
 * TNFS structs and definitions
27
 *
28
 * */
29
 
30
#include <stdint.h>
31
#include <dirent.h>
32
 
33 299 winston
#ifdef UNIX
34
#include <arpa/inet.h>
35
#endif
36
#ifdef WIN32
37
#include <windows.h>
38
#endif
39
 
40
#ifndef in_addr_t
41
#define in_addr_t uint32_t
42
#endif
43
 
44
#ifndef socklen_t
45
#define socklen_t int
46
#endif
47
 
48 291 winston
#include "config.h"
49
 
50
/* tnfs command IDs */
51
#define TNFS_MOUNT      0x00
52
#define TNFS_UMOUNT     0x01
53
 
54
#define TNFS_OPENDIR    0x10
55
#define TNFS_READDIR    0x11
56
#define TNFS_CLOSEDIR   0x12
57
 
58
#define TNFS_OPENFILE   0x20
59
#define TNFS_READBLOCK  0x21
60
#define TNFS_WRITEBLOCK 0x22
61
#define TNFS_CLOSEFILE  0x23
62
#define TNFS_STATFILE   0x24
63
#define TNFS_SEEKFILE   0x25
64
#define TNFS_UNLINKFILE 0x26
65
#define TNFS_CHMODFILE  0x27
66
#define TNFS_RENAMEFILE 0x28
67
 
68
/* command classes etc. */
69
#define CLASS_SESSION   0x00
70
#define CLASS_DIRECTORY 0x10
71
#define CLASS_FILE      0x20
72 412 winston
#define NUM_DIRCMDS     5
73 484 winston
#define NUM_FILECMDS    10
74 291 winston
 
75
typedef struct _session
76
{
77
        uint16_t sid;                   /* session ID */
78
        in_addr_t ipaddr;               /* client addr */
79
        uint8_t seqno;                  /* last sequence number */
80
        int fd[MAX_FD_PER_CONN];        /* file descriptors */
81 409 winston
        DIR *dhnd[MAX_DHND_PER_CONN];   /* directory handles */
82 291 winston
        char *root;                     /* requested root dir */
83
        unsigned char lastmsg[MAXMSGSZ];/* last message sent */
84
        int lastmsgsz;                  /* last message's size inc. hdr */
85
        uint8_t lastseqno;              /* last sequence number */
86 570 winston
        uint8_t isTCP;                  /* uses the TCP transport */
87 291 winston
 
88
} Session;
89
 
90
typedef struct _header
91
{
92
        uint16_t sid;                   /* session id */
93
        uint8_t seqno;                  /* sequence number */
94
        uint8_t cmd;                    /* command */
95
        uint8_t status;                 /* command's status */
96
        in_addr_t ipaddr;               /* client address */
97
        uint16_t port;                  /* client port address */
98
} Header;
99
 
100
typedef void(*tnfs_cmdfunc)(Header *hdr, Session *sess,
101
                                unsigned char *buf, int bufsz);
102
 
103
#endif
104