示例#1
0
static void print_masq(struct masq *ms, int numeric, int ext)
{
    unsigned long minutes, seconds, sec100s;

    printf("%-4s", ms->proto);

    sec100s = ms->expires % 100L;
    seconds = (ms->expires / 100L) % 60;
    minutes = ms->expires / 6000L;

    printf("%3ld:%02ld.%02ld ", minutes, seconds, sec100s);

    if (ext > 1) {
	if (has_pdelta)
	    printf("%10lu %5hd %5hd ", ms->initseq,
		   ms->delta, ms->pdelta);
	else
	    printf("%10lu %5hd     - ", ms->initseq,
		   ms->delta);
    }
    printf("%-20s ", ap->sprint((struct sockaddr *) &(ms->src), numeric));
    printf("%-20s ", ap->sprint((struct sockaddr *) &(ms->dst), numeric));

    printf("%s -> ", get_sname(ms->sport, ms->proto, numeric));
    printf("%s", get_sname(ms->dport, ms->proto, numeric));
    printf(" (%s)\n", get_sname(ms->mport, ms->proto, numeric));
}
示例#2
0
/*
 * Open file descriptor for current disk (cur_file)
 *	with "p0" path or cur_disk->disk_path
 */
void
open_cur_file(int mode)
{
	char	*dkpath;
	char	pbuf[MAXPATHLEN];

	switch (mode) {
	    case FD_USE_P0_PATH:
		(void) get_pname(&pbuf[0]);
		dkpath = pbuf;
		break;
	    case FD_USE_CUR_DISK_PATH:
		if (cur_disk->fdisk_part.systid == SUNIXOS ||
		    cur_disk->fdisk_part.systid == SUNIXOS2) {
			(void) get_sname(&pbuf[0]);
			dkpath = pbuf;
		} else {
			dkpath = cur_disk->disk_path;
		}
		break;
	    default:
		err_print("Error: Invalid mode option for opening cur_file\n");
		fullabort();
	}

	/* Close previous cur_file */
	(void) close(cur_file);
	/* Open cur_file with the required path dkpath */
	if ((cur_file = open_disk(dkpath, O_RDWR | O_NDELAY)) < 0) {
		err_print(
		    "Error: can't open selected disk '%s'.\n", dkpath);
		fullabort();
	}
}
示例#3
0
static void snprint_ip_port(char *ip_port, int size, struct sockaddr *addr, int port, const char *proto, int numeric)
{
	const char *port_name;

#if ENABLE_FEATURE_IPV6
	if (addr->sa_family == AF_INET6) {
		INET6_rresolve(ip_port, size, (struct sockaddr_in6 *)addr,
			(numeric & NETSTAT_NUMERIC) ? 0x0fff : 0);
	} else
#endif
	{
		INET_rresolve(ip_port, size, (struct sockaddr_in *)addr,
			0x4000 | ((numeric & NETSTAT_NUMERIC) ? 0x0fff : 0),
			0xffffffff);
	}
	port_name = get_sname(htons(port), proto, numeric);
	if ((strlen(ip_port) + strlen(port_name)) > 22)
		ip_port[22 - strlen(port_name)] = '\0';
	ip_port += strlen(ip_port);
	strcat(ip_port, ":");
	strcat(ip_port, port_name);
}