static void sctp_print_address(union sctp_sockstore *address, int port, int num_port) { struct servent *sp = 0; char line[80], *cp; int width; switch (address->sa.sa_family) { #ifdef INET case AF_INET: sprintf(line, "%.*s.", Wflag ? 39 : 16, inetname(&address->sin.sin_addr)); break; #endif #ifdef INET6 case AF_INET6: sprintf(line, "%.*s.", Wflag ? 39 : 16, inet6name(&address->sin6.sin6_addr)); break; #endif default: sprintf(line, "%.*s.", Wflag ? 39 : 16, ""); break; } cp = strchr(line, '\0'); if (!num_port && port) sp = getservbyport((int)port, "sctp"); if (sp || port == 0) sprintf(cp, "%.15s ", sp ? sp->s_name : "*"); else sprintf(cp, "%d ", ntohs((u_short)port)); width = Wflag ? 45 : 22; printf("%-*.*s ", width, width, line); }
/* * Pretty print an Internet address (net address + port). */ void inetprint(const char *container, struct in_addr *in, int port, const char *proto, int num_port, const int af1) { struct servent *sp = 0; char line[80], *cp; int width; size_t alen, plen; if (container) xo_open_container(container); if (Wflag) snprintf(line, sizeof(line), "%s.", inetname(in)); else snprintf(line, sizeof(line), "%.*s.", (Aflag && !num_port) ? 12 : 16, inetname(in)); alen = strlen(line); cp = line + alen; if (!num_port && port) sp = getservbyport((int)port, proto); if (sp || port == 0) snprintf(cp, sizeof(line) - alen, "%.15s ", sp ? sp->s_name : "*"); else snprintf(cp, sizeof(line) - alen, "%d ", ntohs((u_short)port)); width = (Aflag && !Wflag) ? 18 : ((!Wflag || af1 == AF_INET) ? 22 : 45); if (Wflag) xo_emit("{d:target/%-*s} ", width, line); else xo_emit("{d:target/%-*.*s} ", width, width, line); plen = strlen(cp) - 1; alen--; xo_emit("{e:address/%*.*s}{e:port/%*.*s}", alen, alen, line, plen, plen, cp); if (container) xo_close_container(container); }
void print(struct msghdr *mhdr, int cc) { struct sockaddr_in6 *from = (struct sockaddr_in6 *)mhdr->msg_name; char hbuf[NI_MAXHOST]; if (getnameinfo((struct sockaddr *)from, from->sin6_len, hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST) != 0) strlcpy(hbuf, "invalid", sizeof(hbuf)); if (nflag) printf(" %s", hbuf); else if (lflag) printf(" %s (%s)", inetname((struct sockaddr *)from), hbuf); else printf(" %s", inetname((struct sockaddr *)from)); if (verbose) { printf(" %d bytes of data to %s", cc, rcvpktinfo ? inet_ntop(AF_INET6, &rcvpktinfo->ipi6_addr, hbuf, sizeof(hbuf)) : "?"); } }
/* * Pretty print an Internet address (net address + port). */ void inetprint(struct in_addr *in, int port, const char *proto, int num_port) { struct servent *sp = NULL; char line[80], *cp; int width; if (Wflag) sprintf(line, "%s.", inetname(in)); else sprintf(line, "%.*s.", (Aflag && !num_port) ? 12 : 16, inetname(in)); cp = strchr(line, '\0'); if (!num_port && port) sp = getservbyport((int)port, proto); if (sp || port == 0) sprintf(cp, "%.15s ", sp ? sp->s_name : "*"); else sprintf(cp, "%d ", ntohs((u_short)port)); width = (Aflag && !Wflag) ? 17 : 21; if (Wflag) printf("%-*s ", width, line); else printf("%-*.*s ", width, width, line); }
static inline void print(u_char *buf, int cc, struct sockaddr_in *from) { struct ip *ip; int hlen; ip = (struct ip *) buf; hlen = ip->ip_hl << 2; cc -= hlen; inetname(from); #ifdef CONFIG_FEATURE_TRACEROUTE_VERBOSE if (verbose) printf (" %d bytes to %s", cc, inet_ntoa (ip->ip_dst)); #endif }
/* * Pretty print an Internet address (net address + port). * If the nflag was specified, use numbers instead of names. */ static void inetprint(struct in_addr *in, int port, char *proto, field_def *fld) { struct servent *sp = 0; tb_start(); tbprintf("%s", inetname(*in)); if (!nflag && port) sp = getservbyport(port, proto); if (sp || port == 0) tbprintf(":%s", sp ? sp->s_name : "*"); else tbprintf(":%d", ntohs((u_short)port)); print_fld_tb(fld); }
static void sctp_print_address(const char *container, union sctp_sockstore *address, int port, int num_port) { struct servent *sp = 0; char line[80], *cp; int width; if (container) xo_open_container(container); switch (address->sa.sa_family) { #ifdef INET case AF_INET: sprintf(line, "%.*s.", Wflag ? 39 : 16, inetname(&address->sin.sin_addr)); break; #endif #ifdef INET6 case AF_INET6: sprintf(line, "%.*s.", Wflag ? 39 : 16, inet6name(&address->sin6.sin6_addr)); break; #endif default: sprintf(line, "%.*s.", Wflag ? 39 : 16, ""); break; } cp = strchr(line, '\0'); if (!num_port && port) sp = getservbyport((int)port, "sctp"); if (sp || port == 0) sprintf(cp, "%.15s ", sp ? sp->s_name : "*"); else sprintf(cp, "%d ", ntohs((u_short)port)); width = Wflag ? 45 : 22; xo_emit("{d:target/%-*.*s} ", width, width, line); int alen = cp - line - 1, plen = strlen(cp) - 1; xo_emit("{e:address/%*.*s}{e:port/%*.*s}", alen, alen, line, plen, plen, cp); if (container) xo_close_container(container); }
/* * Pretty print an Internet address (net address + port). * If the nflag was specified, use numbers instead of names. */ void inetprint(struct in_addr *in, u_short port, const char *proto) { struct servent *sp = 0; char line[80], *cp; int width; sprintf(line, "%.*s.", 22, inetname(*in)); cp = (char *) strchr(line, '\0'); if (!nflag && port) sp = getservbyport(htons(port), proto); if (sp || port == 0) sprintf(cp, "%.8s", sp ? sp->s_name : "*"); else sprintf(cp, "%d", port); width = 28; printf(" %-*.*s", width, width, line); }
/* * Pretty print an Internet address (net address + port). * If the nflag was specified, use numbers instead of names. */ void inetprint(struct in_addr *in, int port, const char *proto, int local) { struct servent *sp = NULL; char line[80], *cp; int width; snprintf(line, sizeof line, "%.*s.", (Aflag && !nflag) ? 12 : 16, inetname(in)); cp = strchr(line, '\0'); if (!nflag && port) sp = getservbyport((int)port, proto); if (sp || port == 0) snprintf(cp, line + sizeof line - cp, "%.8s", sp ? sp->s_name : "*"); /* * Translation of RPC service names - Omitted */ else snprintf(cp, line + sizeof line - cp, "%d", ntohs(port)); width = Aflag ? 18 : 22; printf(" %-*.*s", width, width, line); }
/* * Pretty print an Internet address (net address + port). * If the nflag was specified, use numbers instead of names. */ void inetprint(struct in_addr *in, in_port_t port, char *proto, int local) { struct servent *sp = 0; char line[80], *cp, *nam; int width; snprintf(line, sizeof line, "%.*s.", (Aflag && !nflag) ? 12 : 16, inetname(in)); cp = strchr(line, '\0'); if (!nflag && port) sp = getservbyport((int)port, proto); if (sp || port == 0) snprintf(cp, line + sizeof line - cp, "%.8s", sp ? sp->s_name : "*"); else if (local && !nflag && (nam = getrpcportnam(ntohs(port), (strcmp(proto, "tcp") == 0 ? IPPROTO_TCP : IPPROTO_UDP)))) snprintf(cp, line + sizeof line - cp, "%d[%.8s]", ntohs(port), nam); else snprintf(cp, line + sizeof line - cp, "%d", ntohs(port)); width = Aflag ? 18 : 22; printf(" %-*.*s", width, width, line); }