Changeset 17 for abuse/trunk/src/old.nfserver.cpp
- Timestamp:
- Nov 10, 2005, 9:41:13 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/src/old.nfserver.cpp
r2 r17 84 84 int nfs_server::process_packet(packet &pk, nfs_server_client_node *c) 85 85 { 86 u charcmd;86 uint8_t cmd; 87 87 if (pk.read(&cmd,1)!=1) 88 88 { … … 97 97 case NFS_CRC_OPEN : 98 98 { 99 u charfn_len;99 uint8_t fn_len; 100 100 char fn[255],newfn[255],perm[255]; 101 u longcrc;102 if (pk.read((u char*)&crc,4)!=4) return 0; crc=lltl(crc);101 uint32_t crc; 102 if (pk.read((uint8_t *)&crc,4)!=4) return 0; crc=lltl(crc); 103 103 if (pk.read(&fn_len,1)!=1) return 0; 104 if (pk.read((u char*)fn,fn_len)!=fn_len) return 0;105 if (pk.read((u char*)&fn_len,1)!=1) return 0;106 if (pk.read((u char*)perm,fn_len)!=fn_len) return 0; // read permission string104 if (pk.read((uint8_t *)fn,fn_len)!=fn_len) return 0; 105 if (pk.read((uint8_t *)&fn_len,1)!=1) return 0; 106 if (pk.read((uint8_t *)perm,fn_len)!=fn_len) return 0; // read permission string 107 107 dprintf("nfs open %s,%s\n",fn,perm); 108 108 packet opk; 109 109 int fail; 110 u longmy_crc=crc_man.get_crc(crc_man.get_filenumber(fn),fail);110 uint32_t my_crc=crc_man.get_crc(crc_man.get_filenumber(fn),fail); 111 111 if (fail) 112 112 { … … 115 115 { 116 116 delete fp; 117 opk.write_ long((long)-1);117 opk.write_uint32((int32_t)-1); 118 118 if (!c->nd->send(opk)) return 0; 119 119 return 1; … … 128 128 if (my_crc==crc) 129 129 { 130 opk.write_ long((long)-2);130 opk.write_uint32((int32_t)-2); 131 131 if (!c->nd->send(opk)) return 0; 132 132 return 1; … … 137 137 { 138 138 delete fp; 139 opk.write_ long((long)-1);139 opk.write_uint32((int32_t)-1); 140 140 } else 141 opk.write_ long(c->add_file(fp));141 opk.write_uint32(c->add_file(fp)); 142 142 if (!c->nd->send(opk)) return 0; 143 143 return 1; … … 145 145 case NFS_OPEN : 146 146 { 147 u charfn_len;147 uint8_t fn_len; 148 148 char fn[255],newfn[255],perm[255]; 149 149 if (pk.read(&fn_len,1)!=1) return 0; 150 if (pk.read((u char*)fn,fn_len)!=fn_len) return 0;151 if (pk.read((u char*)&fn_len,1)!=1) return 0;152 if (pk.read((u char*)perm,fn_len)!=fn_len) return 0; // read permission string150 if (pk.read((uint8_t *)fn,fn_len)!=fn_len) return 0; 151 if (pk.read((uint8_t *)&fn_len,1)!=1) return 0; 152 if (pk.read((uint8_t *)perm,fn_len)!=fn_len) return 0; // read permission string 153 153 dprintf("nfs open %s,%s\n",fn,perm); 154 154 packet opk; … … 157 157 { 158 158 delete fp; 159 opk.write_ long((long)-1);159 opk.write_uint32((int32_t)-1); 160 160 } else 161 opk.write_ long(c->add_file(fp));161 opk.write_uint32(c->add_file(fp)); 162 162 if (!c->nd->send(opk)) return 0; 163 163 return 1; … … 165 165 case NFS_CLOSE : 166 166 { 167 longfd;168 if (pk.read((u char*)&fd,4)!=4) return 0; fd=lltl(fd);167 int32_t fd; 168 if (pk.read((uint8_t *)&fd,4)!=4) return 0; fd=lltl(fd); 169 169 dprintf("nfs close %d\n",fd); 170 170 if (!c->delete_file(fd)) … … 177 177 case NFS_READ : 178 178 { 179 longfd,size;180 if (pk.read((u char*)&fd,4)!=4) return 0; fd=lltl(fd);181 if (pk.read((u char*)&size,4)!=4) return 0; size=lltl(size);179 int32_t fd,size; 180 if (pk.read((uint8_t *)&fd,4)!=4) return 0; fd=lltl(fd); 181 if (pk.read((uint8_t *)&size,4)!=4) return 0; size=lltl(size); 182 182 dprintf("nfs read %d,%d\n",fd,size); 183 183 bFILE *fp=c->get_file(fd); 184 u charbuf[NFSFILE_BUFFER_SIZE];184 uint8_t buf[NFSFILE_BUFFER_SIZE]; 185 185 packet opk; 186 186 if (!fp) return 0; … … 191 191 int to_read=NFSFILE_BUFFER_SIZE < size ? NFSFILE_BUFFER_SIZE : size; 192 192 total=fp->read(buf,to_read); 193 opk.write_ short(total);193 opk.write_uint16(total); 194 194 opk.write(buf,total); 195 195 printf("sending %d bytes\n",total); … … 211 211 case NFS_SEEK : 212 212 { 213 longfd,off,type;214 if (pk.read((u char*)&fd,4)!=4) return 0; fd=lltl(fd);215 if (pk.read((u char*)&off,4)!=4) return 0; off=lltl(off);216 if (pk.read((u char*)&type,4)!=4) return 0; type=lltl(type);213 int32_t fd,off,type; 214 if (pk.read((uint8_t *)&fd,4)!=4) return 0; fd=lltl(fd); 215 if (pk.read((uint8_t *)&off,4)!=4) return 0; off=lltl(off); 216 if (pk.read((uint8_t *)&type,4)!=4) return 0; type=lltl(type); 217 217 dprintf("seek %d %d %d\n",fd,off,type); 218 218 bFILE *fp=c->get_file(fd); … … 223 223 case NFS_FILESIZE : 224 224 { 225 longfd,off,type;226 if (pk.read((u char*)&fd,4)!=4) return 0; fd=lltl(fd);225 int32_t fd,off,type; 226 if (pk.read((uint8_t *)&fd,4)!=4) return 0; fd=lltl(fd); 227 227 bFILE *fp=c->get_file(fd); 228 228 if (!fp) return 0; 229 229 packet opk; 230 opk.write_ long(fp->file_size());230 opk.write_uint32(fp->file_size()); 231 231 if (!c->nd->send(opk)) return 0; 232 232 return 1; … … 234 234 case NFS_TELL : 235 235 { 236 longfd,off,type;237 if (pk.read((u char*)&fd,4)!=4) return 0; fd=lltl(fd);236 int32_t fd,off,type; 237 if (pk.read((uint8_t *)&fd,4)!=4) return 0; fd=lltl(fd); 238 238 bFILE *fp=c->get_file(fd); 239 239 if (!fp) return 0; 240 240 packet opk; 241 opk.write_ long(fp->tell());241 opk.write_uint32(fp->tell()); 242 242 if (!c->nd->send(opk)) return 0; 243 243 return 1;
Note: See TracChangeset
for help on using the changeset viewer.