Rev 18 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 18 | Rev 20 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include "pd/net.h" |
1 | #include "pd/net.h" |
2 | 2 | ||
3 | #include "brender.h" |
3 | #include "brender/brender.h" |
4 | #include "dr_types.h" |
4 | #include "dr_types.h" |
5 | #include "errors.h" |
5 | #include "errors.h" |
6 | #include "globvrpb.h" |
6 | #include "globvrpb.h" |
7 | #include "harness/config.h" |
7 | #include "harness/config.h" |
8 | #include "harness/hooks.h" |
8 | #include "harness/hooks.h" |
Line 53... | Line 53... | ||
53 | struct sockaddr_in gLast_received_addr; |
53 | struct sockaddr_in gLast_received_addr; |
54 | int gSocket; |
54 | int gSocket; |
55 | 55 | ||
56 | #define MESSAGE_HEADER_STR "CW95MSG" |
56 | #define MESSAGE_HEADER_STR "CW95MSG" |
57 | #define JOINABLE_GAMES_CAPACITY 16 |
57 | #define JOINABLE_GAMES_CAPACITY 16 |
58 | - | ||
59 | DR_STATIC_ASSERT(offsetof(tNet_message, pd_stuff_so_DO_NOT_USE) == 0); |
- | |
60 | DR_STATIC_ASSERT(offsetof(tNet_message, magic_number) == 4); |
- | |
61 | DR_STATIC_ASSERT(offsetof(tNet_message, guarantee_number) == 8); |
- | |
62 | DR_STATIC_ASSERT(offsetof(tNet_message, sender) == 12); |
- | |
63 | DR_STATIC_ASSERT(offsetof(tNet_message, version) == 16); |
- | |
64 | DR_STATIC_ASSERT(offsetof(tNet_message, senders_time_stamp) == 20); |
- | |
65 | DR_STATIC_ASSERT(offsetof(tNet_message, num_contents) == 24); |
- | |
66 | DR_STATIC_ASSERT(offsetof(tNet_message, overall_size) == 26); |
- | |
67 | DR_STATIC_ASSERT(offsetof(tNet_message, contents) == 28); |
- | |
68 | 58 | ||
69 | // IDA: void __cdecl ClearupPDNetworkStuff() |
59 | // IDA: void __cdecl ClearupPDNetworkStuff() |
70 | void ClearupPDNetworkStuff(void) { |
60 | void ClearupPDNetworkStuff(void) { |
71 | LOG_TRACE("()"); |
61 | LOG_TRACE("()"); |
72 | NOT_IMPLEMENTED(); |
62 | NOT_IMPLEMENTED(); |
Line 136... | Line 126... | ||
136 | 126 | ||
137 | int SameEthernetAddress(struct sockaddr_in* pAddr_ipx1, struct sockaddr_in* pAddr_ipx2) { |
127 | int SameEthernetAddress(struct sockaddr_in* pAddr_ipx1, struct sockaddr_in* pAddr_ipx2) { |
138 | LOG_TRACE("(%p, %p)", pAddr_ipx1, pAddr_ipx2); |
128 | LOG_TRACE("(%p, %p)", pAddr_ipx1, pAddr_ipx2); |
139 | 129 | ||
140 | return memcmp(pAddr_ipx1, pAddr_ipx2, sizeof(struct sockaddr_in)) == 0; |
130 | return memcmp(pAddr_ipx1, pAddr_ipx2, sizeof(struct sockaddr_in)) == 0; |
141 | } |
131 | } |
142 | 132 | ||
143 | /*SOCKADDR_IPX_* */ void* GetIPXAddrFromPlayerID(tPlayer_ID pPlayer_id) { |
133 | /*SOCKADDR_IPX_* */ void* GetIPXAddrFromPlayerID(tPlayer_ID pPlayer_id) { |
144 | //int i; // Pierre-Marie Baty -- unused variable |
134 | //int i; // Pierre-Marie Baty -- unused variable |
145 | //tU8* nodenum; // Pierre-Marie Baty -- unused variable |
135 | //tU8* nodenum; // Pierre-Marie Baty -- unused variable |
146 | NOT_IMPLEMENTED(); |
136 | NOT_IMPLEMENTED(); |
Line 574... | Line 564... | ||
574 | 564 | ||
575 | char addr_str[32]; |
565 | char addr_str[32]; |
576 | unsigned int sa_len; |
566 | unsigned int sa_len; |
577 | int res; |
567 | int res; |
578 | tNet_message* msg; |
568 | tNet_message* msg; |
579 | 569 | ||
580 | sa_len = sizeof(gRemote_addr); |
570 | sa_len = sizeof(gRemote_addr); |
581 | msg = NetAllocateMessage(512); |
571 | msg = NetAllocateMessage(512); |
582 | receive_buffer = (char*)msg; |
572 | receive_buffer = (char*)msg; |
583 | res = recvfrom(gSocket, receive_buffer, 512, 0, (struct sockaddr*)&gRemote_addr, &sa_len); |
573 | res = recvfrom(gSocket, receive_buffer, 512, 0, (struct sockaddr*)&gRemote_addr, &sa_len); |
584 | res = res != -1; |
574 | res = res != -1; |
Line 619... | Line 609... | ||
619 | } |
609 | } |
620 | 610 | ||
621 | // IDA: tNet_message* __usercall PDNetAllocateMessage@<EAX>(tU32 pSize@<EAX>, tS32 pSize_decider@<EDX>) |
611 | // IDA: tNet_message* __usercall PDNetAllocateMessage@<EAX>(tU32 pSize@<EAX>, tS32 pSize_decider@<EDX>) |
622 | tNet_message* PDNetAllocateMessage(tU32 pSize, tS32 pSize_decider) { |
612 | tNet_message* PDNetAllocateMessage(tU32 pSize, tS32 pSize_decider) { |
623 | LOG_TRACE("(%d, %d)", pSize, pSize_decider); |
613 | LOG_TRACE("(%d, %d)", pSize, pSize_decider); |
624 | NOT_IMPLEMENTED(); |
614 | NOT_IMPLEMENTED(); |
625 | } |
615 | } |
626 | 616 | ||
627 | // IDA: void __usercall PDNetDisposeMessage(tNet_game_details *pDetails@<EAX>, tNet_message *pMessage@<EDX>) |
617 | // IDA: void __usercall PDNetDisposeMessage(tNet_game_details *pDetails@<EAX>, tNet_message *pMessage@<EDX>) |
628 | void PDNetDisposeMessage(tNet_game_details* pDetails, tNet_message* pMessage) { |
618 | void PDNetDisposeMessage(tNet_game_details* pDetails, tNet_message* pMessage) { |
629 | LOG_TRACE("(%p, %p)", pDetails, pMessage); |
619 | LOG_TRACE("(%p, %p)", pDetails, pMessage); |
630 | NOT_IMPLEMENTED(); |
620 | NOT_IMPLEMENTED(); |
Line 648... | Line 638... | ||
648 | int PDNetSendMessageToAddress(tNet_game_details* pDetails, tNet_message* pMessage, void* pAddress) { |
638 | int PDNetSendMessageToAddress(tNet_game_details* pDetails, tNet_message* pMessage, void* pAddress) { |
649 | char str[256]; |
639 | char str[256]; |
650 | LOG_TRACE("(%p, %p, %p)", pDetails, pMessage, pAddress); |
640 | LOG_TRACE("(%p, %p, %p)", pDetails, pMessage, pAddress); |
651 | 641 | ||
652 | NetNowIPXLocalTarget2String(str, (struct sockaddr_in*)pAddress); |
642 | NetNowIPXLocalTarget2String(str, (struct sockaddr_in*)pAddress); |
- | 643 | if (pDetails->pd_net_info.addr_in.sin_port == 0) { |
|
- | 644 | int i = 0; |
|
- | 645 | } |
|
653 | 646 | ||
654 | if (sendto(gSocket, (const char*)pMessage, pMessage->overall_size, 0, (const struct sockaddr*)pAddress, sizeof(struct sockaddr)) == -1) { |
647 | if (sendto(gSocket, (const char*)pMessage, pMessage->overall_size, 0, (const struct sockaddr*)pAddress, sizeof(struct sockaddr)) == -1) { |
655 | dr_dprintf("PDNetSendMessageToAddress(): Error on sendto() - WSAGetLastError=%d", WSAGetLastError()); |
648 | dr_dprintf("PDNetSendMessageToAddress(): Error on sendto() - WSAGetLastError=%d", WSAGetLastError()); |
656 | NetDisposeMessage(pDetails, pMessage); |
649 | NetDisposeMessage(pDetails, pMessage); |
657 | return 1; |
650 | return 1; |