aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vppinfra/format.h7
-rw-r--r--src/vppinfra/unix-formats.c479
2 files changed, 0 insertions, 486 deletions
diff --git a/src/vppinfra/format.h b/src/vppinfra/format.h
index 6e958e2cce8..70882adac99 100644
--- a/src/vppinfra/format.h
+++ b/src/vppinfra/format.h
@@ -102,17 +102,10 @@ _(format_time_interval);
#ifdef CLIB_UNIX
/* Unix specific formats. */
_(format_address_family);
-_(format_unix_arphrd);
-_(format_unix_interface_flags);
_(format_network_address);
_(format_network_protocol);
_(format_network_port);
_(format_sockaddr);
-_(format_ip4_tos_byte);
-_(format_ip4_packet);
-_(format_icmp4_type_and_code);
-_(format_ethernet_packet);
-_(format_hostname);
_(format_timeval);
_(format_time_float);
_(format_signal);
diff --git a/src/vppinfra/unix-formats.c b/src/vppinfra/unix-formats.c
index cd137e58687..fd112675fa7 100644
--- a/src/vppinfra/unix-formats.c
+++ b/src/vppinfra/unix-formats.c
@@ -283,485 +283,6 @@ u8 * format_sockaddr (u8 * s, va_list * args)
}
#ifndef __APPLE__
-u8 * format_tcp4_packet (u8 * s, va_list * args)
-{
- u8 * p = va_arg (*args, u8 *);
- struct iphdr * ip = (void *) p;
- struct tcphdr * tcp = (void *) (ip + 1);
-
- s = format (s, "tcp %U:%U -> %U:%U",
- format_network_address, AF_INET, &ip->saddr,
- format_network_port, IPPROTO_TCP, ntohs (tcp->source),
- format_network_address, AF_INET, &ip->daddr,
- format_network_port, IPPROTO_TCP, ntohs (tcp->dest));
-
- s = format (s, ", seq 0x%08x -> 0x%08x", tcp->seq, tcp->ack_seq);
-#define _(f) if (tcp->f) s = format (s, ", " #f);
- _ (syn); _ (ack); _ (fin); _ (rst); _ (psh); _ (urg);
-#undef _
-
- if (tcp->window)
- s = format (s, ", window 0x%04x", tcp->window);
- if (tcp->urg)
- s = format (s, ", urg 0x%04x", tcp->urg_ptr);
-
- return s;
-}
-
-u8 * format_udp4_packet (u8 * s, va_list * args)
-{
- u8 * p = va_arg (*args, u8 *);
- struct iphdr * ip = (void *) p;
- struct udphdr * udp = (void *) (ip + 1);
-
- s = format (s, "udp %U:%U -> %U:%U", format_network_address, AF_INET,
- &ip->saddr, format_network_port, IPPROTO_UDP,
- ntohs (udp->source), format_network_address, AF_INET, &ip->daddr,
- format_network_port, IPPROTO_UDP, ntohs (udp->dest));
-
- return s;
-}
-
-u8 * format_icmp4_type_and_code (u8 * s, va_list * args)
-{
- uword icmp_type = va_arg (*args, uword);
- uword icmp_code = va_arg (*args, uword);
-
- switch (icmp_type)
- {
-#define _(f,str) case ICMP_##f: s = format (s, str); break;
- _ (ECHOREPLY, "echo reply");
- _ (DEST_UNREACH, "unreachable");
- _ (SOURCE_QUENCH, "source quench");
- _ (REDIRECT, "redirect");
- _ (ECHO, "echo request");
- _ (TIME_EXCEEDED, "time exceeded");
- _ (PARAMETERPROB, "parameter problem");
- _ (TIMESTAMP, "timestamp request");
- _ (TIMESTAMPREPLY, "timestamp reply");
- _ (INFO_REQUEST, "information request");
- _ (INFO_REPLY, "information reply");
- _ (ADDRESS, "address mask request");
- _ (ADDRESSREPLY, "address mask reply");
-#undef _
- default:
- s = format (s, "unknown type 0x%x", icmp_type);
- }
-
- if (icmp_type == ICMP_DEST_UNREACH)
- {
- switch (icmp_code)
- {
-#define _(f,str) case ICMP_##f: s = format (s, " " # str); break;
- _ (NET_UNREACH, "network");
- _ (HOST_UNREACH, "host");
- _ (PROT_UNREACH, "protocol");
- _ (PORT_UNREACH, "port");
- _ (FRAG_NEEDED, ": fragmentation needed/DF set");
- _ (SR_FAILED, "source route failed");
- _ (NET_UNKNOWN, "network unknown");
- _ (HOST_UNKNOWN, "host unknown");
- _ (HOST_ISOLATED, "host isolated");
- _ (NET_ANO, "network: admin. prohibited");
- _ (HOST_ANO, "host: admin. prohibited");
- _ (NET_UNR_TOS, "network for type-of-service");
- _ (HOST_UNR_TOS, "host for type-of-service");
- _ (PKT_FILTERED, ": packet filtered");
- _ (PREC_VIOLATION, "precedence violation");
- _ (PREC_CUTOFF, "precedence cut off");
-#undef _
- default:
- s = format (s, "unknown code 0x%x", icmp_code);
- }
- }
- else if (icmp_type == ICMP_REDIRECT)
- {
- switch (icmp_code)
- {
-#define _(f,str) case ICMP_##f: s = format (s, " " # str); break;
- _ (REDIR_NET, "network");
- _ (REDIR_HOST, "host");
- _ (REDIR_NETTOS, "network for type-of-service");
- _ (REDIR_HOSTTOS, "host for type-of-service");
-#undef _
- default:
- s = format (s, "unknown code 0x%x", icmp_code);
- }
- }
- else if (icmp_type == ICMP_TIME_EXCEEDED)
- {
- switch (icmp_code)
- {
-#define _(f,str) case ICMP_##f: s = format (s, " " # str); break;
- _ (EXC_TTL, "time-to-live zero in transit");
- _ (EXC_FRAGTIME, "time-to-live zero during reassembly");
-#undef _
- default:
- s = format (s, "unknown code 0x%x", icmp_code);
- }
- }
-
- return s;
-}
-
-typedef struct {
- u8 type;
- u8 code;
- u16 checksum;
-} icmp4_t;
-
-u8 * format_icmp4_packet (u8 * s, va_list * args)
-{
- u8 * p = va_arg (*args, u8 *);
- struct iphdr * ip = (void *) p;
- icmp4_t * icmp = (void *) (ip + 1);
- s = format (s, "icmp %U %U -> %U",
- format_icmp4_type_and_code, icmp->type, icmp->code,
- format_network_address, AF_INET, &ip->saddr,
- format_network_address, AF_INET, &ip->daddr);
-
- return s;
-}
-
-u8 * format_ip4_tos_byte (u8 * s, va_list * args)
-{
- uword tos = va_arg (*args, uword);
-
- if (tos & IPTOS_LOWDELAY)
- s = format (s, "minimize-delay, ");
- if (tos & IPTOS_MINCOST)
- s = format (s, "minimize-cost, ");
- if (tos & IPTOS_THROUGHPUT)
- s = format (s, "maximize-throughput, ");
- if (tos & IPTOS_RELIABILITY)
- s = format (s, "maximize-reliability, ");
-
- switch (IPTOS_PREC (tos))
- {
-#define _(x,y) case IPTOS_PREC_##x: s = format (s, y); break
- _ (NETCONTROL, "network");
- _ (INTERNETCONTROL, "internet");
- _ (CRITIC_ECP, "critical");
- _ (FLASH, "flash");
- _ (FLASHOVERRIDE, "flash-override");
- _ (IMMEDIATE, "immediate");
- _ (PRIORITY, "priority");
- _ (ROUTINE, "routine");
-#undef _
- }
-
- return s;
-}
-
-u8 * format_ip4_packet (u8 * s, va_list * args)
-{
- u8 * p = va_arg (*args, u8 *);
- struct iphdr * ip = (void *) p;
-
- static format_function_t * f[256];
-
- if (! f[IPPROTO_TCP])
- {
- f[IPPROTO_TCP] = format_tcp4_packet;
- f[IPPROTO_UDP] = format_udp4_packet;
- f[IPPROTO_ICMP] = format_icmp4_packet;
- }
-
- if (f[ip->protocol])
- return format (s, "%U", f[ip->protocol], p);
-
- s = format (s, "%U: %U -> %U",
- format_network_protocol, AF_INET, ip->protocol,
- format_network_address, AF_INET, &ip->saddr,
- format_network_address, AF_INET, &ip->daddr);
-
- return s;
-}
-
-#define foreach_unix_arphrd_type \
- _ (NETROM, 0) \
- _ (ETHER, 1) \
- _ (EETHER, 2) \
- _ (AX25, 3) \
- _ (PRONET, 4) \
- _ (CHAOS, 5) \
- _ (IEEE802, 6) \
- _ (ARCNET, 7) \
- _ (APPLETLK, 8) \
- _ (DLCI, 15) \
- _ (ATM, 19) \
- _ (METRICOM, 23) \
- _ (IEEE1394, 24) \
- _ (EUI64, 27) \
- _ (INFINIBAND, 32) \
- _ (SLIP, 256) \
- _ (CSLIP, 257) \
- _ (SLIP6, 258) \
- _ (CSLIP6, 259) \
- _ (RSRVD, 260) \
- _ (ADAPT, 264) \
- _ (ROSE, 270) \
- _ (X25, 271) \
- _ (HWX25, 272) \
- _ (PPP, 512) \
- _ (HDLC, 513) \
- _ (LAPB, 516) \
- _ (DDCMP, 517) \
- _ (RAWHDLC, 518) \
- _ (TUNNEL, 768) \
- _ (TUNNEL6, 769) \
- _ (FRAD, 770) \
- _ (SKIP, 771) \
- _ (LOOPBACK, 772) \
- _ (LOCALTLK, 773) \
- _ (FDDI, 774) \
- _ (BIF, 775) \
- _ (SIT, 776) \
- _ (IPDDP, 777) \
- _ (IPGRE, 778) \
- _ (PIMREG, 779) \
- _ (HIPPI, 780) \
- _ (ASH, 781) \
- _ (ECONET, 782) \
- _ (IRDA, 783) \
- _ (FCPP, 784) \
- _ (FCAL, 785) \
- _ (FCPL, 786) \
- _ (FCFABRIC, 787) \
- _ (IEEE802_TR, 800) \
- _ (IEEE80211, 801) \
- _ (IEEE80211_PRISM, 802) \
- _ (IEEE80211_RADIOTAP, 803) \
- _ (VOID, 0xFFFF) \
- _ (NONE, 0xFFFE)
-
-u8 * format_unix_arphrd (u8 * s, va_list * args)
-{
-#ifndef __COVERITY__ /* doesn't understand this at all... */
- u32 x = va_arg (*args, u32);
- char * t;
- switch (x)
- {
-#define _(f,n) case ARPHRD_##f: t = #f; break;
- foreach_unix_arphrd_type
-#undef _
- default:
- t = 0;
- break;
- }
-
- if (t)
- s = format (s, "%s", t);
- else
- s = format (s, "unknown 0x%x", x);
-#endif
- return s;
-}
-
-#define foreach_unix_interface_flag \
- _ (up) \
- _ (broadcast) \
- _ (debug) \
- _ (loopback) \
- _ (pointopoint) \
- _ (notrailers) \
- _ (running) \
- _ (noarp) \
- _ (promisc) \
- _ (allmulti) \
- _ (master) \
- _ (slave) \
- _ (multicast) \
- _ (portsel) \
- _ (automedia) \
- _ (dynamic) \
- _ (lower_up) \
- _ (dormant) \
- _ (echo)
-
-static char * unix_interface_flag_names[] = {
-#define _(f) #f,
- foreach_unix_interface_flag
-#undef _
-};
-
-u8 * format_unix_interface_flags (u8 * s, va_list * args)
-{
- u32 x = va_arg (*args, u32);
- u32 i;
-
- if (x == 0)
- s = format (s, "none");
- else foreach_set_bit (i, x, ({
- if (i < ARRAY_LEN (unix_interface_flag_names))
- s = format (s, "%s", unix_interface_flag_names[i]);
- else
- s = format (s, "unknown %d", i);
- if (x >> (i + 1))
- s = format (s, ", ");
- }));
- return s;
-}
-
-typedef struct {
- u16 ar_hrd; /* format of hardware address */
- u16 ar_pro; /* format of protocol address */
- u8 ar_hln; /* length of hardware address */
- u8 ar_pln; /* length of protocol address */
- u16 ar_op; /* ARP opcode (command) */
- u8 ar_sha[6]; /* sender hardware address */
- u8 ar_spa[4]; /* sender IP address */
- u8 ar_tha[6]; /* target hardware address */
- u8 ar_tpa[4]; /* target IP address */
-} arp_ether_ip4_t;
-
-u8 * format_arp_packet (u8 * s, va_list * args)
-{
- arp_ether_ip4_t * a = va_arg (*args, arp_ether_ip4_t *);
- char * op = "unknown";
-
- if (a->ar_pro != ETH_P_IP ||
- a->ar_hrd != ARPHRD_ETHER)
- return s;
-
- switch (a->ar_op)
- {
-#define _(f) case ARPOP_##f: op = #f; break;
- _ (REQUEST);
- _ (REPLY);
- _ (RREQUEST);
- _ (RREPLY);
-#undef _
- }
-
- s = format (s, "%s %U %U -> %U %U",
- op,
- format_network_address, AF_INET, a->ar_spa,
- format_network_address, AF_UNSPEC, a->ar_sha,
- format_network_address, AF_INET, a->ar_tpa,
- format_network_address, AF_UNSPEC, a->ar_tha);
- return s;
-}
-
-u8 * format_ethernet_proto (u8 * s, va_list * args)
-{
- uword type = va_arg (*args, uword);
- char * t = 0;
-
- switch (type)
- {
- case 0: t = "BPDU"; break;
-#define _(f) case ETH_P_##f: t = #f; break;
- _ (LOOP);
- _ (PUP);
-#ifdef ETH_P_PUPAT
- _ (PUPAT);
-#endif
- _ (IP);
- _ (X25);
- _ (ARP);
- _ (BPQ);
-#ifdef ETH_P_PUPAT
- _ (IEEEPUP);
- _ (IEEEPUPAT);
-#endif
- _ (DEC);
- _ (DNA_DL);
- _ (DNA_RC);
- _ (DNA_RT);
- _ (LAT);
- _ (DIAG);
- _ (CUST);
- _ (SCA);
- _ (RARP);
- _ (ATALK);
- _ (AARP);
- _ (IPX);
- _ (IPV6);
-#ifdef ETH_P_PPP_DISC
- _ (PPP_DISC);
- _ (PPP_SES);
-#endif
-#ifdef ETH_P_ATMMPOA
- _ (ATMMPOA);
- _ (ATMFATE);
-#endif
- _ (802_3);
- _ (AX25);
- _ (ALL);
- _ (802_2);
- _ (SNAP);
- _ (DDCMP);
- _ (WAN_PPP);
- _ (PPP_MP);
- _ (LOCALTALK);
- _ (PPPTALK);
- _ (TR_802_2);
- _ (MOBITEX);
- _ (CONTROL);
- _ (IRDA);
-#ifdef ETH_P_ECONET
- _ (ECONET);
-#endif
-#undef _
- }
-
- if (t)
- vec_add (s, t, strlen (t));
- else
- s = format (s, "ether-type 0x%x", type);
- return s;
-}
-
-u8 * format_ethernet_packet (u8 * s, va_list * args)
-{
- struct ethhdr * h = va_arg (*args, struct ethhdr *);
- uword proto = h->h_proto;
- u8 * payload = (void *) (h + 1);
- u32 indent;
-
- /* Check for 802.2/802.3 encapsulation. */
- if (proto < ETH_DATA_LEN)
- {
- typedef struct {
- u8 dsap, ssap, control;
- u8 orig_code[3];
- u16 proto;
- } ethhdr_802_t;
- ethhdr_802_t * h1 = (void *) (h + 1);
- proto = h1->proto;
- payload = (void *) (h1 + 1);
- }
-
- indent = format_get_indent (s);
-
- s = format (s, "%U: %U -> %U",
- format_ethernet_proto, proto,
- format_network_address, AF_UNSPEC, h->h_source,
- format_network_address, AF_UNSPEC, h->h_dest);
-
- switch (proto)
- {
- case ETH_P_ARP:
- s = format (s, "\n%U%U",
- format_white_space, indent,
- format_arp_packet, payload);
- break;
- }
-
- return s;
-}
-
-#ifndef __KERNEL__
-u8 * format_hostname (u8 * s, va_list * args)
-{
- char buffer[1024];
- char * b = buffer;
- if (gethostname (b, sizeof (buffer)) < 0)
- b = "noname";
- return format (s, "%s", b);
-}
-#endif
#ifndef __KERNEL__
u8 * format_timeval (u8 * s, va_list * args)