1/* 2 * Copyright (c) 2010 Apple Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. Neither the name of Apple Inc. ("Apple") nor the names of its 16 * contributors may be used to endorse or promote products derived from 17 * this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * 30 * Portions of this software have been released under the following terms: 31 * 32 * (c) Copyright 1989-1993 OPEN SOFTWARE FOUNDATION, INC. 33 * (c) Copyright 1989-1993 HEWLETT-PACKARD COMPANY 34 * (c) Copyright 1989-1993 DIGITAL EQUIPMENT CORPORATION 35 * 36 * To anyone who acknowledges that this file is provided "AS IS" 37 * without any express or implied warranty: 38 * permission to use, copy, modify, and distribute this file for any 39 * purpose is hereby granted without fee, provided that the above 40 * copyright notices and this notice appears in all source code copies, 41 * and that none of the names of Open Software Foundation, Inc., Hewlett- 42 * Packard Company or Digital Equipment Corporation be used 43 * in advertising or publicity pertaining to distribution of the software 44 * without specific, written prior permission. Neither Open Software 45 * Foundation, Inc., Hewlett-Packard Company nor Digital 46 * Equipment Corporation makes any representations about the suitability 47 * of this software for any purpose. 48 * 49 * Copyright (c) 2007, Novell, Inc. All rights reserved. 50 * Redistribution and use in source and binary forms, with or without 51 * modification, are permitted provided that the following conditions 52 * are met: 53 * 54 * 1. Redistributions of source code must retain the above copyright 55 * notice, this list of conditions and the following disclaimer. 56 * 2. Redistributions in binary form must reproduce the above copyright 57 * notice, this list of conditions and the following disclaimer in the 58 * documentation and/or other materials provided with the distribution. 59 * 3. Neither the name of Novell Inc. nor the names of its contributors 60 * may be used to endorse or promote products derived from this 61 * this software without specific prior written permission. 62 * 63 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 64 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 65 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 66 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY 67 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 68 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 69 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 70 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 71 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 72 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 73 * 74 * @APPLE_LICENSE_HEADER_END@ 75 */ 76 77/* 78 */ 79/* 80** 81** NAME 82** 83** comnaf.c 84** 85** FACILITY: 86** 87** Remote Procedure Call (RPC) 88** 89** ABSTRACT: 90** 91** Definition of the Network Address Family Services for the Common 92** Communication Services component. These routines are called by the 93** other services internal to the RPC runtime (such as protocol services) 94** to dispatch to the appropriate Network Address Family service. 95** 96** 97*/ 98 99#include <commonp.h> /* Common declarations for all RPC runtime */ 100#include <com.h> /* Common communications services */ 101#include <comprot.h> /* Common protocol services */ 102#include <comnaf.h> /* Common network address family services */ 103#include <comp.h> /* Private communications services */ 104#include <comtwrref.h> /* Private tower defs for other RPC components */ 105 106#include <assert.h> 107 108 109/* 110**++ 111** 112** ROUTINE NAME: rpc__naf_addr_alloc 113** 114** SCOPE: PRIVATE - declared in com.h 115** 116** DESCRIPTION: 117** 118** Dispatch to a Network Address Family Service to create an RPC Address. 119** 120** INPUTS: 121** 122** protseq_id The RPC Protocol Sequence ID which represents a 123** NAF, NAF Transport Protocol, and NAF Interface Type 124** 125** naf_id The NAF ID of the RPC Address 126** 127** endpoint The string containing the endpoint to be placed 128** in the RPC Address 129** 130** netaddr The string containing the network address to be 131** placed in the RPC Address 132** 133** network_options A vector of network options tag and value strings 134** to be placed in the RPC Address 135** 136** INPUTS/OUTPUTS: none 137** 138** OUTPUTS: 139** 140** rpc_addr The RPC Address to be created in the format of a 141** particular NAF 142** 143** status A value indicating the return status of the routine 144** 145** Any of the values returned by the NAF addr_alloc routine 146** 147** IMPLICIT INPUTS: none 148** 149** IMPLICIT OUTPUTS: none 150** 151** FUNCTION VALUE: void 152** 153** SIDE EFFECTS: none 154** 155**-- 156**/ 157 158PRIVATE void rpc__naf_addr_alloc 159( 160 rpc_protseq_id_t protseq_id, 161 rpc_naf_id_t naf_id, 162 unsigned_char_p_t endpoint, 163 unsigned_char_p_t netaddr, 164 unsigned_char_p_t network_options, 165 rpc_addr_p_t *rpc_addr, 166 unsigned32 *status 167) 168{ 169 RPC_LOG_NAF_ADDR_ALLOC_NTR; 170 171 /* 172 * dispatch to the appropriate NAF service 173 */ 174 (*rpc_g_naf_id[naf_id].epv->naf_addr_alloc) 175 (protseq_id, naf_id, endpoint, netaddr, network_options, 176 rpc_addr, status); 177 178 RPC_LOG_NAF_ADDR_ALLOC_XIT; 179} 180 181/* 182**++ 183** 184** ROUTINE NAME: rpc__naf_addr_free 185** 186** SCOPE: PRIVATE - declared in com.h 187** 188** DESCRIPTION: 189** 190** Dispatch to a Network Address Family Service to free an RPC Address. 191** 192** INPUTS: none 193** 194** INPUTS/OUTPUTS: 195** 196** rpc_addr The RPC Address to be freed in the format of a 197** particular NAF 198** 199** OUTPUTS: 200** 201** status A value indicating the return status of the routine 202** 203** Any of the values returned by the NAF addr_free routine 204** 205** IMPLICIT INPUTS: none 206** 207** IMPLICIT OUTPUTS: none 208** 209** FUNCTION VALUE: void 210** 211** SIDE EFFECTS: none 212** 213**-- 214**/ 215 216PRIVATE void rpc__naf_addr_free 217( 218 rpc_addr_p_t *rpc_addr, 219 unsigned32 *status 220) 221{ 222 RPC_LOG_NAF_ADDR_FREE_NTR; 223 224 /* 225 * dispatch to the appropriate NAF service 226 */ 227 (*rpc_g_naf_id[(*rpc_addr)->sa.family].epv->naf_addr_free) 228 (rpc_addr, status); 229 230 RPC_LOG_NAF_ADDR_FREE_XIT; 231} 232 233/* 234**++ 235** 236** ROUTINE NAME: rpc__naf_addr_vector_free 237** 238** SCOPE: PRIVATE - declared in com.h 239** 240** DESCRIPTION: 241** 242** Dispatch to a Network Address Family Service to free a vector of 243** RPC Addresses. Each address and the vector itself are freed. 244** 245** Note that we ignore NULL entries in the vector. This is to make 246** it easy for recipients of a vector to "steal" the pointers to RPC 247** Addresses and put them in some other data structure. After the 248** stealing, they null out the vector entry. 249** 250** INPUTS: none 251** 252** INPUTS/OUTPUTS: 253** 254** rpc_addr_vec The vector of RPC Addresses to be freed 255** 256** OUTPUTS: 257** 258** status A value indicating the return status of the routine 259** 260** IMPLICIT INPUTS: none 261** 262** IMPLICIT OUTPUTS: none 263** 264** FUNCTION VALUE: void 265** 266** SIDE EFFECTS: none 267** 268**-- 269**/ 270 271PRIVATE void rpc__naf_addr_vector_free 272( 273 rpc_addr_vector_p_t *rpc_addr_vec, 274 unsigned32 *status 275) 276{ 277 unsigned16 i; 278 279 /* 280 * In case the vector is empty. 281 */ 282 *status = rpc_s_ok; 283 284 for (i = 0; i < (*rpc_addr_vec)->len; i++) 285 { 286 if ((*rpc_addr_vec)->addrs[i] != NULL) 287 { 288 (*rpc_g_naf_id[(*rpc_addr_vec)->addrs[i]->sa.family].epv->naf_addr_free) 289 (&(*rpc_addr_vec)->addrs[i], status); 290 } 291 } 292 293 RPC_MEM_FREE (*rpc_addr_vec, RPC_C_MEM_RPC_ADDR_VEC); 294} 295 296 297/* 298**++ 299** 300** ROUTINE NAME: rpc__naf_addr_copy 301** 302** SCOPE: PRIVATE - declared in com.h 303** 304** DESCRIPTION: 305** 306** Dispatch to a Network Address Family Service to copy an RPC Address. 307** 308** INPUTS: 309** 310** src_rpc_addr The RPC Address to be copied in the format of a 311** particular NAF 312** 313** INPUTS/OUTPUTS: none 314** 315** OUTPUTS: 316** 317** dst_rpc_addr The RPC Address to be created in the format of a 318** particular NAF 319** 320** status A value indicating the return status of the routine 321** 322** Any of the values returned by the NAF addr_copy routine 323** 324** IMPLICIT INPUTS: none 325** 326** IMPLICIT OUTPUTS: none 327** 328** FUNCTION VALUE: void 329** 330** SIDE EFFECTS: none 331** 332**-- 333**/ 334 335PRIVATE void rpc__naf_addr_copy 336( 337 rpc_addr_p_t src_rpc_addr, 338 rpc_addr_p_t *dst_rpc_addr, 339 unsigned32 *status 340) 341{ 342 RPC_LOG_NAF_ADDR_COPY_NTR; 343 344 /* 345 * dispatch to the appropriate NAF service 346 */ 347 (*rpc_g_naf_id[src_rpc_addr->sa.family].epv->naf_addr_copy) 348 (src_rpc_addr, dst_rpc_addr, status); 349 350 RPC_LOG_NAF_ADDR_COPY_XIT; 351} 352 353/* 354**++ 355** 356** ROUTINE NAME: rpc__naf_addr_overcopy 357** 358** SCOPE: PRIVATE - declared in com.h 359** 360** DESCRIPTION: 361** 362** Like rpc__naf_addr_copy, except uses storage from an existing target 363** address, if there is one (thus saving the malloc). 364** 365** INPUTS: 366** 367** src_rpc_addr The RPC Address to be copied in the format of a 368** particular NAF 369** 370** INPUTS/OUTPUTS: none 371** 372** OUTPUTS: 373** 374** dst_rpc_addr The RPC Address to be created in the format of a 375** particular NAF 376** 377** status A value indicating the return status of the routine 378** 379** Any of the values returned by the NAF addr_copy routine 380** 381** IMPLICIT INPUTS: none 382** 383** IMPLICIT OUTPUTS: none 384** 385** FUNCTION VALUE: void 386** 387** SIDE EFFECTS: none 388** 389**-- 390**/ 391 392PRIVATE void rpc__naf_addr_overcopy 393( 394 rpc_addr_p_t src_rpc_addr, 395 rpc_addr_p_t *dst_rpc_addr, 396 unsigned32 *status 397) 398{ 399 /* 400 * If there is no existing destinition address yet, or if it's not big 401 * enough to receive the source address, call the NAF copy. (Free the 402 * existing one first in the latter case.) Otherwise, just overwrite 403 * the existing destination with the source address. 404 */ 405 if (*dst_rpc_addr == NULL || (*dst_rpc_addr)->len < src_rpc_addr->len) 406 { 407 if (*dst_rpc_addr != NULL) 408 (*rpc_g_naf_id[(*dst_rpc_addr)->sa.family].epv->naf_addr_free) 409 (dst_rpc_addr, status); 410 (*rpc_g_naf_id[src_rpc_addr->sa.family].epv->naf_addr_copy) 411 (src_rpc_addr, dst_rpc_addr, status); 412 } 413 else 414 { 415 assert((*dst_rpc_addr)->len >= sizeof((*dst_rpc_addr)->sa)); 416 **dst_rpc_addr = *src_rpc_addr; 417 memmove( &(*dst_rpc_addr)->sa, &src_rpc_addr->sa, src_rpc_addr->len); 418 *status = rpc_s_ok; 419 } 420} 421 422/* 423**++ 424** 425** ROUTINE NAME: rpc__naf_addr_set_endpoint 426** 427** SCOPE: PRIVATE - declared in com.h 428** 429** DESCRIPTION: 430** 431** Dispatch to a Network Address Family Service to set the endpoint in 432** an RPC Address. 433** 434** INPUTS: 435** 436** endpoint The string containing the endpoint to be placed 437** in the RPC Address 438** 439** INPUTS/OUTPUTS: 440** 441** rpc_addr The RPC Address in which to set the endpoint in the 442** format of a particular NAF 443** 444** OUTPUTS: 445** 446** status A value indicating the return status of the routine 447** 448** Any of the values returned by the NAF addr_set_endpoint routine 449** 450** IMPLICIT INPUTS: none 451** 452** IMPLICIT OUTPUTS: none 453** 454** FUNCTION VALUE: void 455** 456** SIDE EFFECTS: none 457** 458**-- 459**/ 460 461PRIVATE void rpc__naf_addr_set_endpoint 462( 463 unsigned_char_p_t endpoint, 464 rpc_addr_p_t *rpc_addr, 465 unsigned32 *status 466) 467{ 468 /* 469 * dispatch to the appropriate NAF service 470 */ 471 (*rpc_g_naf_id[(*rpc_addr)->sa.family].epv->naf_addr_set_endpoint) 472 (endpoint, rpc_addr, status); 473} 474 475/* 476**++ 477** 478** ROUTINE NAME: rpc__naf_addr_inq_endpoint 479** 480** SCOPE: PRIVATE - declared in com.h 481** 482** DESCRIPTION: 483** 484** Dispatch to a Network Address Family Service to inquire the endpoint 485** in an RPC Address. 486** 487** INPUTS: 488** 489** rpc_addr The RPC Address from which to obtain the endpoint 490** in the format of a particular NAF 491** 492** INPUTS/OUTPUTS: none 493** 494** OUTPUTS: 495** 496** endpoint The string containing the endpoint to be obtained 497** from the RPC Address 498** 499** status A value indicating the return status of the routine 500** 501** Any of the values returned by the NAF addr_inq_endpoint routine 502** 503** IMPLICIT INPUTS: none 504** 505** IMPLICIT OUTPUTS: none 506** 507** FUNCTION VALUE: void 508** 509** SIDE EFFECTS: none 510** 511**-- 512**/ 513 514PRIVATE void rpc__naf_addr_inq_endpoint 515( 516 rpc_addr_p_t rpc_addr, 517 unsigned_char_t **endpoint, 518 unsigned32 *status 519) 520{ 521 /* 522 * dispatch to the appropriate NAF service 523 */ 524 (*rpc_g_naf_id[rpc_addr->sa.family].epv->naf_addr_inq_endpoint) 525 (rpc_addr, endpoint, status); 526} 527 528/* 529**++ 530** 531** ROUTINE NAME: rpc__naf_addr_set_netaddr 532** 533** SCOPE: PRIVATE - declared in com.h 534** 535** DESCRIPTION: 536** 537** Dispatch to a Network Address Family Service to set the network address 538** in an RPC Address. 539** 540** INPUTS: 541** 542** netaddr The string containing the network address to be 543** placed in the RPC Address 544** 545** INPUTS/OUTPUTS: 546** 547** rpc_addr The RPC Address in which to set the network address 548** in the format of a particular NAF 549** 550** OUTPUTS: 551** 552** status A value indicating the return status of the routine 553** 554** Any of the values returned by the NAF addr_set_netaddr routine 555** 556** IMPLICIT INPUTS: none 557** 558** IMPLICIT OUTPUTS: none 559** 560** FUNCTION VALUE: void 561** 562** SIDE EFFECTS: none 563** 564**-- 565**/ 566 567PRIVATE void rpc__naf_addr_set_netaddr 568( 569 unsigned_char_p_t netaddr, 570 rpc_addr_p_t *rpc_addr, 571 unsigned32 *status 572) 573{ 574 /* 575 * dispatch to the appropriate NAF service 576 */ 577 (*rpc_g_naf_id[(*rpc_addr)->sa.family].epv->naf_addr_set_netaddr) 578 (netaddr, rpc_addr, status); 579} 580 581/* 582**++ 583** 584** ROUTINE NAME: rpc__naf_addr_inq_netaddr 585** 586** SCOPE: PRIVATE - declared in com.h 587** 588** DESCRIPTION: 589** 590** Dispatch to a Network Address Family Service to obtain the network 591** address from an RPC Address. 592** 593** INPUTS: 594** 595** rpc_addr The RPC Address from which to obtain the network 596** address in the format of a particular NAF 597** 598** INPUTS/OUTPUTS: none 599** 600** OUTPUTS: 601** 602** netaddr The string containing the network address 603** obtained from the RPC Address 604** 605** status A value indicating the return status of the routine 606** 607** Any of the values returned by the NAF addr_inq_netaddr routine 608** 609** IMPLICIT INPUTS: none 610** 611** IMPLICIT OUTPUTS: none 612** 613** FUNCTION VALUE: void 614** 615** SIDE EFFECTS: none 616** 617**-- 618**/ 619 620PRIVATE void rpc__naf_addr_inq_netaddr 621( 622 rpc_addr_p_t rpc_addr, 623 unsigned_char_t **netaddr, 624 unsigned32 *status 625) 626{ 627 /* 628 * dispatch to the appropriate NAF service 629 */ 630 (*rpc_g_naf_id[rpc_addr->sa.family].epv->naf_addr_inq_netaddr) 631 (rpc_addr, netaddr, status); 632} 633 634/* 635**++ 636** 637** ROUTINE NAME: rpc__naf_addr_set_options 638** 639** SCOPE: PRIVATE - declared in com.h 640** 641** DESCRIPTION: 642** 643** Dispatch to a Network Address Family Service to set the network options 644** in an RPC Address. 645** 646** INPUTS: 647** 648** network_options A network options string 649** 650** INPUTS/OUTPUTS: 651** 652** rpc_addr The RPC Address in which to set the network options 653** in the format of a particular NAF 654** 655** OUTPUTS: 656** 657** status A value indicating the return status of the routine 658** 659** Any of the values returned by the NAF addr_set_options routine 660** 661** IMPLICIT INPUTS: none 662** 663** IMPLICIT OUTPUTS: none 664** 665** FUNCTION VALUE: void 666** 667** SIDE EFFECTS: none 668** 669**-- 670**/ 671 672PRIVATE void rpc__naf_addr_set_options 673( 674 unsigned_char_p_t network_options, 675 rpc_addr_p_t *rpc_addr, 676 unsigned32 *status 677) 678{ 679 /* 680 * dispatch to the appropriate NAF service 681 */ 682 (*rpc_g_naf_id[(*rpc_addr)->sa.family].epv->naf_addr_set_options) 683 (network_options, rpc_addr, status); 684} 685 686/* 687**++ 688** 689** ROUTINE NAME: rpc__naf_addr_inq_options 690** 691** SCOPE: PRIVATE - declared in com.h 692** 693** DESCRIPTION: 694** 695** Dispatch to a Network Address Family Service to obtain the network 696** options from an RPC Address. 697** 698** INPUTS: 699** 700** rpc_addr The RPC Address from which to obtain the network 701** options in the format of a particular NAF 702** 703** INPUTS/OUTPUTS: none 704** 705** OUTPUTS: 706** 707** network_options A network options string 708** 709** status A value indicating the return status of the routine 710** 711** Any of the values returned by the NAF addr_inq_options routine 712** 713** IMPLICIT INPUTS: none 714** 715** IMPLICIT OUTPUTS: none 716** 717** FUNCTION VALUE: void 718** 719** SIDE EFFECTS: none 720** 721**-- 722**/ 723 724PRIVATE void rpc__naf_addr_inq_options 725( 726 rpc_addr_p_t rpc_addr, 727 unsigned_char_t **network_options, 728 unsigned32 *status 729) 730{ 731 /* 732 * dispatch to the appropriate NAF service 733 */ 734 (*rpc_g_naf_id[rpc_addr->sa.family].epv->naf_addr_inq_options) 735 (rpc_addr, network_options, status); 736} 737 738/* 739**++ 740** 741** ROUTINE NAME: rpc__naf_desc_inq_addr 742** 743** SCOPE: PRIVATE - declared in com.h 744** 745** DESCRIPTION: 746** 747** Dispatch to a Network Address Family Service to return a vector 748** of RPC Addresses that reflect all the local network addresses 749** the supplied socket descriptor will listen on. The endpoints 750** in each of the returned RPC Addresses will be the same. If 751** the local host has multiple network addresses, each will be 752** returned in a separate RPC Addresses. 753** 754** INPUTS: 755** 756** protseq_id The RPC Protocol Sequence ID which represents a 757** NAF, NAF Transport Protocol, and NAF Interface Type 758** 759** desc The network descriptor which was returned from the 760** NAF Service 761** 762** INPUTS/OUTPUTS: none 763** 764** OUTPUTS: 765** 766** rpc_addr_vec The returned vector of RPC Addresses 767** 768** status A value indicating the return status of the routine 769** 770** Any of the values returned by the NAF desc_inq_addr routine 771** 772** IMPLICIT INPUTS: none 773** 774** IMPLICIT OUTPUTS: none 775** 776** FUNCTION VALUE: void 777** 778** SIDE EFFECTS: none 779** 780**-- 781**/ 782 783PRIVATE void rpc__naf_desc_inq_addr 784( 785 rpc_protseq_id_t protseq_id, 786 rpc_socket_t desc, 787 rpc_addr_vector_p_t *rpc_addr_vec, 788 unsigned32 *status 789) 790{ 791 rpc_naf_id_t naf_id; 792 793 naf_id = RPC_PROTSEQ_INQ_NAF_ID(protseq_id); 794 795 /* 796 * dispatch to the appropriate NAF service 797 */ 798 (*rpc_g_naf_id[naf_id].epv->naf_desc_inq_addr) 799 (protseq_id, desc, rpc_addr_vec, status); 800} 801 802/* 803**++ 804** 805** ROUTINE NAME: rpc__naf_desc_inq_network 806** 807** SCOPE: PRIVATE - declared in com.h 808** 809** DESCRIPTION: 810** 811** Dispatch to a Network Address Family Service to return the network 812** interface type and network protocol family for a descriptor (socket). 813** 814** INPUTS: 815** 816** desc socket descriptor to query 817** 818** INPUTS/OUTPUTS: none 819** 820** OUTPUTS: 821** 822** naf_id network address family id 823** 824** socket_type network interface type id 825** 826** protocol_id network protocol family id 827** 828** status status returned by called routines 829** 830** IMPLICIT INPUTS: none 831** 832** IMPLICIT OUTPUTS: none 833** 834** FUNCTION VALUE: void 835** 836** SIDE EFFECTS: none 837** 838**-- 839**/ 840 841PRIVATE void rpc__naf_desc_inq_network 842( 843 rpc_socket_t desc, 844 rpc_naf_id_t *naf_id, 845 rpc_network_if_id_t *socket_type, 846 rpc_network_protocol_id_t *protocol_id, 847 unsigned32 *status 848) 849{ 850 CODING_ERROR (status); 851 852 /* 853 * Determine the network address family. 854 */ 855 856 rpc__naf_desc_inq_naf_id (desc, naf_id, status); 857 if (*status != rpc_s_ok) return; 858 859 /* 860 * Vector to the appropriate NAF routine to ascertain the 861 * rest of the network information for this descriptor. 862 * If the naf_id isn't supported, set status to rpc_s_cant_get_if_id. 863 */ 864 if (RPC_NAF_INQ_SUPPORTED(*naf_id)) 865 { 866 (*rpc_g_naf_id[*naf_id].epv->naf_desc_inq_network) 867 (desc, socket_type, protocol_id, status); 868 } 869 else 870 { 871 *status = rpc_s_cant_get_if_id; 872 } 873} 874 875/* 876**++ 877** 878** ROUTINE NAME: rpc__naf_desc_inq_naf_id 879** 880** SCOPE: PRIVATE - declared in com.h 881** 882** DESCRIPTION: 883** 884** Return the network address family of a descriptor (socket). 885** 886** INPUTS: 887** 888** desc socket descriptor to query 889** 890** INPUTS/OUTPUTS: none 891** 892** OUTPUTS: 893** 894** naf_id network address family id 895** 896** status status returned 897** rpc_s_ok 898** rpc_s_no_memory 899** rpc_s_cant_inq_socket 900** 901** IMPLICIT INPUTS: none 902** 903** IMPLICIT OUTPUTS: none 904** 905** FUNCTION VALUE: void 906** 907** SIDE EFFECTS: none 908** 909**-- 910**/ 911 912PRIVATE void rpc__naf_desc_inq_naf_id 913( 914 rpc_socket_t desc, 915 rpc_naf_id_t *naf_id, 916 unsigned32 *status 917) 918{ 919 rpc_addr_p_t addr; 920 unsigned8 buff[sizeof (*addr)]; 921 rpc_socket_error_t serr; 922 923 CODING_ERROR (status); 924 925 /* 926 * Get the endpoint info, ie. fill in the rpc_addr_t. We're 927 * really only interested in the family returned in the socket 928 * address and therefore only provide a socket address buffer 2 929 * bytes long. 930 */ 931 addr = (rpc_addr_p_t) buff; 932#ifdef _SOCKADDR_LEN 933 addr->len = sizeof(addr->sa.family) + sizeof(addr->sa.length); 934#elif ! defined(AIX32) 935 addr->len = sizeof (addr->sa.family); 936#else 937 addr->len = (long) (&(addr->sa.data) - &(addr->sa)); 938#endif /* AIX32 */ 939 940 addr->sa.family = 0; 941 serr = rpc__socket_inq_endpoint (desc, addr); 942 943 if (RPC_SOCKET_IS_ERR (serr)) 944 { 945 *status = rpc_s_cant_inq_socket; 946 goto error; 947 } 948 949 /* On some systems, getsockname fails silently on UNIX 950 domain sockets. This has been seen on HP-UX, Darwin, and AIX. 951 Detect this case and try getpeername instead */ 952 if (addr->sa.family == 0) 953 { 954 serr = rpc__socket_getpeername (desc, addr); 955 956 if (RPC_SOCKET_IS_ERR (serr)) 957 { 958 *status = rpc_s_cant_inq_socket; 959 goto error; 960 } 961 } 962 963 *naf_id = addr->sa.family; 964 965 /* If we *still* got 0 for some reason, force it to AF_UNIX */ 966 if (*naf_id == 0) 967 { 968 *naf_id = AF_UNIX; 969 } 970 971 *status = rpc_s_ok; 972 973error: 974 975 return; 976} 977 978/* 979**++ 980** 981** ROUTINE NAME: rpc__naf_desc_inq_protseq_id 982** 983** SCOPE: PRIVATE - declared in com.h 984** 985** DESCRIPTION: 986** 987** Return the protocol sequence id for a descriptor (socket). 988** (We are passed the network protocol family id.) 989** 990** INPUTS: 991** 992** desc socket descriptor to query 993** 994** protocol_id network protocol family id 995** 996** INPUTS/OUTPUTS: none 997** 998** OUTPUTS: 999** 1000** protseq_id network protocol sequence id 1001** 1002** status status returned 1003** rpc_s_ok 1004** rpc_s_invalid_rpc_protseq 1005** 1006** IMPLICIT INPUTS: none 1007** 1008** IMPLICIT OUTPUTS: none 1009** 1010** FUNCTION VALUE: void 1011** 1012** SIDE EFFECTS: none 1013** 1014**-- 1015**/ 1016 1017PRIVATE void rpc__naf_desc_inq_protseq_id 1018( 1019 rpc_socket_t desc, 1020 rpc_network_protocol_id_t protocol_id, 1021 rpc_protseq_id_t *protseq_id, 1022 unsigned32 *status 1023) 1024{ 1025 rpc_protseq_id_t i; /* index into protseq table */ 1026 rpc_naf_id_t naf_id; /* naf id returned to us */ 1027 rpc_network_if_id_t socket_type; /* network protocol type */ 1028 1029 CODING_ERROR (status); 1030 1031 /* 1032 * Determine the correct network address family. 1033 */ 1034 1035 rpc__naf_desc_inq_naf_id (desc, &naf_id, status); 1036 if (*status != rpc_s_ok) return; 1037 1038 /* 1039 * Determine the rest of the network stuff. 1040 */ 1041 1042 rpc__naf_desc_inq_network 1043 (desc, &naf_id, &socket_type, &protocol_id, status); 1044 if (*status != rpc_s_ok) return; 1045 1046 /* 1047 * Now that we've looked everything up, determine the protocol 1048 * sequence id by scanning the protocol sequence table for a match 1049 * on the network address family id, socket type (rpc protocol id) 1050 * and the network protocol id. 1051 */ 1052 1053 for (i=0; i<RPC_C_PROTSEQ_ID_MAX; i++) 1054 { 1055 if ((naf_id == rpc_g_protseq_id[i].naf_id) && 1056 (protocol_id == rpc_g_protseq_id[i].network_protocol_id) && 1057 (socket_type == rpc_g_protseq_id[i].network_if_id)) 1058 { 1059 break; 1060 } 1061 } 1062 1063 /* 1064 * Check the results of the scan, set status and return protseq_id. 1065 */ 1066 1067 if (i<RPC_C_PROTSEQ_ID_MAX) 1068 { 1069 *protseq_id = rpc_g_protseq_id[i].rpc_protseq_id; 1070 *status = rpc_s_ok; 1071 } 1072 else 1073 { 1074 *protseq_id = rpc_c_invalid_protseq_id; 1075 *status = rpc_s_invalid_rpc_protseq; 1076 } 1077} 1078 1079/* 1080**++ 1081** 1082** ROUTINE NAME: rpc__naf_desc_inq_peer_addr 1083** 1084** SCOPE: PRIVATE - declared in com.h 1085** 1086** DESCRIPTION: 1087** 1088** Return the network address (name) of a connected peer. 1089** 1090** INPUTS: 1091** 1092** desc socket descriptor to query 1093** 1094** protseq_id network protocol sequence id 1095** 1096** INPUTS/OUTPUTS: none 1097** 1098** OUTPUTS: 1099** 1100** addr peer address 1101** 1102** status status returned 1103** rpc_s_ok 1104** 1105** IMPLICIT INPUTS: none 1106** 1107** IMPLICIT OUTPUTS: none 1108** 1109** FUNCTION VALUE: void 1110** 1111** SIDE EFFECTS: none 1112** 1113**-- 1114**/ 1115 1116PRIVATE void rpc__naf_desc_inq_peer_addr 1117( 1118 rpc_socket_t desc, 1119 rpc_protseq_id_t protseq_id, 1120 rpc_addr_p_t *addr, 1121 unsigned32 *status 1122) 1123{ 1124 rpc_naf_id_t naf_id; 1125 1126 naf_id = RPC_PROTSEQ_INQ_NAF_ID(protseq_id); 1127 1128 /* 1129 * dispatch to the appropriate NAF service 1130 */ 1131 (*rpc_g_naf_id[naf_id].epv->naf_desc_inq_peer_addr) 1132 (protseq_id, desc, addr, status); 1133} 1134 1135 1136/* 1137**++ 1138** 1139** ROUTINE NAME: rpc__naf_inq_max_tsdu 1140** 1141** SCOPE: PRIVATE - declared in com.h 1142** 1143** DESCRIPTION: 1144** 1145** Dispatch to a Network Address Family Service to find out the size 1146** of the largest possible transport service data unit (TSDU); i.e., 1147** the size of the largest transport protocol data unit (TPDU) that 1148** can be passed through the transport service interface. ("data units" 1149** excludes all header bytes.) 1150** 1151** INPUTS: 1152** 1153** pseq_id The protocol sequence of interest 1154** 1155** INPUTS/OUTPUTS: 1156** 1157** none 1158** 1159** OUTPUTS: 1160** 1161** max_tsdu A pointer to where the maximum TSDU should be stored. 1162** 1163** status A value indicating the return status of the routine 1164** 1165** IMPLICIT INPUTS: none 1166** 1167** IMPLICIT OUTPUTS: none 1168** 1169** FUNCTION VALUE: void 1170** 1171** SIDE EFFECTS: none 1172** 1173**-- 1174**/ 1175 1176PRIVATE void rpc__naf_inq_max_tsdu 1177( 1178 rpc_protseq_id_t pseq_id, 1179 unsigned32 *max_tsdu, 1180 unsigned32 *status 1181) 1182{ 1183 rpc_naf_id_t naf_id; 1184 rpc_network_if_id_t iftype; 1185 rpc_network_protocol_id_t protocol; 1186 1187 naf_id = RPC_PROTSEQ_INQ_NAF_ID(pseq_id); 1188 iftype = RPC_PROTSEQ_INQ_NET_IF_ID(pseq_id); 1189 protocol = RPC_PROTSEQ_INQ_NET_PROT_ID(pseq_id); 1190 1191 /* 1192 * dispatch to the appropriate NAF service 1193 */ 1194 (*rpc_g_naf_id[naf_id].epv->naf_inq_max_tsdu) 1195 (naf_id, iftype, protocol, max_tsdu, status); 1196} 1197 1198 1199/* 1200**++ 1201** 1202** ROUTINE NAME: rpc__naf_inq_max_pth_unfrg_tpdu 1203** 1204** SCOPE: PRIVATE - declared in com.h 1205** 1206** DESCRIPTION: 1207** 1208** Dispatch to a Network Address Family Service to find out the size 1209** of the largest transport protocol data unit (TPDU) that can be sent 1210** to a particular address without being fragmented along the way. 1211** 1212** INPUTS: 1213** 1214** rpc_addr The address that forms the path of interest 1215** 1216** INPUTS/OUTPUTS: 1217** 1218** none 1219** 1220** OUTPUTS: 1221** 1222** max_tpdu A pointer to where the maximum TPDU should be stored. 1223** 1224** status A value indicating the return status of the routine 1225** 1226** IMPLICIT INPUTS: none 1227** 1228** IMPLICIT OUTPUTS: none 1229** 1230** FUNCTION VALUE: void 1231** 1232** SIDE EFFECTS: none 1233** 1234**-- 1235**/ 1236 1237PRIVATE void rpc__naf_inq_max_pth_unfrg_tpdu 1238( 1239 rpc_addr_p_t rpc_addr, 1240 unsigned32 *max_tpdu, 1241 unsigned32 *status 1242) 1243{ 1244 /* 1245 * dispatch to the appropriate NAF service 1246 */ 1247 (*rpc_g_naf_id[rpc_addr->sa.family].epv->naf_inq_max_pth_unfrg_tpdu) 1248 (rpc_addr, RPC_PROTSEQ_INQ_NET_IF_ID(rpc_addr->rpc_protseq_id), 1249 RPC_PROTSEQ_INQ_NET_PROT_ID(rpc_addr->rpc_protseq_id), max_tpdu, status); 1250} 1251 1252 1253/* 1254**++ 1255** 1256** ROUTINE NAME: rpc__naf_inq_max_loc_unfrg_tpdu 1257** 1258** SCOPE: PRIVATE - declared in com.h 1259** 1260** DESCRIPTION: 1261** 1262** Dispatch to a Network Address Family Service to find out the 1263** size of the largest transport protocol data unit (TPDU) that can 1264** fit (without fragmentation) through the "widest" network interface 1265** on the local host. 1266** 1267** INPUTS: 1268** 1269** pseq_id The protocol sequence of interest 1270** 1271** INPUTS/OUTPUTS: 1272** 1273** none 1274** 1275** OUTPUTS: 1276** 1277** max_tpdu A pointer to where the maximum TPDU should be stored. 1278** 1279** status A value indicating the return status of the routine 1280** 1281** IMPLICIT INPUTS: none 1282** 1283** IMPLICIT OUTPUTS: none 1284** 1285** FUNCTION VALUE: void 1286** 1287** SIDE EFFECTS: none 1288** 1289**-- 1290**/ 1291 1292PRIVATE void rpc__naf_inq_max_loc_unfrg_tpdu 1293( 1294 rpc_protseq_id_t pseq_id, 1295 unsigned32 *max_tpdu, 1296 unsigned32 *status 1297) 1298{ 1299 rpc_naf_id_t naf_id; 1300 rpc_network_if_id_t iftype; 1301 rpc_network_protocol_id_t protocol; 1302 1303 naf_id = RPC_PROTSEQ_INQ_NAF_ID(pseq_id); 1304 iftype = RPC_PROTSEQ_INQ_NET_IF_ID(pseq_id); 1305 protocol = RPC_PROTSEQ_INQ_NET_PROT_ID(pseq_id); 1306 1307 /* 1308 * dispatch to the appropriate NAF service 1309 */ 1310 (*rpc_g_naf_id[naf_id].epv->naf_inq_max_loc_unfrg_tpdu) 1311 (naf_id, iftype, protocol, max_tpdu, status); 1312} 1313 1314 1315/* 1316**++ 1317** 1318** ROUTINE NAME: rpc__naf_get_broadcast 1319** 1320** SCOPE: PRIVATE - declared in com.h 1321** 1322** DESCRIPTION: 1323** 1324** Dispatch to a Network Address Family Service to find out what the maximum 1325** transport protocol data unit size is for that address family. 1326** 1327** INPUTS: 1328** 1329** naf_id The Netork Address Family we're interested in. 1330** prot_seq The protocol sequence 1331** 1332** INPUTS/OUTPUTS: 1333** 1334** none 1335** 1336** OUTPUTS: 1337** 1338** rpc_addrs A pointer to a pointer to a structure in which to put the 1339** list of broadcast addresses. This structure will be allocated 1340** by the address family specific routine 1341** 1342** status A value indicating the return status of the routine 1343** 1344** IMPLICIT INPUTS: none 1345** 1346** IMPLICIT OUTPUTS: none 1347** 1348** FUNCTION VALUE: void 1349** 1350** SIDE EFFECTS: none 1351** 1352**-- 1353**/ 1354 1355PRIVATE void rpc__naf_get_broadcast 1356( 1357 rpc_naf_id_t naf_id, 1358 rpc_protseq_id_t protseq_id, 1359 rpc_addr_vector_p_t *rpc_addrs, 1360 unsigned32 *status 1361) 1362{ 1363 /* 1364 * dispatch to the appropriate NAF service 1365 */ 1366 (*rpc_g_naf_id[naf_id].epv->naf_get_broadcast) 1367 (naf_id, protseq_id, rpc_addrs, status); 1368} 1369 1370 1371/* 1372**++ 1373** 1374** ROUTINE NAME: rpc__naf_addr_compare 1375** 1376** SCOPE: PRIVATE - declared in com.h 1377** 1378** DESCRIPTION: 1379** 1380** Dispatch to a Network Address Family Service to determine if the two 1381** input addresses are equal. 1382** 1383** INPUTS: 1384** 1385** addr1 The first RPC Address to be compared. 1386** 1387** addr2 The second RPC Address to be compared. 1388** 1389** INPUTS/OUTPUTS: 1390** 1391** none 1392** 1393** OUTPUTS: 1394** 1395** status A value indicating the return status of the routine 1396** 1397** IMPLICIT INPUTS: none 1398** 1399** IMPLICIT OUTPUTS: none 1400** 1401** FUNCTION VALUE: rpc_c_true if the addresses are equal 1402** 1403** SIDE EFFECTS: none 1404** 1405**-- 1406**/ 1407 1408PRIVATE boolean rpc__naf_addr_compare 1409( 1410 rpc_addr_p_t addr1, 1411 rpc_addr_p_t addr2, 1412 unsigned32 *status 1413) 1414{ 1415 /* 1416 * Handle NULL pointers here. 1417 */ 1418 if ((addr1 == NULL) || (addr2 == NULL)) 1419 { 1420 *status = rpc_s_ok; 1421 if (addr1 == addr2) return true; 1422 else return false; 1423 } 1424 1425 /* 1426 * dispatch to the appropriate NAF service 1427 */ 1428 if ((*rpc_g_naf_id[addr1->sa.family].epv->naf_addr_compare) 1429 (addr1, addr2, status)) 1430 return true; 1431 else 1432 return false; 1433} 1434 1435 1436/* 1437**++ 1438** 1439** ROUTINE NAME: rpc__naf_set_pkt_nodelay 1440** 1441** SCOPE: PRIVATE - declared in com.h 1442** 1443** DESCRIPTION: 1444** 1445** Dispatch to a Network Address Family Service to set the option 1446** for the transport which will result in the transport "pushing" onto 1447** the network everything it is given as it is given. 1448** input addresses are equal. 1449** 1450** INPUTS: 1451** 1452** desc The network descriptor representing the 1453** transport on which to set the option. 1454** rpc_addr The rpc address of the remote side of the 1455** connection. If NULL it will be determined 1456** from the network descriptor. 1457** 1458** INPUTS/OUTPUTS: 1459** 1460** none 1461** 1462** OUTPUTS: 1463** 1464** status A value indicating the return status of the routine 1465** 1466** IMPLICIT INPUTS: none 1467** 1468** IMPLICIT OUTPUTS: none 1469** 1470** FUNCTION VALUE: none 1471** 1472** SIDE EFFECTS: none 1473** 1474**-- 1475**/ 1476 1477PRIVATE void rpc__naf_set_pkt_nodelay 1478( 1479 rpc_socket_t desc, 1480 rpc_addr_p_t rpc_addr, 1481 unsigned32 *status 1482) 1483{ 1484 rpc_naf_id_t naf_id; 1485 1486 /* 1487 * dispatch to the appropriate NAF service 1488 */ 1489 if (rpc_addr == NULL) 1490 { 1491 rpc__naf_desc_inq_naf_id (desc, &naf_id, status); 1492 if (*status != rpc_s_ok) return; 1493 } 1494 else 1495 { 1496 naf_id = rpc_addr->sa.family; 1497 } 1498 (*rpc_g_naf_id[naf_id].epv->naf_set_pkt_nodelay) 1499 (desc, status); 1500} 1501 1502 1503/* 1504**++ 1505** 1506** ROUTINE NAME: rpc__naf_is_connect_closed 1507** 1508** SCOPE: PRIVATE - declared in com.h 1509** 1510** DESCRIPTION: 1511** 1512** Dispatch to a Network Address Family Service to determine 1513** whether the connection represented by the network descriptor given 1514** is closed. 1515** 1516** INPUTS: 1517** 1518** desc The network descriptor representing the 1519** connection. 1520** 1521** INPUTS/OUTPUTS: 1522** 1523** none 1524** 1525** OUTPUTS: 1526** 1527** status A value indicating the return status of the routine 1528** 1529** IMPLICIT INPUTS: none 1530** 1531** IMPLICIT OUTPUTS: none 1532** 1533** FUNCTION VALUE: 1534** 1535** boolean true if the connection is closed, false otherwise. 1536** 1537** SIDE EFFECTS: none 1538** 1539**-- 1540**/ 1541 1542PRIVATE boolean rpc__naf_is_connect_closed 1543( 1544 rpc_socket_t desc, 1545 unsigned32 *status 1546) 1547{ 1548 rpc_naf_id_t naf_id; 1549 1550 /* 1551 * dispatch to the appropriate NAF service 1552 */ 1553 rpc__naf_desc_inq_naf_id (desc, &naf_id, status); 1554 if (*status != rpc_s_ok) return TRUE; /* ??? */ 1555 return ((*rpc_g_naf_id[naf_id].epv->naf_is_connect_closed) 1556 (desc, status)); 1557} 1558 1559/* 1560**++ 1561** 1562** ROUTINE NAME: rpc__naf_addr_from_sa 1563** 1564** SCOPE: PRIVATE - declared in com.h 1565** 1566** DESCRIPTION: 1567** 1568** Create an RPC addr from a aockaddr. 1569** 1570** INPUTS: 1571** 1572** sockaddr The sockaddr to use in the created RPC addr 1573** 1574** sockaddr_len Length of "sockaddr" 1575** 1576** INPUTS/OUTPUTS: none 1577** 1578** OUTPUTS: 1579** 1580** rpc_addr Returned RPC addr 1581** 1582** status A value indicating the return status of the routine: 1583** rpc_s_ok 1584** 1585** IMPLICIT INPUTS: none 1586** 1587** IMPLICIT OUTPUTS: none 1588** 1589** FUNCTION VALUE: void 1590** 1591** SIDE EFFECTS: none 1592** 1593**-- 1594**/ 1595 1596PRIVATE void rpc__naf_addr_from_sa 1597( 1598 sockaddr_p_t sockaddr, 1599 unsigned32 sockaddr_len, 1600 rpc_addr_p_t *rpc_addr, 1601 unsigned32 *status 1602) 1603{ 1604 /* 1605 * Allocate memory for an RPC address. 1606 */ 1607 RPC_MEM_ALLOC ( 1608 *rpc_addr, 1609 rpc_addr_p_t, 1610 (sockaddr_len + sizeof(rpc_protseq_id_t) + sizeof(unsigned32)), 1611 RPC_C_MEM_RPC_ADDR, 1612 RPC_C_MEM_WAITOK); 1613 1614 /* 1615 * Copy the sockaddr into the RPC addr. 1616 */ 1617 memcpy (&((*rpc_addr)->sa), sockaddr, sockaddr_len); 1618 1619 /* 1620 * Set the sockaddr length into the RPC addr. 1621 */ 1622 (*rpc_addr)->len = sockaddr_len; 1623 1624 *status = rpc_s_ok; 1625 return; 1626} 1627/* 1628**++ 1629** 1630** ROUTINE NAME: rpc__naf_tower_flrs_from_addr 1631** 1632** SCOPE: PRIVATE - declared in com.h 1633** 1634** DESCRIPTION: 1635** 1636** Dispatch to a Network Address Family Service to create lower tower 1637** floors from an RPC addr. 1638** 1639** INPUTS: 1640** 1641** rpc_addr RPC addr to convert to lower tower floors. 1642** 1643** INPUTS/OUTPUTS: none 1644** 1645** OUTPUTS: 1646** 1647** lower_flrs The returned lower tower floors. 1648** 1649** status A value indicating the return status of the routine: 1650** rpc_s_ok 1651** 1652** IMPLICIT INPUTS: none 1653** 1654** IMPLICIT OUTPUTS: none 1655** 1656** FUNCTION VALUE: void 1657** 1658** SIDE EFFECTS: none 1659** 1660**-- 1661**/ 1662 1663PRIVATE void rpc__naf_tower_flrs_from_addr 1664( 1665 rpc_addr_p_t rpc_addr, 1666 twr_p_t *lower_flrs, 1667 unsigned32 *status 1668) 1669{ 1670 /* 1671 * Dispatch to the appropriate NAF service tower_flrs_from_addr routine 1672 * passing through the args (rpc_addr, lower_flrs, status): 1673 */ 1674 1675 (*rpc_g_naf_id[rpc_addr->sa.family].epv->naf_tower_flrs_from_addr) 1676 (rpc_addr, lower_flrs, status); 1677} 1678 1679/* 1680**++ 1681** 1682** ROUTINE NAME: rpc__naf_tower_flrs_to_addr 1683** 1684** SCOPE: PRIVATE - declared in com.h 1685** 1686** DESCRIPTION: 1687** 1688** Dispatch to a Network Address Family Service to create an RPC addr 1689** from a protocol tower. 1690** 1691** INPUTS: 1692** 1693** tower_octet_string 1694** Protocol tower octet string whose floors are used to 1695** construct an RPC addr 1696** 1697** INPUTS/OUTPUTS: none 1698** 1699** OUTPUTS: 1700** 1701** rpc_addr RPC addr constructed from a protocol tower. 1702** 1703** status A value indicating the return status of the routine: 1704** rpc_s_ok 1705** 1706** IMPLICIT INPUTS: none 1707** 1708** IMPLICIT OUTPUTS: none 1709** 1710** FUNCTION VALUE: void 1711** 1712** SIDE EFFECTS: none 1713** 1714**-- 1715**/ 1716 1717PRIVATE void rpc__naf_tower_flrs_to_addr 1718( 1719 byte_p_t tower_octet_string, 1720 rpc_addr_p_t *rpc_addr, 1721 unsigned32 *status 1722) 1723{ 1724 rpc_protseq_id_t protseq_id; 1725 rpc_naf_id_t naf_id; 1726 unsigned16 flr_count; 1727 rpc_tower_ref_p_t tower_ref; 1728 unsigned32 temp_status; 1729 1730 CODING_ERROR (status); 1731 1732#ifdef RPC_NO_TOWER_SUPPORT 1733 1734 *status = rpc_s_coding_error; 1735 1736#else 1737 1738 /* 1739 * Need a tower_ref_t in order to determine the protocol sequence for 1740 * this tower. 1741 */ 1742 1743 /* 1744 * Get the floor count from the octet string and convert it to local 1745 * endian rep. 1746 */ 1747 memcpy (&flr_count, tower_octet_string, RPC_C_TOWER_FLR_COUNT_SIZE); 1748 1749 if (NDR_LOCAL_INT_REP != ndr_c_int_little_endian) 1750 { 1751 SWAB_INPLACE_16 ((flr_count)); 1752 } 1753 1754 /* 1755 * Allocate a tower_ref_t, with flr_count floors and 1756 * initialize the tower ref with the tower_octet_string. We are in 1757 * the import path here, we must have a complete tower. So start at 1758 * floor 1. 1759 * beginning at floor 1. 1760 */ 1761 rpc__tower_ref_alloc (tower_octet_string, (unsigned32) flr_count, 1, 1762 &tower_ref, status); 1763 1764 if (*status != rpc_s_ok) 1765 { 1766 return; 1767 } 1768 1769 /* 1770 * Get the protocol sequence id for this protocol tower. 1771 */ 1772 rpc__tower_ref_inq_protseq_id (tower_ref, &protseq_id, status); 1773 1774 if (*status != rpc_s_ok) 1775 { 1776 rpc__tower_ref_free (&tower_ref, &temp_status); 1777 return; 1778 } 1779 1780 /* 1781 * Done with the tower ref 1782 */ 1783 rpc__tower_ref_free (&tower_ref, status); 1784 1785 if (*status != rpc_s_ok) 1786 { 1787 return; 1788 } 1789 1790 if (! RPC_PROTSEQ_INQ_SUPPORTED(protseq_id)) 1791 { 1792 *status = rpc_s_protseq_not_supported; 1793 return; 1794 } 1795 1796 /* 1797 * Get the NAF ID from the protocol sequence. 1798 */ 1799 naf_id = RPC_PROTSEQ_INQ_NAF_ID (protseq_id); 1800 1801 /* Dispatch to the appropriate NAF service tower_flrs_to_addr routine 1802 * passing through the args (tower, rpc_addr, status): 1803 */ 1804 (*rpc_g_naf_id[naf_id].epv->naf_tower_flrs_to_addr) 1805 (tower_octet_string, rpc_addr, status); 1806 1807 if (*status != rpc_s_ok) 1808 { 1809 return; 1810 } 1811 1812 /* 1813 * Set the protocol sequence id into the RPC addr. 1814 */ 1815 (*rpc_addr)->rpc_protseq_id = protseq_id; 1816 1817#endif 1818 1819 return; 1820} 1821 1822 1823/* 1824**++ 1825** 1826** ROUTINE NAME: rpc__naf_set_port_restriction 1827** 1828** SCOPE: PRIVATE - declared in com.h 1829** 1830** DESCRIPTION: 1831** 1832** Dispatch to a Network Address Family Service to set a protocol 1833** sequence's port restriction structure. 1834** 1835** 1836** INPUTS: 1837** 1838** protseq_id 1839** The protocol sequence id to set port restriction 1840** on. 1841** n_elements 1842** The number of port ranges passed in. 1843** 1844** first_port_name_list 1845** An array of pointers to strings containing the 1846** lower bound port names. 1847** 1848** last_port_name_list 1849** An array of pointers to strings containing the 1850** upper bound port names. 1851** 1852** INPUTS/OUTPUTS: none 1853** 1854** OUTPUTS: 1855** 1856** status 1857** 1858** IMPLICIT INPUTS: none 1859** 1860** IMPLICIT OUTPUTS: none 1861** 1862** FUNCTION VALUE: void 1863** 1864** SIDE EFFECTS: 1865** 1866**-- 1867**/ 1868 1869PRIVATE void rpc__naf_set_port_restriction 1870( 1871 rpc_protseq_id_t protseq_id, 1872 unsigned32 n_elements, 1873 unsigned_char_p_t *first_port_name_list, 1874 unsigned_char_p_t *last_port_name_list, 1875 unsigned32 *status 1876) 1877{ 1878 1879 rpc_naf_id_t naf_id; 1880 1881 /* 1882 * Dispatch to appropriate NAF service. 1883 */ 1884 1885 naf_id = RPC_PROTSEQ_INQ_NAF_ID (protseq_id); 1886 1887 (*rpc_g_naf_id[naf_id].epv->naf_set_port_restriction) 1888 (protseq_id, 1889 n_elements, 1890 first_port_name_list, 1891 last_port_name_list, 1892 status); 1893} /* rpc__naf_set_port_restriction */ 1894 1895 1896/* 1897**++ 1898** 1899** ROUTINE NAME: rpc__naf_get_next_restricted_port 1900** 1901** SCOPE: PRIVATE - declared in com.h 1902** 1903** DESCRIPTION: 1904** 1905** Provides the next restricted port to try to bind to. 1906** 1907** INPUTS: 1908** 1909** protseq_id 1910** The protocol sequence id of that the caller is 1911** trying to bind to. 1912** 1913** INPUTS/OUTPUTS: none 1914** 1915** OUTPUTS: 1916** 1917** port_name 1918** A pointer to an address-family-specific port name. 1919** 1920** status 1921** 1922** IMPLICIT INPUTS: none 1923** 1924** IMPLICIT OUTPUTS: none 1925** 1926** FUNCTION VALUE: void 1927** 1928** SIDE EFFECTS: none 1929** 1930**-- 1931**/ 1932 1933PRIVATE void rpc__naf_get_next_restricted_port 1934( 1935 rpc_protseq_id_t protseq_id, 1936 unsigned_char_p_t *port_name, 1937 unsigned32 *status 1938) 1939{ 1940 1941 rpc_naf_id_t naf_id; 1942 1943 /* 1944 * Dispatch to appropriate NAF service. 1945 */ 1946 1947 naf_id = RPC_PROTSEQ_INQ_NAF_ID (protseq_id); 1948 1949 (*rpc_g_naf_id[naf_id].epv->naf_get_next_restricted_port) 1950 (protseq_id, port_name, status); 1951 1952} /* rpc__naf_get_next_restricted_port */ 1953 1954 1955/* 1956**++ 1957** 1958** ROUTINE NAME: rpc__naf_inq_max_frag_size 1959** 1960** SCOPE: PRIVATE - declared in com.h 1961** 1962** DESCRIPTION: 1963** 1964** Dispatch to a Network Address Family Service to find out the size 1965** of the largest fragment size that can be sent to a particular 1966** address 1967** 1968** INPUTS: 1969** 1970** rpc_addr The address that forms the path of interest 1971** 1972** INPUTS/OUTPUTS: 1973** 1974** none 1975** 1976** OUTPUTS: 1977** 1978** max_frag_size A pointer to where the maximum fragment size 1979** should be stored. 1980** 1981** status A value indicating the return status of the routine 1982** 1983** IMPLICIT INPUTS: none 1984** 1985** IMPLICIT OUTPUTS: none 1986** 1987** FUNCTION VALUE: void 1988** 1989** SIDE EFFECTS: none 1990** 1991**-- 1992**/ 1993 1994PRIVATE void rpc__naf_inq_max_frag_size 1995( 1996 rpc_addr_p_t rpc_addr, 1997 unsigned32 *max_frag_size, 1998 unsigned32 *status 1999) 2000{ 2001 /* 2002 * dispatch to the appropriate NAF service 2003 */ 2004 (*rpc_g_naf_id[rpc_addr->sa.family].epv->naf_inq_max_frag_size) 2005 (rpc_addr, max_frag_size, status); 2006} 2007