1996-02-27 02:05:14 +03:00
|
|
|
/* $NetBSD: bootparam.c,v 1.7 1996/02/26 23:05:14 gwr Exp $ */
|
1995-06-27 19:32:40 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1995 Gordon W. Ross
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
* 4. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by Gordon W. Ross
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* RPC/bootparams
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
|
|
|
|
#include <net/if.h>
|
|
|
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/in_systm.h>
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
1996-02-27 02:05:14 +03:00
|
|
|
#include "rpcv2.h"
|
|
|
|
|
1995-06-27 19:32:40 +04:00
|
|
|
#include "stand.h"
|
|
|
|
#include "net.h"
|
|
|
|
#include "netif.h"
|
|
|
|
#include "rpc.h"
|
|
|
|
#include "bootparam.h"
|
|
|
|
|
1995-09-19 01:19:18 +04:00
|
|
|
struct in_addr bp_server_addr; /* net order */
|
|
|
|
n_short bp_server_port; /* net order */
|
1995-06-27 19:32:40 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* RPC definitions for bootparamd
|
|
|
|
*/
|
|
|
|
#define BOOTPARAM_PROG 100026
|
|
|
|
#define BOOTPARAM_VERS 1
|
|
|
|
#define BOOTPARAM_WHOAMI 1
|
|
|
|
#define BOOTPARAM_GETFILE 2
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Inet address in RPC messages
|
|
|
|
* (Note, really four ints, NOT chars. Blech.)
|
|
|
|
*/
|
|
|
|
struct xdr_inaddr {
|
|
|
|
u_int32_t atype;
|
|
|
|
int32_t addr[4];
|
|
|
|
};
|
|
|
|
|
1995-09-23 07:36:06 +04:00
|
|
|
int xdr_inaddr_encode __P((char **p, struct in_addr ia));
|
|
|
|
int xdr_inaddr_decode __P((char **p, struct in_addr *ia));
|
1995-06-27 19:32:40 +04:00
|
|
|
|
1995-09-23 07:36:06 +04:00
|
|
|
int xdr_string_encode __P((char **p, char *str, int len));
|
|
|
|
int xdr_string_decode __P((char **p, char *str, int *len_p));
|
1995-06-27 19:32:40 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* RPC: bootparam/whoami
|
|
|
|
* Given client IP address, get:
|
|
|
|
* client name (hostname)
|
|
|
|
* domain name (domainname)
|
|
|
|
* gateway address
|
|
|
|
*
|
|
|
|
* The hostname and domainname are set here for convenience.
|
|
|
|
*
|
|
|
|
* Note - bpsin is initialized to the broadcast address,
|
|
|
|
* and will be replaced with the bootparam server address
|
|
|
|
* after this call is complete. Have to use PMAP_PROC_CALL
|
|
|
|
* to make sure we get responses only from a servers that
|
|
|
|
* know about us (don't want to broadcast a getport call).
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
bp_whoami(sockfd)
|
|
|
|
int sockfd;
|
|
|
|
{
|
|
|
|
/* RPC structures for PMAPPROC_CALLIT */
|
|
|
|
struct args {
|
|
|
|
u_int32_t prog;
|
|
|
|
u_int32_t vers;
|
|
|
|
u_int32_t proc;
|
|
|
|
u_int32_t arglen;
|
|
|
|
struct xdr_inaddr xina;
|
|
|
|
} *args;
|
|
|
|
struct repl {
|
1995-12-08 07:10:28 +03:00
|
|
|
u_int16_t _pad;
|
|
|
|
u_int16_t port;
|
1995-06-27 19:32:40 +04:00
|
|
|
u_int32_t encap_len;
|
|
|
|
/* encapsulated data here */
|
|
|
|
n_long capsule[64];
|
|
|
|
} *repl;
|
|
|
|
struct {
|
|
|
|
n_long h[RPC_HEADER_WORDS];
|
|
|
|
struct args d;
|
|
|
|
} sdata;
|
|
|
|
struct {
|
|
|
|
n_long h[RPC_HEADER_WORDS];
|
|
|
|
struct repl d;
|
|
|
|
} rdata;
|
1995-09-23 07:36:06 +04:00
|
|
|
char *send_tail, *recv_head;
|
1995-06-27 19:32:40 +04:00
|
|
|
struct iodesc *d;
|
|
|
|
int len, x;
|
|
|
|
|
|
|
|
#ifdef RPC_DEBUG
|
1995-09-19 01:19:18 +04:00
|
|
|
printf("bp_whoami: myip=%s\n", inet_ntoa(myip));
|
1995-06-27 19:32:40 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!(d = socktodesc(sockfd))) {
|
1995-09-23 07:36:06 +04:00
|
|
|
#ifdef RPC_DEBUG
|
1995-06-27 19:32:40 +04:00
|
|
|
printf("bp_whoami: bad socket. %d\n", sockfd);
|
1995-09-23 07:36:06 +04:00
|
|
|
#endif
|
1995-09-19 01:19:18 +04:00
|
|
|
return (-1);
|
1995-06-27 19:32:40 +04:00
|
|
|
}
|
|
|
|
args = &sdata.d;
|
|
|
|
repl = &rdata.d;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Build request args for PMAPPROC_CALLIT.
|
|
|
|
*/
|
|
|
|
args->prog = htonl(BOOTPARAM_PROG);
|
|
|
|
args->vers = htonl(BOOTPARAM_VERS);
|
|
|
|
args->proc = htonl(BOOTPARAM_WHOAMI);
|
|
|
|
args->arglen = htonl(sizeof(struct xdr_inaddr));
|
1995-09-23 07:36:06 +04:00
|
|
|
send_tail = (char*) &args->xina;
|
1995-06-27 19:32:40 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* append encapsulated data (client IP address)
|
|
|
|
*/
|
|
|
|
if (xdr_inaddr_encode(&send_tail, myip))
|
|
|
|
return (-1);
|
|
|
|
|
|
|
|
/* RPC: portmap/callit */
|
|
|
|
d->myport = htons(--rpc_port);
|
1995-09-19 01:19:18 +04:00
|
|
|
d->destip.s_addr = INADDR_BROADCAST; /* XXX: subnet bcast? */
|
1995-06-27 19:32:40 +04:00
|
|
|
/* rpc_call will set d->destport */
|
|
|
|
|
|
|
|
len = rpc_call(d, PMAPPROG, PMAPVERS, PMAPPROC_CALLIT,
|
1995-09-23 07:36:06 +04:00
|
|
|
args, send_tail - (char*)args,
|
1995-06-27 19:32:40 +04:00
|
|
|
repl, sizeof(*repl));
|
|
|
|
if (len < 8) {
|
|
|
|
printf("bootparamd: 'whoami' call failed\n");
|
1995-09-19 01:19:18 +04:00
|
|
|
return (-1);
|
1995-06-27 19:32:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Save bootparam server address (from IP header). */
|
|
|
|
rpc_fromaddr(repl, &bp_server_addr, &bp_server_port);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note that bp_server_port is now 111 due to the
|
|
|
|
* indirect call (using PMAPPROC_CALLIT), so get the
|
|
|
|
* actual port number from the reply data.
|
|
|
|
*/
|
|
|
|
bp_server_port = repl->port;
|
|
|
|
|
|
|
|
#ifdef RPC_DEBUG
|
|
|
|
printf("bp_whoami: server at %s:%d\n",
|
1995-09-19 01:19:18 +04:00
|
|
|
inet_ntoa(bp_server_addr), ntohs(bp_server_port));
|
1995-06-27 19:32:40 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* We have just done a portmap call, so cache the portnum. */
|
|
|
|
rpc_pmap_putcache(bp_server_addr,
|
|
|
|
BOOTPARAM_PROG,
|
|
|
|
BOOTPARAM_VERS,
|
1995-09-23 07:36:06 +04:00
|
|
|
(int)ntohs(bp_server_port));
|
1995-06-27 19:32:40 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Parse the encapsulated results from bootparam/whoami
|
|
|
|
*/
|
|
|
|
x = ntohl(repl->encap_len);
|
|
|
|
if (len < x) {
|
|
|
|
printf("bp_whoami: short reply, %d < %d\n", len, x);
|
1995-09-19 01:19:18 +04:00
|
|
|
return (-1);
|
1995-06-27 19:32:40 +04:00
|
|
|
}
|
1995-09-23 07:36:06 +04:00
|
|
|
recv_head = (char*) repl->capsule;
|
1995-06-27 19:32:40 +04:00
|
|
|
|
|
|
|
/* client name */
|
|
|
|
hostnamelen = MAXHOSTNAMELEN-1;
|
|
|
|
if (xdr_string_decode(&recv_head, hostname, &hostnamelen)) {
|
|
|
|
#ifdef RPC_DEBUG
|
|
|
|
printf("bp_whoami: bad hostname\n");
|
|
|
|
#endif
|
1995-09-19 01:19:18 +04:00
|
|
|
return (-1);
|
1995-06-27 19:32:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* domain name */
|
|
|
|
domainnamelen = MAXHOSTNAMELEN-1;
|
|
|
|
if (xdr_string_decode(&recv_head, domainname, &domainnamelen)) {
|
|
|
|
#ifdef RPC_DEBUG
|
|
|
|
printf("bp_whoami: bad domainname\n");
|
|
|
|
#endif
|
1995-09-19 01:19:18 +04:00
|
|
|
return (-1);
|
1995-06-27 19:32:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* gateway address */
|
|
|
|
if (xdr_inaddr_decode(&recv_head, &gateip)) {
|
|
|
|
#ifdef RPC_DEBUG
|
|
|
|
printf("bp_whoami: bad gateway\n");
|
|
|
|
#endif
|
1995-09-19 01:19:18 +04:00
|
|
|
return (-1);
|
1995-06-27 19:32:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* success */
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* RPC: bootparam/getfile
|
|
|
|
* Given client name and file "key", get:
|
|
|
|
* server name
|
|
|
|
* server IP address
|
|
|
|
* server pathname
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
bp_getfile(sockfd, key, serv_addr, pathname)
|
|
|
|
int sockfd;
|
|
|
|
char *key;
|
|
|
|
char *pathname;
|
1995-09-19 01:19:18 +04:00
|
|
|
struct in_addr *serv_addr;
|
1995-06-27 19:32:40 +04:00
|
|
|
{
|
|
|
|
struct {
|
|
|
|
n_long h[RPC_HEADER_WORDS];
|
|
|
|
n_long d[64];
|
|
|
|
} sdata;
|
|
|
|
struct {
|
|
|
|
n_long h[RPC_HEADER_WORDS];
|
|
|
|
n_long d[128];
|
|
|
|
} rdata;
|
|
|
|
char serv_name[FNAME_SIZE];
|
1995-09-23 07:36:06 +04:00
|
|
|
char *send_tail, *recv_head;
|
1995-06-27 19:32:40 +04:00
|
|
|
/* misc... */
|
|
|
|
struct iodesc *d;
|
|
|
|
int sn_len, path_len, rlen;
|
|
|
|
|
|
|
|
if (!(d = socktodesc(sockfd))) {
|
1995-09-23 07:36:06 +04:00
|
|
|
#ifdef RPC_DEBUG
|
1995-06-27 19:32:40 +04:00
|
|
|
printf("bp_getfile: bad socket. %d\n", sockfd);
|
1995-09-23 07:36:06 +04:00
|
|
|
#endif
|
1995-09-19 01:19:18 +04:00
|
|
|
return (-1);
|
1995-06-27 19:32:40 +04:00
|
|
|
}
|
|
|
|
|
1995-09-23 07:36:06 +04:00
|
|
|
send_tail = (char*) sdata.d;
|
|
|
|
recv_head = (char*) rdata.d;
|
1995-06-27 19:32:40 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Build request message.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* client name (hostname) */
|
|
|
|
if (xdr_string_encode(&send_tail, hostname, hostnamelen)) {
|
|
|
|
#ifdef RPC_DEBUG
|
|
|
|
printf("bp_getfile: bad client\n");
|
|
|
|
#endif
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* key name (root or swap) */
|
|
|
|
if (xdr_string_encode(&send_tail, key, strlen(key))) {
|
|
|
|
#ifdef RPC_DEBUG
|
|
|
|
printf("bp_getfile: bad key\n");
|
|
|
|
#endif
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* RPC: bootparam/getfile */
|
|
|
|
d->myport = htons(--rpc_port);
|
|
|
|
d->destip = bp_server_addr;
|
|
|
|
/* rpc_call will set d->destport */
|
|
|
|
|
|
|
|
rlen = rpc_call(d,
|
|
|
|
BOOTPARAM_PROG, BOOTPARAM_VERS, BOOTPARAM_GETFILE,
|
1995-09-23 07:36:06 +04:00
|
|
|
sdata.d, send_tail - (char*)sdata.d,
|
1995-06-27 19:32:40 +04:00
|
|
|
rdata.d, sizeof(rdata.d));
|
|
|
|
if (rlen < 4) {
|
|
|
|
#ifdef RPC_DEBUG
|
|
|
|
printf("bp_getfile: short reply\n");
|
|
|
|
#endif
|
1995-09-19 01:19:18 +04:00
|
|
|
errno = EBADRPC;
|
|
|
|
return (-1);
|
1995-06-27 19:32:40 +04:00
|
|
|
}
|
1995-09-23 07:36:06 +04:00
|
|
|
recv_head = (char*) rdata.d;
|
1995-06-27 19:32:40 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Parse result message.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* server name */
|
|
|
|
sn_len = FNAME_SIZE-1;
|
|
|
|
if (xdr_string_decode(&recv_head, serv_name, &sn_len)) {
|
|
|
|
#ifdef RPC_DEBUG
|
|
|
|
printf("bp_getfile: bad server name\n");
|
|
|
|
#endif
|
1995-09-19 01:19:18 +04:00
|
|
|
return (-1);
|
1995-06-27 19:32:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* server IP address (mountd/NFS) */
|
|
|
|
if (xdr_inaddr_decode(&recv_head, serv_addr)) {
|
|
|
|
#ifdef RPC_DEBUG
|
|
|
|
printf("bp_getfile: bad server addr\n");
|
|
|
|
#endif
|
1995-09-19 01:19:18 +04:00
|
|
|
return (-1);
|
1995-06-27 19:32:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* server pathname */
|
|
|
|
path_len = MAXPATHLEN-1;
|
|
|
|
if (xdr_string_decode(&recv_head, pathname, &path_len)) {
|
|
|
|
#ifdef RPC_DEBUG
|
|
|
|
printf("bp_getfile: bad server path\n");
|
|
|
|
#endif
|
1995-09-19 01:19:18 +04:00
|
|
|
return (-1);
|
1995-06-27 19:32:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* success */
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* eXternal Data Representation routines.
|
|
|
|
* (but with non-standard args...)
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
xdr_string_encode(pkt, str, len)
|
1995-09-23 07:36:06 +04:00
|
|
|
char **pkt;
|
1995-06-27 19:32:40 +04:00
|
|
|
char *str;
|
|
|
|
int len;
|
|
|
|
{
|
|
|
|
u_int32_t *lenp;
|
|
|
|
char *datap;
|
|
|
|
int padlen = (len + 3) & ~3; /* padded length */
|
|
|
|
|
1995-09-23 07:36:06 +04:00
|
|
|
/* The data will be int aligned. */
|
|
|
|
lenp = (u_int32_t*) *pkt;
|
|
|
|
*pkt += sizeof(*lenp);
|
1995-06-27 19:32:40 +04:00
|
|
|
*lenp = htonl(len);
|
|
|
|
|
|
|
|
datap = *pkt;
|
1995-09-23 07:36:06 +04:00
|
|
|
*pkt += padlen;
|
1995-06-27 19:32:40 +04:00
|
|
|
bcopy(str, datap, len);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
xdr_string_decode(pkt, str, len_p)
|
1995-09-23 07:36:06 +04:00
|
|
|
char **pkt;
|
1995-06-27 19:32:40 +04:00
|
|
|
char *str;
|
|
|
|
int *len_p; /* bufsize - 1 */
|
|
|
|
{
|
|
|
|
u_int32_t *lenp;
|
|
|
|
char *datap;
|
|
|
|
int slen; /* string length */
|
|
|
|
int plen; /* padded length */
|
|
|
|
|
1995-09-23 07:36:06 +04:00
|
|
|
/* The data will be int aligned. */
|
|
|
|
lenp = (u_int32_t*) *pkt;
|
|
|
|
*pkt += sizeof(*lenp);
|
1995-06-27 19:32:40 +04:00
|
|
|
slen = ntohl(*lenp);
|
|
|
|
plen = (slen + 3) & ~3;
|
|
|
|
|
|
|
|
if (slen > *len_p)
|
|
|
|
slen = *len_p;
|
|
|
|
datap = *pkt;
|
1995-09-23 07:36:06 +04:00
|
|
|
*pkt += plen;
|
1995-06-27 19:32:40 +04:00
|
|
|
bcopy(datap, str, slen);
|
|
|
|
|
|
|
|
str[slen] = '\0';
|
|
|
|
*len_p = slen;
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
xdr_inaddr_encode(pkt, ia)
|
1995-09-23 07:36:06 +04:00
|
|
|
char **pkt;
|
|
|
|
struct in_addr ia; /* network order */
|
1995-06-27 19:32:40 +04:00
|
|
|
{
|
|
|
|
struct xdr_inaddr *xi;
|
|
|
|
u_char *cp;
|
|
|
|
int32_t *ip;
|
|
|
|
union {
|
1995-09-23 07:36:06 +04:00
|
|
|
n_long l; /* network order */
|
1995-06-27 19:32:40 +04:00
|
|
|
u_char c[4];
|
|
|
|
} uia;
|
|
|
|
|
1995-09-23 07:36:06 +04:00
|
|
|
/* The data will be int aligned. */
|
|
|
|
xi = (struct xdr_inaddr *) *pkt;
|
|
|
|
*pkt += sizeof(*xi);
|
1995-06-27 19:32:40 +04:00
|
|
|
xi->atype = htonl(1);
|
1995-09-19 01:19:18 +04:00
|
|
|
uia.l = ia.s_addr;
|
1995-06-27 19:32:40 +04:00
|
|
|
cp = uia.c;
|
|
|
|
ip = xi->addr;
|
1995-09-23 07:36:06 +04:00
|
|
|
/*
|
|
|
|
* Note: the htonl() calls below DO NOT
|
|
|
|
* imply that uia.l is in host order.
|
|
|
|
* In fact this needs it in net order.
|
|
|
|
*/
|
1995-09-19 01:19:18 +04:00
|
|
|
*ip++ = htonl((unsigned int)*cp++);
|
|
|
|
*ip++ = htonl((unsigned int)*cp++);
|
|
|
|
*ip++ = htonl((unsigned int)*cp++);
|
|
|
|
*ip++ = htonl((unsigned int)*cp++);
|
1995-06-27 19:32:40 +04:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
xdr_inaddr_decode(pkt, ia)
|
1995-09-23 07:36:06 +04:00
|
|
|
char **pkt;
|
|
|
|
struct in_addr *ia; /* network order */
|
1995-06-27 19:32:40 +04:00
|
|
|
{
|
|
|
|
struct xdr_inaddr *xi;
|
|
|
|
u_char *cp;
|
|
|
|
int32_t *ip;
|
|
|
|
union {
|
1995-09-23 07:36:06 +04:00
|
|
|
n_long l; /* network order */
|
1995-06-27 19:32:40 +04:00
|
|
|
u_char c[4];
|
|
|
|
} uia;
|
|
|
|
|
1995-09-23 07:36:06 +04:00
|
|
|
/* The data will be int aligned. */
|
|
|
|
xi = (struct xdr_inaddr *) *pkt;
|
|
|
|
*pkt += sizeof(*xi);
|
1995-06-27 19:32:40 +04:00
|
|
|
if (xi->atype != htonl(1)) {
|
|
|
|
#ifdef RPC_DEBUG
|
|
|
|
printf("xdr_inaddr_decode: bad addrtype=%d\n",
|
|
|
|
ntohl(xi->atype));
|
|
|
|
#endif
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
cp = uia.c;
|
|
|
|
ip = xi->addr;
|
1995-09-23 07:36:06 +04:00
|
|
|
/*
|
|
|
|
* Note: the ntohl() calls below DO NOT
|
|
|
|
* imply that uia.l is in host order.
|
|
|
|
* In fact this needs it in net order.
|
|
|
|
*/
|
1995-09-19 01:19:18 +04:00
|
|
|
*cp++ = ntohl(*ip++);
|
|
|
|
*cp++ = ntohl(*ip++);
|
|
|
|
*cp++ = ntohl(*ip++);
|
|
|
|
*cp++ = ntohl(*ip++);
|
|
|
|
ia->s_addr = uia.l;
|
1995-06-27 19:32:40 +04:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|