/*
* Copyright (c) 1983, 1988, 1993
* The Regents of the University of California. 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. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
*/
/*
* Print a summary of connections related to a Network Systems
* protocol. For XXX, also give state of connection.
* Listening processes (aflag) are suppressed unless the
* -a (all) flag is specified.
*/
/* what == 0 for addr only == 3
* 1 for net
* 2 for host
* 4 for port
* 8 for numeric only
*/
const char *
atalk_print(const struct sockaddr *sa, int what)
{
const struct sockaddr_at *sat = (const struct sockaddr_at *) sa;
static char mybuf[50];
int numeric = (what & 0x08);
thesockaddr.sat_addr.s_net = sat1->sat_addr.s_net &
sat2->sat_addr.s_net;
n = snprintf(buf, sizeof(buf), "%s", atalk_print(sa2, 1 | (what & 8)));
if (n >= (int)sizeof(buf))
n = sizeof(buf) - 1;
else if (n == -1)
n = 0; /* What else can be done ? */
if (sat2->sat_addr.s_net != 0xFFFF) {
thesockaddr.sat_addr.s_net = sat1->sat_addr.s_net |
~sat2->sat_addr.s_net;
l = snprintf(buf + n, sizeof(buf) - n,
"-%s", atalk_print(sa2, 1 | (what & 8)));
if (l >= (int)(sizeof(buf) - n))
l = sizeof(buf) - n - 1;
if (l > 0)
n += l;
}
if (what & 2) {
l = snprintf(buf + n, sizeof(buf) - n, ".%s",
atalk_print(sa, what & (~1)));
if (l >= (int)(sizeof(buf) - n))
l = sizeof(buf) - n - 1;
if (l > 0)
n += l;
}
return buf;
}
void
atalkprotopr(u_long off, const char *name)
{
struct ddpcb ddpcb;
struct socket sockb;
struct ddpcb *next;
struct ddpcb *initial;
int width = 22;
if (off == 0)
return;
if (kread(off, (char *)&initial, sizeof(struct ddpcb *)) < 0)
return;
for (next = initial; next != NULL;) {
u_long ppcb = (u_long)next;
if (prog_sysctlbyname("net.atalk.ddp.stats", ddpstat, &size,
NULL, 0) == -1 && errno != ENOMEM)
return;
} else {
warnx("%s stats not available via KVM.", name);
return;
}
printf("%s:\n", name);
ANY(ddpstat[DDP_STAT_SHORT], "packet", " with short headers ");
ANY(ddpstat[DDP_STAT_LONG], "packet", " with long headers ");
ANY(ddpstat[DDP_STAT_NOSUM], "packet", " with no checksum ");
ANY(ddpstat[DDP_STAT_TOOSHORT], "packet", " too short ");
ANY(ddpstat[DDP_STAT_BADSUM], "packet", " with bad checksum ");
ANY(ddpstat[DDP_STAT_TOOSMALL], "packet", " with not enough data ");
ANY(ddpstat[DDP_STAT_FORWARD], "packet", " forwarded ");
ANY(ddpstat[DDP_STAT_ENCAP], "packet", " encapsulated ");
ANY(ddpstat[DDP_STAT_CANTFORWARD], "packet",
" rcvd for unreachable dest ");
ANY(ddpstat[DDP_STAT_NOSOCKSPACE], "packet",
" dropped due to no socket space ");
}
#undef ANY