diff options
| author | Reiner Herrmann <reiner@reiner-h.de> | 2019-03-03 11:12:21 +0100 |
|---|---|---|
| committer | Reiner Herrmann <reiner@reiner-h.de> | 2019-03-03 11:12:21 +0100 |
| commit | 96978307ad0d2ab2ad29d082f213770d56d7a4a6 (patch) | |
| tree | d4ce14b83bab21883b41c8ddcf66908eee2c09ab /src/tftpd.rs | |
| parent | 8f5d8798eea9c68cce474810aa0ee4fd432f3a0f (diff) | |
Don't hardcode opcode values everywhere
Diffstat (limited to 'src/tftpd.rs')
| -rw-r--r-- | src/tftpd.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/tftpd.rs b/src/tftpd.rs index 0b06310..48e374e 100644 --- a/src/tftpd.rs +++ b/src/tftpd.rs @@ -168,7 +168,7 @@ impl Tftpd { socket.connect(cl)?; let _opcode = match u16::from_be_bytes([buf[0], buf[1]]) { - 1 /* RRQ */ => { + o if o == rtftp::Opcodes::RRQ as u16 => { if self.conf.wo { self.tftp.send_error(&socket, 4, "reading not allowed")?; return Err(io::Error::new(io::ErrorKind::Other, "unallowed mode")); @@ -176,7 +176,7 @@ impl Tftpd { self.handle_rrq(&socket, &cl, &buf[2..])?; } }, - 2 /* WRQ */ => { + o if o == rtftp::Opcodes::WRQ as u16 => { if self.conf.ro { self.tftp.send_error(&socket, 4, "writing not allowed")?; return Err(io::Error::new(io::ErrorKind::Other, "unallowed mode")); @@ -184,7 +184,7 @@ impl Tftpd { self.handle_wrq(&socket, &cl, &buf[2..])?; } }, - 5 /* ERROR */ => println!("Received ERROR from {}", cl), + o if o == rtftp::Opcodes::ERROR as u16 => println!("Received ERROR from {}", cl), _ => { self.tftp.send_error(&socket, 4, "Unexpected opcode")?; return Err(io::Error::new(io::ErrorKind::Other, "unexpected opcode")); |
