Skip to content

Instantly share code, notes, and snippets.

@acg
Created February 23, 2014 03:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acg/9166590 to your computer and use it in GitHub Desktop.
Save acg/9166590 to your computer and use it in GitHub Desktop.
$ grep -iHn poop netcat.c
netcat.c:94:struct host_poop {
netcat.c:99:#define HINF struct host_poop
netcat.c:101:struct port_poop {
netcat.c:106:#define PINF struct port_poop
netcat.c:143:HINF ** gates = NULL; /* LSRR hop hostpoop */
netcat.c:149:PINF * portpoop = NULL; /* for getportpoop / getservby* */
netcat.c:299: cross-check the host_poop we have so far against new gethostby*() info,
netcat.c:303:int comparehosts (poop, hp)
netcat.c:304: HINF * poop;
netcat.c:312: if (strcmp (poop->name, hp->h_name) != 0) { /* case-sensitive */
netcat.c:314: if (strcasecmp (poop->name, hp->h_name) != 0) { /* normal */
netcat.c:316: holler ("DNS fwd/rev mismatch: %s != %s", poop->name, hp->h_name);
netcat.c:323:/* gethostpoop :
netcat.c:324: resolve a host 8 ways from sunday; return a new host_poop struct with its
netcat.c:328:HINF * gethostpoop (name, numeric)
netcat.c:334: register HINF * poop = NULL;
netcat.c:359: poop = (HINF *) Hmalloc (sizeof (HINF));
netcat.c:360: if (! poop)
netcat.c:361: bail ("gethostpoop fuxored");
netcat.c:362: strcpy (poop->name, unknown); /* preload it */
netcat.c:373: strncpy (poop->name, hostent->h_name, MAXHOSTNAMELEN - 2);
netcat.c:375: memcpy (&poop->iaddrs[x], hostent->h_addr_list[x], sizeof (IA));
netcat.c:376: strncpy (poop->addrs[x], inet_ntoa (poop->iaddrs[x]),
netcat.c:377: sizeof (poop->addrs[0]));
netcat.c:380: return (poop); /* inverse stuff, we're done. */
netcat.c:383: for (x = 0; poop->iaddrs[x].s_addr && (x < 8); x++) {
netcat.c:384: hostent = gethostbyaddr ((char *)&poop->iaddrs[x],
netcat.c:388: poop->addrs[x]);
netcat.c:390: (void) comparehosts (poop, hostent);
netcat.c:394: memcpy (poop->iaddrs, &iaddr, sizeof (IA));
netcat.c:395: strncpy (poop->addrs[0], inet_ntoa (iaddr), sizeof (poop->addrs));
netcat.c:397: return (poop);
netcat.c:399: return (poop); /* the full DNS hair */
netcat.c:405: strncpy (poop->name, hostent->h_name, MAXHOSTNAMELEN - 2);
netcat.c:406: hostent = gethostbyname (poop->name);
netcat.c:409: poop->name);
netcat.c:411: (void) comparehosts (poop, hostent);
netcat.c:415:/* whatever-all went down previously, we should now have a host_poop struct
netcat.c:418: return (poop);
netcat.c:419:} /* gethostpoop */
netcat.c:421:/* getportpoop :
netcat.c:422: Same general idea as gethostpoop -- look up a port in /etc/services, fill
netcat.c:423: in global port_poop, but return the actual port *number*. Pass ONE of:
netcat.c:428:USHORT getportpoop (pstring, pnum)
netcat.c:438: portpoop->name[0] = '?'; /* fast preload */
netcat.c:439: portpoop->name[1] = '\0';
netcat.c:455: strncpy (portpoop->name, servent->s_name, sizeof (portpoop->name));
netcat.c:469: return (getportpoop (NULL, x)); /* recurse for numeric-string-arg */
netcat.c:474: strncpy (portpoop->name, servent->s_name, sizeof (portpoop->name));
netcat.c:496: sprintf (portpoop->anum, "%d", x); /* always load any numeric specs! */
netcat.c:497: portpoop->num = (x & 0xffff); /* ushort, remember... */
netcat.c:498: return (portpoop->num);
netcat.c:499:} /* getportpoop */
netcat.c:906: gethostpoop wants a string and there's much gnarlier code out there already,
netcat.c:914: whozis = gethostpoop (bigbuf_net, o_nflag);
netcat.c:1329: portpoop = (PINF *) Hmalloc (sizeof (PINF));
netcat.c:1415: gp = gethostpoop (optarg, o_nflag);
netcat.c:1440: o_lport = getportpoop (optarg, 0);
netcat.c:1450: wherefrom = gethostpoop (optarg, o_nflag);
netcat.c:1506: whereto = gethostpoop (argv[optind], o_nflag);
netcat.c:1521: curport = getportpoop (argv[optind], 0);
netcat.c:1559: hiport = getportpoop (cp, 0);
netcat.c:1563: loport = getportpoop (argv[optind], 0);
netcat.c:1584: curport = getportpoop (NULL, curport);
netcat.c:1593: whereto->name, whereto->addrs[0], curport, portpoop->name);
netcat.c:1606: whereto->name, whereto->addrs[0], curport, portpoop->name);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment