| 1 | /* |
| 2 | * Copyright (C) 1999,2000 Ross Combs ([email protected]) |
| 3 | * Copyright (C) 1999,2000 Rob Crittenden ([email protected]) |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License |
| 7 | * as published by the Free Software Foundation; either version 2 |
| 8 | * of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 | */ |
| 19 | #include "common/setup_before.h"cxx . . $ `<file>/src/common/setup_before.h`/ |
| 20 | #include "handle_file.h"cxx . . $ `<file>/src/bnetd/handle_file.h`/ |
| 21 | |
| 22 | #include "compat/psock.h"cxx . . $ `<file>/src/compat/psock.h`/ |
| 23 | #include "common/eventlog.h"cxx . . $ `<file>/src/common/eventlog.h`/ |
| 24 | #include "common/packet.h"cxx . . $ `<file>/src/common/packet.h`/ |
| 25 | #include "common/bn_type.h"cxx . . $ `<file>/src/common/bn_type.h`/ |
| 26 | |
| 27 | #include "connection.h"cxx . . $ `<file>/src/bnetd/connection.h`/ |
| 28 | #include "file.h"cxx . . $ `<file>/src/bnetd/file.h`/ |
| 29 | #include "common/setup_after.h"cxx . . $ `<file>/src/common/setup_after.h`/ |
| 30 | |
| 31 | |
| 32 | namespace pvpgncxx . . $ pvpgn/ |
| 33 | { |
| 34 | |
| 35 | namespace bnetdcxx . . $ pvpgn/bnetd/ |
| 36 | { |
| 37 | |
| 38 | extern int handle_file_packetcxx . . $ pvpgn/bnetd/handle_file_packet(8d07eb83d60bed1d).(t_connection * c, t_packetcxx . . $ pvpgn/t_packet# const * const packet) |
| 39 | { |
| 40 | if (!c) |
| 41 | { |
| 42 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "[{}] got NULL connection", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c)); |
| 43 | return -1; |
| 44 | } |
| 45 | if (!packet) |
| 46 | { |
| 47 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "[{}] got NULL packet", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c)); |
| 48 | return -1; |
| 49 | } |
| 50 | /* REMOVED BY UNDYING SOULZZ 4/3/02 */ |
| 51 | /* |
| 52 | if (packet_get_class(packet)!=packet_class_file) |
| 53 | { |
| 54 | eventlog(eventlog_level_error,__FUNCTION__,"[%d] got bad packet (class %d)",conn_get_socket(c),(int)packet_get_class(packet)); |
| 55 | return -1; |
| 56 | } |
| 57 | */ |
| 58 | switch (conn_get_statecxx . . $ pvpgn/bnetd/conn_get_state(14586157a79399d4).(c)) |
| 59 | { |
| 60 | case conn_state_connected: |
| 61 | switch (packet_get_typecxx . . $ pvpgn/packet_get_type(e4ac9e2b4744cb4b).(packet)) |
| 62 | { |
| 63 | case CLIENT_FILE_REQcxx . . $ `src/common/file_protocol.h:68:9`!: |
| 64 | { |
| 65 | char const * rawname; |
| 66 | |
| 67 | if (!(rawname = packet_get_str_constcxx . . $ pvpgn/packet_get_str_const(2621638e840efcc6).(packet, sizeof(t_client_file_reqcxx . . $ pvpgn/t_client_file_req#), MAX_FILENAME_STRcxx . . $ MAX_FILENAME_STR.))) |
| 68 | { |
| 69 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "[{}] got bad FILE_REQ (missing or too long filename)", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c)); |
| 70 | |
| 71 | return -1; |
| 72 | } |
| 73 | |
| 74 | file_sendcxx . . $ pvpgn/bnetd/file_send(bcadffea2cd735b4).(c, rawname, |
| 75 | bn_int_get(packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..client_file_reqcxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#client_file_req..adidcxx . . $ pvpgn/$anonymous_type_d2bac4e24f922c3_2#adid.), |
| 76 | bn_int_get(packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..client_file_reqcxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#client_file_req..extensiontagcxx . . $ pvpgn/$anonymous_type_d2bac4e24f922c3_2#extensiontag.), |
| 77 | bn_int_get(packet->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..client_file_reqcxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#client_file_req..startoffsetcxx . . $ pvpgn/$anonymous_type_d2bac4e24f922c3_2#startoffset.), |
| 78 | 1); |
| 79 | } |
| 80 | break; |
| 81 | |
| 82 | case CLIENT_FILE_REQ2cxx . . $ `src/common/file_protocol.h:92:9`!: |
| 83 | { |
| 84 | t_packetcxx . . $ pvpgn/t_packet# * rpacket = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 85 | if ((rpacket = packet_createcxx . . $ pvpgn/packet_create(f721c565085e24c0).(packet_class_rawcxx . . $ pvpgn/packet_class_raw.))) { |
| 86 | packet_set_sizecxx . . $ pvpgn/packet_set_size(a12d8724e4c46208).(rpacket, sizeof(t_server_file_unknown1cxx . . $ pvpgn/t_server_file_unknown1#)); |
| 87 | bn_int_set(&rpacket->ucxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#u..server_file_unknown1cxx . . $ pvpgn/$anonymous_type_a1640d8ff791e3e5_2#$anonymous_type_3#server_file_unknown1..unknowncxx . . $ pvpgn/$anonymous_type_d2bac4e24f922c3_6#unknown., 0xdeadbeef); |
| 88 | conn_push_outqueuecxx . . $ pvpgn/bnetd/conn_push_outqueue(212cf84cd7032d49).(c, rpacket); |
| 89 | packet_del_refcxx . . $ pvpgn/packet_del_ref(d23439d9c1f63082).(rpacket); |
| 90 | } |
| 91 | conn_set_statecxx . . $ pvpgn/bnetd/conn_set_state(7b556497952c81aa).(c, conn_state_pending_raw); |
| 92 | break; |
| 93 | } |
| 94 | |
| 95 | default: |
| 96 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "[{}] unknown file packet type 0x{:04x}, len {}", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c), packet_get_typecxx . . $ pvpgn/packet_get_type(e4ac9e2b4744cb4b).(packet), packet_get_sizecxx . . $ pvpgn/packet_get_size(e4ac9e2b4744cb4b).(packet)); |
| 97 | |
| 98 | break; |
| 99 | } |
| 100 | break; |
| 101 | |
| 102 | case conn_state_pending_raw: |
| 103 | switch (packet_get_typecxx . . $ pvpgn/packet_get_type(e4ac9e2b4744cb4b).(packet)) |
| 104 | { |
| 105 | case CLIENT_FILE_REQ3cxx . . $ `src/common/file_protocol.h:101:9`!: |
| 106 | { |
| 107 | char rawname[MAX_FILENAME_STRcxx . . $ MAX_FILENAME_STR.] = {}; |
| 108 | |
| 109 | psock_recvcxx . . $ `src/compat/psock.h:297:9`!(conn_get_socket(c), rawname, MAX_FILENAME_STR, 0); |
| 110 | file_sendcxx . . $ pvpgn/bnetd/file_send(bcadffea2cd735b4).(c, rawname, 0, 0, 0, 1); |
| 111 | } |
| 112 | break; |
| 113 | |
| 114 | default: |
| 115 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "[{}] unknown file packet type 0x{:04x}, len {}", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c), packet_get_typecxx . . $ pvpgn/packet_get_type(e4ac9e2b4744cb4b).(packet), packet_get_sizecxx . . $ pvpgn/packet_get_size(e4ac9e2b4744cb4b).(packet)); |
| 116 | |
| 117 | break; |
| 118 | } |
| 119 | break; |
| 120 | |
| 121 | default: |
| 122 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "[{}] unknown file connection state {}", conn_get_socketcxx . . $ pvpgn/bnetd/conn_get_socket(b5160de3e9803af4).(c), (int)conn_get_statecxx . . $ pvpgn/bnetd/conn_get_state(14586157a79399d4).(c)); |
| 123 | } |
| 124 | |
| 125 | return 0; |
| 126 | } |
| 127 | |
| 128 | } |
| 129 | |
| 130 | } |