servinfo.c revision eb1a34638eba7c5add1421327f3eb225a8ea7518
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* IANA and running RPC services. Given a IANA name or RPC program name
* or number, the program uses getservbyname(3SOCKET) and rpcbind(3NSL)
* to obtain port and proto information for the specified service.
*/
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <netconfig.h>
#include <netdb.h>
#include <netdir.h>
#include <inttypes.h>
#include <limits.h>
#include <libintl.h>
#include <locale.h>
#ifndef TEXT_DOMAIN
#define TEXT_DOMAIN "SUNW_OST_OSCMD"
#endif /* TEXT_DOMAIN */
#define TCP "tcp"
#define TCP6 "tcp6"
#define UDP "udp"
#define UDP6 "udp6"
#define DEFAULT 0x1
#define PORT 0x2
#define PROTO 0x4
static void
{
"-s service_name\n"), arg0);
}
static rpcport_t
uaddr2port(char *addr)
{
char *dot, *p;
return (0);
} else {
return (0);
p = dot - 1;
while (*p != '.') {
/*
* If the first dot hasn't been seen, it's a
* malformed universal address.
*/
if (p == addr)
return (0);
p--;
}
}
return (port);
}
static int
{
int prognum = -1;
if (prognum > 0)
else
/*
* If an entry doesn't exist, it could be a running program
* without a registered RPC entry.
*/
if (prognum <= 0) {
gettext("Can't get rpc entry\n"));
return (1);
}
}
if (setnetconfig() == NULL) {
return (1);
}
return (1);
}
== NULL) {
gettext("Failed: rpcb_getmaps failed\n"));
return (1);
}
continue;
if (sproto) {
continue;
} else {
continue;
}
continue;
continue;
} else {
continue;
}
}
/*
* Print the concatenated output if options is PROTO or PORT.
*/
return (0);
}
int
{
(void) textdomain(TEXT_DOMAIN);
optind = 1;
opterr = 1;
switch (c) {
case 's':
break;
case 't':
break;
case 'u':
break;
case '6':
v6_flag = 1;
break;
case 'P':
break;
case 'p':
break;
case 'R':
isrpc = 1;
break;
default:
return (1);
}
}
return (1);
}
/*
* Specified service is an RPC service.
*/
if (isrpc) {
}
}
"Failed to get information for %s\n"), sname);
return (1);
}
else
return (0);
}