| 1258 | #define CONNECTSEQ 0x142 // Magic number for starting a connection, just so it isn't 0 |
| 1259 | |
| 1260 | void nw_WorkReliable(uint8_t *data, int len, network_address *naddr) { |
| 1261 | int i; |
| 1262 | int rcode = -1; |
| 1263 | int16_t max_len = NETBUFFERSIZE; |
| 1264 | static reliable_header rcv_buff; |
| 1265 | static SOCKADDR rcv_addr; |
| 1266 | int bytesin = 0; |
| 1267 | int addrlen = sizeof(SOCKADDR); |
| 1268 | uint32_t rcvid; // The id of who we actually received a packet from, as opposed to socketid parm |
| 1269 | |
| 1270 | if (NP_TCP == naddr->connection_type) { |
| 1271 | SOCKADDR_IN *inaddr = (SOCKADDR_IN *)&rcv_addr; |
| 1272 | memcpy(&inaddr->sin_addr, &naddr->address, 4); |
| 1273 | inaddr->sin_port = htons(naddr->port); |
| 1274 | } |
| 1275 | |
| 1276 | if (Net_connect_sequence == R_NET_SEQUENCE_CONNECTING) { |
| 1277 | nw_HandleConnectResponse(data, len, naddr); |
| 1278 | return; |
| 1279 | } |
| 1280 | // Check for incoming data |
| 1281 | |
| 1282 | reliable_socket *rsocket = NULL; |
| 1283 | // Check to see if we need to send a packet out. |
| 1284 | if ((serverconn != -1) && (reliable_sockets[serverconn].status == RNF_LIMBO) && |
| 1285 | ((timer_GetTime() - last_sent_iamhere) > NETRETRYTIME)) { |
| 1286 | reliable_header conn_header; |
| 1287 | // Now send I_AM_HERE packet |
| 1288 | conn_header.type = RNT_I_AM_HERE; |
| 1289 | conn_header.seq = INTEL_SHORT((int16_t)(~CONNECTSEQ)); |
| 1290 | conn_header.data_len = INTEL_SHORT((int16_t)0); |
| 1291 | last_sent_iamhere = timer_GetTime(); |
| 1292 | network_address send_address; |
| 1293 | memset(&send_address, 0, sizeof(network_address)); |
| 1294 | |
| 1295 | send_address.connection_type = reliable_sockets[serverconn].connection_type; |
| 1296 | if (NP_TCP == send_address.connection_type) { |
| 1297 | SOCKADDR_IN *inaddr = (SOCKADDR_IN *)&reliable_sockets[serverconn].addr; |
| 1298 | memcpy(send_address.address, &inaddr->sin_addr, 4); |
| 1299 | send_address.port = htons(inaddr->sin_port); |
| 1300 | send_address.connection_type = NP_TCP; |
| 1301 | } |
| 1302 | |
| 1303 | int ret = nw_SendWithID(NWT_RELIABLE, (uint8_t *)&conn_header, RELIABLE_PACKET_HEADER_ONLY_SIZE, &send_address); |
| 1304 | |
| 1305 | if ((ret == SOCKET_ERROR) && (WSAEWOULDBLOCK == WSAGetLastError())) { |
| 1306 | reliable_sockets[serverconn].last_packet_sent = timer_GetTime() - NETRETRYTIME; |
| 1307 | } else { |
| 1308 | reliable_sockets[serverconn].last_packet_sent = timer_GetTime(); |
| 1309 | } |
| 1310 | } |
| 1311 | network_protocol link_type = naddr->connection_type; |
| 1312 | network_address d3_rcv_addr; |
| 1313 | memcpy(&d3_rcv_addr, naddr, sizeof(network_address)); |
| 1314 | memcpy((uint8_t *)&rcv_buff, data, len); |
| 1315 | SOCKADDR_IN *rcvaddr, *rsockaddr; |
| 1316 | |
| 1317 | do { |
nothing calls this directly
no test coverage detected