inetfs.h

Go to the documentation of this file.
00001 /*
00002 ** inetfs.h for  in /home/anoman/work/lse/atomix/lseos-net/inet
00003 ** 
00004 ** Copyright (c)2004 Arthur Kopatsy
00005 ** Login   <kopats_a@epita.fr>
00006 ** 
00007 ** Started on  Wed Jul  7 15:25:58 2004 Arthur Kopatsy
00008 ** Last update Tue Dec 21 11:57:37 2004 Arthur Kopatsy
00009 */
00010 
00011 #ifndef INETFS_H_
00012 #define INETFS_H_
00013 
00014 /* 
00015 ** This structures describe an entry in inetfs
00016 */
00017 
00018 #define INETFS_ENTRYNAME_SIZE   32
00019 
00020 struct s_entry;
00021 struct s_entry_type_op;
00022 struct s_of;
00023 
00024 typedef void (*t_change_fun)(struct s_of *of);
00025                              
00026 typedef struct s_entry
00027 {
00028   LIST_ENTRY(s_entry)                   e_next;
00029 
00030   char                                  e_name[INETFS_ENTRYNAME_SIZE];
00031   LIST_HEAD(s_entry_list, s_entry)      e_list;
00032 
00033   uid_t                                 e_uid;
00034   gid_t                                 e_gid;
00035   size_t                                e_size;
00036   int                                   e_flags;
00037   mode_t                                e_mode;
00038 
00039   int                                   e_type;
00040   const struct s_entry_type_op          *e_type_op;
00041 
00042   void                                  *e_data;
00043   void                                  *e_data_bin;            /* Data used for binary access */
00044 
00045   struct s_entry                        *e_father;
00046   t_change_fun                          e_change_fun;
00047 } t_entry;
00048 
00049 /* 
00050 ** This structure describes an opened file or socket.
00051 */
00052 
00053 typedef struct s_of
00054 {
00055   LIST_ENTRY(s_of)              of_next;
00056   u_int32_t                     of_fd;                  /* File descriptor */
00057   int64_t                       of_holders;
00058   int                           of_flags;               /* flags used to open the file */
00059   t_entry                       *of_entry;              /* in case of a simple proc system entry  */
00060   off_t                         of_offset;              /* current file/mbuf offset     */
00061   int                           of_bin;                 /* if set, use binary access */
00062   t_entry                       *of_cur;                /* current directory offset */
00063 } t_of;
00064 
00065 /* 
00066 ** This array contains all syscall functions
00067 */
00068 
00069 typedef void (*t_sys_fcn)(t_tcb *caller);
00070 
00071 typedef struct s_inetfs_syscall
00072 {
00073   int                   sys_nb;
00074   t_sys_fcn             sys_fcn;
00075 } t_inetfs_syscall;
00076 
00077 extern t_inetfs_syscall inetfs_syscalls[];
00078 
00079 /* 
00080 ** Description of different entry types.
00081 */
00082 
00083 typedef int     (*t_read_fun)(pid_t     pid,
00084                               t_of      *of,
00085                               char      *ubuf,
00086                               size_t    usize);
00087 
00088 typedef int     (*t_write_fun)(pid_t    pid,
00089                                t_of     *of,
00090                                char     *ubuf,
00091                                size_t   size);
00092 
00093 typedef int     (*t_create_entry_fun)(struct s_entry    *father,
00094                                       char              *filename,
00095                                       struct s_entry    **new);
00096 
00097 typedef void    (*t_unlink_entry_fun)(t_entry   *father,
00098                                       char      *filename);
00099 
00100 #define ENTRY_TYPE_DIR          ((1<<1) | 1)
00101 #define ENTRY_TYPE_IFACE_DIR    ((2<<1) | 1)
00102 #define ENTRY_TYPE_ROUTE_DIR    ((3<<1) | 1)
00103 
00104 /* This three types can be used only if no action have to be done except writing */
00105 #define ENTRY_TYPE_UINT32       (2<<1)
00106 #define ENTRY_TYPE_STRING       (3<<1)
00107 
00108 #define ENTRY_TYPE_IPADDR       (4<<1)
00109 #define ENTRY_TYPE_MACADDR      (6<<1)
00110 #define ENTRY_TYPE_ROUTE        (8<<1)
00111 
00112 #define ENTRY_TYPE_SOCKET_TCP   (9<<1)
00113 
00114 typedef struct s_entry_type_op
00115 {
00116   int                   type;
00117   t_read_fun            read_fun;
00118   t_write_fun           write_fun;
00119   t_create_entry_fun    create_entry_fun;
00120   t_unlink_entry_fun    unlink_entry_fun;
00121 } t_entry_type_op;
00122 
00123 extern const t_entry_type_op    inetfs_entry_types_op[];
00124 
00125 /* PROTO inetfs.c */
00126 #ifdef __INET__
00127 /* inetfs.c */
00128 int is_binary_filename(const char *filename);
00129 int macaddr_read(pid_t pid, struct s_of *of, char *ubuf, size_t usize);
00130 int ipaddr_read(pid_t pid, t_of *of, char *ubuf, size_t usize);
00131 int ipaddr_write(pid_t pid, t_of *of, char *ubuf, size_t usize);
00132 t_entry *inetfs_add_entry(t_entry *e_father, const char *e_name, int e_type, void *e_data, void *e_data_bin, size_t e_size, t_change_fun e_change_fun);
00133 int entry_access(t_entry *entry, struct s_ucred *ucred, int how);
00134 int nami(char *path, struct s_ucred *ucred, t_entry **pentry);
00135 void sysinetfs_close(t_tcb *caller);
00136 void sysinetfs_open(t_tcb *caller);
00137 void sysinetfs_stat(t_tcb *caller);
00138 void sysinetfs_fstat(t_tcb *caller);
00139 void sysinetfs_getdents(t_tcb *caller);
00140 void sysinetfs_read(t_tcb *caller);
00141 void sysinetfs_write(t_tcb *caller);
00142 void sysinetfs_lseek(t_tcb *caller);
00143 void sysinetfs_poll(t_tcb *caller);
00144 void sysinetfs_ioctl(t_tcb *caller);
00145 void sysinetfs_dump(t_tcb *caller);
00146 t_of *inetfs_find_of(u_int32_t fd);
00147 #endif /* __INET__ */
00148 #endif

Generated on Wed May 24 23:05:52 2006 for LSE/OS by  doxygen 1.4.6