|
Packit Service |
4f68e0 |
/*
|
|
Packit Service |
4f68e0 |
* Copyright (c) 2009, Sun Microsystems, Inc.
|
|
Packit Service |
4f68e0 |
* All rights reserved.
|
|
Packit Service |
4f68e0 |
*
|
|
Packit Service |
4f68e0 |
* Redistribution and use in source and binary forms, with or without
|
|
Packit Service |
4f68e0 |
* modification, are permitted provided that the following conditions are met:
|
|
Packit Service |
4f68e0 |
* - Redistributions of source code must retain the above copyright notice,
|
|
Packit Service |
4f68e0 |
* this list of conditions and the following disclaimer.
|
|
Packit Service |
4f68e0 |
* - Redistributions in binary form must reproduce the above copyright notice,
|
|
Packit Service |
4f68e0 |
* this list of conditions and the following disclaimer in the documentation
|
|
Packit Service |
4f68e0 |
* and/or other materials provided with the distribution.
|
|
Packit Service |
4f68e0 |
* - Neither the name of Sun Microsystems, Inc. nor the names of its
|
|
Packit Service |
4f68e0 |
* contributors may be used to endorse or promote products derived
|
|
Packit Service |
4f68e0 |
* from this software without specific prior written permission.
|
|
Packit Service |
4f68e0 |
*
|
|
Packit Service |
4f68e0 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
Packit Service |
4f68e0 |
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
Packit Service |
4f68e0 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
Packit Service |
4f68e0 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
Packit Service |
4f68e0 |
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
Packit Service |
4f68e0 |
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
Packit Service |
4f68e0 |
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
Packit Service |
4f68e0 |
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
Packit Service |
4f68e0 |
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
Packit Service |
4f68e0 |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
Packit Service |
4f68e0 |
* POSSIBILITY OF SUCH DAMAGE.
|
|
Packit Service |
4f68e0 |
*/
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
/*
|
|
Packit Service |
4f68e0 |
* pmap_getmap.c
|
|
Packit Service |
4f68e0 |
* Client interface to pmap rpc service.
|
|
Packit Service |
4f68e0 |
* contains pmap_getmaps, which is only tcp service involved
|
|
Packit Service |
4f68e0 |
*
|
|
Packit Service |
4f68e0 |
* Copyright (C) 1984, Sun Microsystems, Inc.
|
|
Packit Service |
4f68e0 |
*/
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
#include <sys/types.h>
|
|
Packit Service |
4f68e0 |
#include <sys/socket.h>
|
|
Packit Service |
4f68e0 |
#include <sys/ioctl.h>
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
#include <arpa/inet.h>
|
|
Packit Service |
4f68e0 |
#include <net/if.h>
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
#include <assert.h>
|
|
Packit Service |
4f68e0 |
#include <errno.h>
|
|
Packit Service |
4f68e0 |
#include <netdb.h>
|
|
Packit Service |
4f68e0 |
#include <stdio.h>
|
|
Packit Service |
4f68e0 |
#include <unistd.h>
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
#include <rpc/rpc.h>
|
|
Packit Service |
4f68e0 |
#include <rpc/pmap_prot.h>
|
|
Packit Service |
4f68e0 |
#include <rpc/pmap_clnt.h>
|
|
Packit Service |
4f68e0 |
//#include <clnt_soc.h>
|
|
Packit Service |
4f68e0 |
#define NAMELEN 255
|
|
Packit Service |
4f68e0 |
#define MAX_BROADCAST_SIZE 1400
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
/*
|
|
Packit Service |
4f68e0 |
* Get a copy of the current port maps.
|
|
Packit Service |
4f68e0 |
* Calls the pmap service remotely to do get the maps.
|
|
Packit Service |
4f68e0 |
*/
|
|
Packit Service |
4f68e0 |
struct pmaplist *
|
|
Packit Service |
4f68e0 |
pmap_getmaps(address)
|
|
Packit Service |
4f68e0 |
struct sockaddr_in *address;
|
|
Packit Service |
4f68e0 |
{
|
|
Packit Service |
4f68e0 |
struct pmaplist *head = NULL;
|
|
Packit Service |
4f68e0 |
int sock = -1;
|
|
Packit Service |
4f68e0 |
struct timeval minutetimeout;
|
|
Packit Service |
4f68e0 |
CLIENT *client;
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
assert(address != NULL);
|
|
Packit Service |
4f68e0 |
|
|
Packit Service |
4f68e0 |
minutetimeout.tv_sec = 60;
|
|
Packit Service |
4f68e0 |
minutetimeout.tv_usec = 0;
|
|
Packit Service |
4f68e0 |
address->sin_port = htons(PMAPPORT);
|
|
Packit Service |
4f68e0 |
client = clnttcp_create(address, PMAPPROG,
|
|
Packit Service |
4f68e0 |
PMAPVERS, &sock, 50, 500);
|
|
Packit Service |
4f68e0 |
if (client != NULL) {
|
|
Packit Service |
4f68e0 |
if (CLNT_CALL(client, (rpcproc_t)PMAPPROC_DUMP,
|
|
Packit Service |
4f68e0 |
(xdrproc_t)xdr_void, NULL,
|
|
Packit Service |
4f68e0 |
(xdrproc_t)xdr_pmaplist, &head, minutetimeout) !=
|
|
Packit Service |
4f68e0 |
RPC_SUCCESS) {
|
|
Packit Service |
4f68e0 |
clnt_perror(client, "pmap_getmaps rpc problem");
|
|
Packit Service |
4f68e0 |
}
|
|
Packit Service |
4f68e0 |
CLNT_DESTROY(client);
|
|
Packit Service |
4f68e0 |
}
|
|
Packit Service |
4f68e0 |
address->sin_port = 0;
|
|
Packit Service |
4f68e0 |
return (head);
|
|
Packit Service |
4f68e0 |
}
|