Skip to content

Latest commit

 

History

History
24 lines (19 loc) · 896 Bytes

print-autonomous-system-number-in-asdot-notation.md

File metadata and controls

24 lines (19 loc) · 896 Bytes

Print Autonomous System Number in ASDOT notation

The ASN (Autonomous System Number, and you can think it as port number) will be outputted in ASPLAIN format by default. However, if -b option is specified (code is here):

	......
	case 'b':
		++ndo->ndo_bflag;
		break;
	......

The ASN will be displayed in ASDOT notation when the number is bigger than 65535 (code is here):

static char *
as_printf(netdissect_options *ndo,
          char *str, int size, u_int asnum)
{
	if (!ndo->ndo_bflag || asnum <= 0xFFFF) {
		snprintf(str, size, "%u", asnum);
	} else {
		snprintf(str, size, "%u.%u", asnum >> 16, asnum & 0xFFFF);
	}
	return str;
}