1 /** 2 * xrdp: A Remote Desktop Protocol server. 3 * 4 * Copyright (C) Laxmikant Rashinkar 2013 LK.Rashinkar@gmail.com 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 * 18 */ 19 20 /* 21 * manage I/O for redirected file system and devices 22 */ 23 24 #ifndef __IRP_H 25 #define __IRP_H 26 27 #ifndef _TIME_H_ 28 #include <time.h> 29 #endif 30 #include "chansrv_fuse.h" 31 32 /* Opaque data types to us */ 33 typedef struct xfuse_info XFUSE_INFO; 34 35 enum irp_lookup_state 36 { 37 E_LOOKUP_GET_FH = 0, 38 E_LOOKUP_CHECK_BASIC, 39 E_LOOKUP_CHECK_EOF 40 } ; 41 42 enum irp_setattr_state 43 { 44 E_SETATTR_GET_FH = 0, 45 E_SETATTR_CHECK_BASIC, 46 E_SETATTR_CHECK_EOF 47 } ; 48 49 struct irp_lookup 50 { 51 enum irp_lookup_state state; /* Next state to consider */ 52 struct file_attr fattr; /* Attributes to get */ 53 }; 54 55 struct irp_setattr 56 { 57 enum irp_setattr_state state; /* Next state to consider */ 58 tui32 to_set; /* Bit mask for elements in use */ 59 struct file_attr fattr; /* Attributes to set */ 60 }; 61 62 struct irp_write 63 { 64 tui64 offset; /* Offset the write was made at */ 65 }; 66 67 struct irp_create 68 { 69 int creating_dir; /* We're creating a directory */ 70 }; 71 72 struct irp_rename 73 { 74 char *new_name; /* New name for file */ 75 }; 76 77 /* An I/O Resource Packet to track I/O calls */ 78 79 typedef struct irp IRP; 80 81 struct irp 82 { 83 tui32 CompletionId; /* unique number */ 84 tui32 DeviceId; /* identifies remote device */ 85 tui32 FileId; /* RDP client provided unique number */ 86 char completion_type; /* describes I/O type */ 87 char *pathname; /* absolute pathname 88 * Allocate with 89 * devredir_irp_with_pathname_new() */ 90 union 91 { 92 struct irp_lookup lookup; /* Used by lookup */ 93 struct irp_setattr setattr; /* Used by setattr */ 94 struct irp_write write; /* Used by write */ 95 struct irp_create create; /* Used by create */ 96 struct irp_rename rename; /* Use by rename */ 97 } gen; /* Additional state data for some ops */ 98 void *fuse_info; /* Fuse info pointer for FUSE calls */ 99 IRP *next; /* point to next IRP */ 100 IRP *prev; /* point to previous IRP */ 101 int scard_index; /* used to smart card to locate dev */ 102 103 void (*callback)(struct stream *s, IRP *irp, tui32 DeviceId, 104 tui32 CompletionId, tui32 IoStatus); 105 void *user_data; 106 }; 107 108 IRP *devredir_irp_new(void); 109 /* As above, but allocates sufficent space for the specified 110 * pathname, and copies it in to the pathname field */ 111 IRP *devredir_irp_with_pathname_new(const char *pathname); 112 /* As above, but specifies a pathname length with pathname 113 * initially set to "". Use if you need to modify the pathname 114 * significantly */ 115 IRP *devredir_irp_with_pathnamelen_new(unsigned int pathnamelen); 116 int devredir_irp_delete(IRP *irp); 117 IRP *devredir_irp_find(tui32 completion_id); 118 IRP *devredir_irp_find_by_fileid(tui32 FileId); 119 IRP *devredir_irp_get_last(void); 120 void devredir_irp_dump(void); 121 122 #endif /* end ifndef __IRP_H */ 123