Differences From Artifact [d0ea6d0ea9]:
- File
src/OFSocket.m
— part of check-in
[a54730b88f]
at
2022-10-22 18:41:45
on branch trunk
— OFSocket: Don't combine port for IP and IPX
While it works for those two protocols, it's a bad precedent as other
protocols have different types for ports. (user: js, size: 22894) [annotate] [blame] [check-ins using] [more...]
To Artifact [4fc1cbbf22]:
- File src/OFSocket.m — part of check-in [d1c9ed8498] at 2022-10-22 18:46:25 on branch appletalk — Merge trunk into branch "appletalk" (user: js, size: 25643) [annotate] [blame] [check-ins using] [more...]
︙ | ︙ | |||
568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 | memcpy(&ret.sockaddr.ipx.sipx_network, &network, sizeof(ret.sockaddr.ipx.sipx_network)); memcpy(ret.sockaddr.ipx.sipx_node, node, IPX_NODE_LEN); ret.sockaddr.ipx.sipx_port = OFToBigEndian16(port); return ret; } bool OFSocketAddressEqual(const OFSocketAddress *address1, const OFSocketAddress *address2) { const struct sockaddr_in *addrIn1, *addrIn2; const struct sockaddr_in6 *addrIn6_1, *addrIn6_2; const struct sockaddr_ipx *addrIPX1, *addrIPX2; void *pool; OFString *path1, *path2; bool ret; if (address1->family != address2->family) return false; | > > > > > > > > > > > > > > > > > > > > > > | 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 | memcpy(&ret.sockaddr.ipx.sipx_network, &network, sizeof(ret.sockaddr.ipx.sipx_network)); memcpy(ret.sockaddr.ipx.sipx_node, node, IPX_NODE_LEN); ret.sockaddr.ipx.sipx_port = OFToBigEndian16(port); return ret; } OFSocketAddress OFSocketAddressMakeAppleTalk(uint16_t network, uint8_t node, uint8_t port) { OFSocketAddress ret; memset(&ret, '\0', sizeof(ret)); ret.family = OFSocketAddressFamilyAppleTalk; ret.length = sizeof(ret.sockaddr.at); #ifdef AF_APPLETALK ret.sockaddr.at.sat_family = AF_APPLETALK; #else ret.sockaddr.at.sat_family = AF_UNSPEC; #endif ret.sockaddr.at.sat_net = OFToBigEndian16(network); ret.sockaddr.at.sat_node = node; ret.sockaddr.at.sat_port = port; return ret; } bool OFSocketAddressEqual(const OFSocketAddress *address1, const OFSocketAddress *address2) { const struct sockaddr_in *addrIn1, *addrIn2; const struct sockaddr_in6 *addrIn6_1, *addrIn6_2; const struct sockaddr_ipx *addrIPX1, *addrIPX2; const struct sockaddr_at *addrAT1, *addrAT2; void *pool; OFString *path1, *path2; bool ret; if (address1->family != address2->family) return false; |
︙ | ︙ | |||
653 654 655 656 657 658 659 660 661 662 663 664 665 666 | if (memcmp(&addrIPX1->sipx_network, &addrIPX2->sipx_network, 4) != 0) return false; if (memcmp(addrIPX1->sipx_node, addrIPX2->sipx_node, IPX_NODE_LEN) != 0) return false; return true; default: @throw [OFInvalidArgumentException exception]; } } unsigned long | > > > > > > > > > > > > > > > > | 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 | if (memcmp(&addrIPX1->sipx_network, &addrIPX2->sipx_network, 4) != 0) return false; if (memcmp(addrIPX1->sipx_node, addrIPX2->sipx_node, IPX_NODE_LEN) != 0) return false; return true; case OFSocketAddressFamilyAppleTalk: if (address1->length < (socklen_t)sizeof(struct sockaddr_at) || address2->length < (socklen_t)sizeof(struct sockaddr_at)) @throw [OFInvalidArgumentException exception]; addrAT1 = &address1->sockaddr.at; addrAT2 = &address2->sockaddr.at; if (addrAT1->sat_net != addrAT2->sat_net) return false; if (addrAT1->sat_node != addrAT2->sat_node) return false; if (addrAT1->sat_port != addrAT2->sat_port) return false; return true; default: @throw [OFInvalidArgumentException exception]; } } unsigned long |
︙ | ︙ | |||
729 730 731 732 733 734 735 736 737 738 739 740 741 742 | for (size_t i = 0; i < sizeof(network); i++) OFHashAddByte(&hash, network[i]); for (size_t i = 0; i < IPX_NODE_LEN; i++) OFHashAddByte(&hash, address->sockaddr.ipx.sipx_node[i]); break; default: @throw [OFInvalidArgumentException exception]; } OFHashFinalize(&hash); | > > > > > > > > > | 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 | for (size_t i = 0; i < sizeof(network); i++) OFHashAddByte(&hash, network[i]); for (size_t i = 0; i < IPX_NODE_LEN; i++) OFHashAddByte(&hash, address->sockaddr.ipx.sipx_node[i]); break; case OFSocketAddressFamilyAppleTalk: if (address->length < (socklen_t)sizeof(struct sockaddr_at)) @throw [OFInvalidArgumentException exception]; OFHashAddByte(&hash, address->sockaddr.at.sat_net >> 8); OFHashAddByte(&hash, address->sockaddr.at.sat_net); OFHashAddByte(&hash, address->sockaddr.at.sat_port); break; default: @throw [OFInvalidArgumentException exception]; } OFHashFinalize(&hash); |
︙ | ︙ | |||
944 945 946 947 948 949 950 | OFSocketAddressIPXPort(const OFSocketAddress *address) { if (address->family != OFSocketAddressFamilyIPX) @throw [OFInvalidArgumentException exception]; return OFFromBigEndian16(address->sockaddr.ipx.sipx_port); } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 | OFSocketAddressIPXPort(const OFSocketAddress *address) { if (address->family != OFSocketAddressFamilyIPX) @throw [OFInvalidArgumentException exception]; return OFFromBigEndian16(address->sockaddr.ipx.sipx_port); } void OFSocketAddressSetAppleTalkNetwork(OFSocketAddress *address, uint16_t network) { if (address->family != OFSocketAddressFamilyAppleTalk) @throw [OFInvalidArgumentException exception]; address->sockaddr.at.sat_net = OFToBigEndian16(network); } uint16_t OFSocketAddressAppleTalkNetwork(const OFSocketAddress *address) { if (address->family != OFSocketAddressFamilyAppleTalk) @throw [OFInvalidArgumentException exception]; return OFFromBigEndian16(address->sockaddr.at.sat_net); } void OFSocketAddressSetAppleTalkNode(OFSocketAddress *address, uint8_t node) { if (address->family != OFSocketAddressFamilyAppleTalk) @throw [OFInvalidArgumentException exception]; address->sockaddr.at.sat_node = node; } uint8_t OFSocketAddressAppleTalkNode(const OFSocketAddress *address) { if (address->family != OFSocketAddressFamilyAppleTalk) @throw [OFInvalidArgumentException exception]; return address->sockaddr.at.sat_node; } void OFSocketAddressSetAppleTalkPort(OFSocketAddress *address, uint8_t port) { if (address->family != OFSocketAddressFamilyAppleTalk) @throw [OFInvalidArgumentException exception]; address->sockaddr.at.sat_port = port; } uint8_t OFSocketAddressAppleTalkPort(const OFSocketAddress *address) { if (address->family != OFSocketAddressFamilyAppleTalk) @throw [OFInvalidArgumentException exception]; return address->sockaddr.at.sat_port; } |