MCPcopy Create free account
hub / github.com/F-Stack/f-stack / print_port

Function print_port

tools/ipfw/ipfw2.c:869–892  ·  view source on GitHub ↗

* prints one port, symbolic or numeric */

Source from the content-addressed store, hash-verified

867 * prints one port, symbolic or numeric
868 */
869static void
870print_port(struct buf_pr *bp, int proto, uint16_t port)
871{
872
873 if (proto == IPPROTO_ETHERTYPE) {
874 char const *s;
875
876 if (g_co.do_resolv && (s = match_value(ether_types, port)) )
877 bprintf(bp, "%s", s);
878 else
879 bprintf(bp, "0x%04x", port);
880 } else {
881 struct servent *se = NULL;
882 if (g_co.do_resolv) {
883 struct protoent *pe = getprotobynumber(proto);
884
885 se = getservbyport(htons(port), pe ? pe->p_name : NULL);
886 }
887 if (se)
888 bprintf(bp, "%s", se->s_name);
889 else
890 bprintf(bp, "%d", port);
891 }
892}
893
894static struct _s_x _port_name[] = {
895 {"dst-port", O_IP_DSTPORT},

Callers 1

print_newportsFunction · 0.85

Calls 2

match_valueFunction · 0.85
bprintfFunction · 0.85

Tested by

no test coverage detected