-- Network services, Internet style
-- See /etc/services

module(...,package.seeall)

services = {
   ["tcpmux"]           = 1,
   ["echo"]             = 7,
   ["discard"]          = 9,
   ["systat"]           = 11,
   ["daytime"]          = 13,
   ["netstat"]          = 15,
   ["qotd"]             = 17,
   ["msp"]              = 18,
   ["chargen"]          = 19,
   ["ftp-data"]         = 20,
   ["ftp"]              = 21,
   ["fsp"]              = 21,
   ["ssh"]              = 22,
   ["telnet"]           = 23,
   ["smtp"]             = 25,
   ["time"]             = 37,
   ["rlp"]              = 39,
   ["nameserver"]       = 42,
   ["whois"]            = 43,
   ["tacacs"]           = 49,
   ["re-mail-ck"]       = 50,
   ["domain"]           = 53,
   ["mtp"]              = 57,
   ["tacacs-ds"]        = 65,
   ["bootps"]           = 67,
   ["bootpc"]           = 68,
   ["tftp"]             = 69,
   ["gopher"]           = 70,
   ["rje"]              = 77,
   ["finger"]           = 79,
   ["http"]             = 80,
   ["link"]             = 87,
   ["kerberos"]         = 88,
   ["supdup"]           = 95,
   ["hostnames"]        = 101,
   ["iso-tsap"]         = 102,
   ["acr-nema"]         = 104,
   ["csnet-ns"]         = 105,
   ["rtelnet"]          = 107,
   ["pop2"]             = 109,
   ["pop3"]             = 110,
   ["sunrpc"]           = 111,
   ["auth"]             = 113,
   ["sftp"]             = 115,
   ["uucp-path"]        = 117,
   ["nntp"]             = 119,
   ["ntp"]              = 123,
   ["pwdgen"]           = 129,
   ["loc-srv"]          = 135,
   ["netbios-ns"]       = 137,
   ["netbios-dgm"]      = 138,
   ["netbios-ssn"]      = 139,
   ["imap2"]            = 143,
   ["snmp"]             = 161,
   ["snmp-trap"]        = 162,
   ["cmip-man"]         = 163,
   ["cmip-agent"]       = 164,
   ["mailq"]            = 174,
   ["xdmcp"]            = 177,
   ["nextstep"]         = 178,
   ["bgp"]              = 179,
   ["prospero"]         = 191,
   ["irc"]              = 194,
   ["smux"]             = 199,
   ["at-rtmp"]          = 201,
   ["at-nbp"]           = 202,
   ["at-echo"]          = 204,
   ["at-zis"]           = 206,
   ["qmtp"]             = 209,
   ["z3950"]            = 210,
   ["ipx"]              = 213,
   ["imap3"]            = 220,
   ["pawserv"]          = 345,
   ["zserv"]            = 346,
   ["fatserv"]          = 347,
   ["rpc2portmap"]      = 369,
   ["codaauth2"]        = 370,
   ["clearcase"]        = 371,
   ["ulistserv"]        = 372,
   ["ldap"]             = 389,
   ["imsp"]             = 406,
   ["svrloc"]           = 427,
   ["https"]            = 443,
   ["snpp"]             = 444,
   ["microsoft-ds"]     = 445,
   ["kpasswd"]          = 464,
   ["urd"]              = 465,
   ["saft"]             = 487,
   ["isakmp"]           = 500,
   ["rtsp"]             = 554,
   ["nqs"]              = 607,
   ["npmp-local"]       = 610,
   ["npmp-gui"]         = 611,
   ["hmmp-ind"]         = 612,
   ["asf-rmcp"]         = 623,
   ["qmqp"]             = 628,
   ["ipp"]              = 631,
   ["exec"]             = 512,
   ["biff"]             = 512,
   ["login"]            = 513,
   ["who"]              = 513,
   ["shell"]            = 514,
   ["syslog"]           = 514,
   ["printer"]          = 515,
   ["talk"]             = 517,
   ["ntalk"]            = 518,
   ["route"]            = 520,
   ["timed"]            = 525,
   ["tempo"]            = 526,
   ["courier"]          = 530,
   ["conference"]       = 531,
   ["netnews"]          = 532,
   ["netwall"]          = 533,
   ["gdomap"]           = 538,
   ["uucp"]             = 540,
   ["klogin"]           = 543,
   ["kshell"]           = 544,
   ["dhcpv6-client"]    = 546,
   ["dhcpv6-server"]    = 547,
   ["afpovertcp"]       = 548,
   ["idfp"]             = 549,
   ["remotefs"]         = 556,
   ["nntps"]            = 563,
   ["submission"]       = 587,
   ["ldaps"]            = 636,
   ["tinc"]             = 655,
   ["silc"]             = 706,
   ["kerberos-adm"]     = 749,
   ["webster"]          = 765,
   ["rsync"]            = 873,
   ["ftps-data"]        = 989,
   ["ftps"]             = 990,
   ["telnets"]          = 992,
   ["imaps"]            = 993,
   ["ircs"]             = 994,
   ["pop3s"]            = 995,
   ["socks"]            = 1080,
   ["proofd"]           = 1093,
   ["rootd"]            = 1094,
   ["openvpn"]          = 1194,
   ["rmiregistry"]      = 1099,
   ["kazaa"]            = 1214,
   ["nessus"]           = 1241,
   ["lotusnote"]        = 1352,
   ["ms-sql-s"]         = 1433,
   ["ms-sql-m"]         = 1434,
   ["ingreslock"]       = 1524,
   ["prospero-np"]      = 1525,
   ["datametrics"]      = 1645,
   ["sa-msg-port"]      = 1646,
   ["kermit"]           = 1649,
   ["groupwise"]        = 1677,
   ["l2f"]              = 1701,
   ["radius"]           = 1812,
   ["radius-acct"]      = 1813,
   ["msnp"]             = 1863,
   ["unix-status"]      = 1957,
   ["log-server"]       = 1958,
   ["remoteping"]       = 1959,
   ["cisco-sccp"]       = 2000,
   ["search"]           = 2010,
   ["pipe-server"]      = 2010,
   ["nfs"]              = 2049,
   ["gnunet"]           = 2086,
   ["rtcm-sc104"]       = 2101,
   ["gsigatekeeper"]    = 2119,
   ["gris"]             = 2135,
   ["cvspserver"]       = 2401,
   ["venus"]            = 2430,
   ["venus-se"]         = 2431,
   ["codasrv"]          = 2432,
   ["codasrv-se"]       = 2433,
   ["mon"]              = 2583,
   ["dict"]             = 2628,
   ["f5-globalsite"]    = 2792,
   ["gsiftp"]           = 2811,
   ["gpsd"]             = 2947,
   ["gds-db"]           = 3050,
   ["icpv2"]            = 3130,
   ["iscsi-target"]     = 3260,
   ["mysql"]            = 3306,
   ["nut"]              = 3493,
   ["distcc"]           = 3632,
   ["daap"]             = 3689,
   ["svn"]              = 3690,
   ["suucp"]            = 4031,
   ["sysrqd"]           = 4094,
   ["sieve"]            = 4190,
   ["epmd"]             = 4369,
   ["remctl"]           = 4373,
   ["f5-iquery"]        = 4353,
   ["ipsec-nat-t"]      = 4500,
   ["iax"]              = 4569,
   ["mtn"]              = 4691,
   ["radmin-port"]      = 4899,
   ["rfe"]              = 5002,
   ["mmcc"]             = 5050,
   ["sip"]              = 5060,
   ["sip-tls"]          = 5061,
   ["aol"]              = 5190,
   ["xmpp-client"]      = 5222,
   ["xmpp-server"]      = 5269,
   ["cfengine"]         = 5308,
   ["mdns"]             = 5353,
   ["postgresql"]       = 5432,
   ["freeciv"]          = 5556,
   ["amqp"]             = 5672,
   ["ggz"]              = 5688,
   ["x11"]              = 6000,
   ["x11-1"]            = 6001,
   ["x11-2"]            = 6002,
   ["x11-3"]            = 6003,
   ["x11-4"]            = 6004,
   ["x11-5"]            = 6005,
   ["x11-6"]            = 6006,
   ["x11-7"]            = 6007,
   ["gnutella-svc"]     = 6346,
   ["gnutella-rtr"]     = 6347,
   ["sge-qmaster"]      = 6444,
   ["sge-execd"]        = 6445,
   ["mysql-proxy"]      = 6446,
   ["afs3-fileserver"]  = 7000,
   ["afs3-callback"]    = 7001,
   ["afs3-prserver"]    = 7002,
   ["afs3-vlserver"]    = 7003,
   ["afs3-kaserver"]    = 7004,
   ["afs3-volser"]      = 7005,
   ["afs3-errors"]      = 7006,
   ["afs3-bos"]         = 7007,
   ["afs3-update"]      = 7008,
   ["afs3-rmtsys"]      = 7009,
   ["font-service"]     = 7100,
   ["http-alt"]         = 8080,
   ["bacula-dir"]       = 9101,
   ["bacula-fd"]        = 9102,
   ["bacula-sd"]        = 9103,
   ["xmms2"]            = 9667,
   ["nbd"]              = 10809,
   ["zabbix-agent"]     = 10050,
   ["zabbix-trapper"]   = 10051,
   ["amanda"]           = 10080,
   ["dicom"]            = 11112,
   ["hkp"]              = 11371,
   ["bprd"]             = 13720,
   ["bpdbm"]            = 13721,
   ["bpjava-msvc"]      = 13722,
   ["vnetd"]            = 13724,
   ["bpcd"]             = 13782,
   ["vopied"]           = 13783,
   ["db-lsp"]           = 17500,
   ["dcap"]             = 22125,
   ["gsidcap"]          = 22128,
   ["wnn6"]             = 22273,
   -- The remaining ports are not as allocated by IANA
   ["kerberos4"]        = 750,
   ["kerberos-master"]  = 751,
   ["passwd-server"]    = 752,
   ["krb-prop"]         = 754,
   ["krbupdate"]        = 760,
   ["swat"]             = 901,
   ["kpop"]             = 1109,
   ["knetd"]            = 2053,
   ["zephyr-srv"]       = 2102,
   ["zephyr-clt"]       = 2103,
   ["zephyr-hm"]        = 2104,
   ["eklogin"]          = 2105,
   ["kx"]               = 2111,
   ["iprop"]            = 2121,
   ["supfilesrv"]       = 871,
   ["supfiledbg"]       = 1127,
   ["linuxconf"]        = 98,
   ["poppassd"]         = 106,
   ["moira-db"]         = 775,
   ["moira-update"]     = 777,
   ["moira-ureg"]       = 779,
   ["spamd"]            = 783,
   ["omirr"]            = 808,
   ["customs"]          = 1001,
   ["skkserv"]          = 1178,
   ["predict"]          = 1210,
   ["rmtcfg"]           = 1236,
   ["wipld"]            = 1300,
   ["xtel"]             = 1313,
   ["xtelw"]            = 1314,
   ["support"]          = 1529,
   ["cfinger"]          = 2003,
   ["frox"]             = 2121,
   ["ninstall"]         = 2150,
   ["zebrasrv"]         = 2600,
   ["zebra"]            = 2601,
   ["ripd"]             = 2602,
   ["ripngd"]           = 2603,
   ["ospfd"]            = 2604,
   ["bgpd"]             = 2605,
   ["ospf6d"]           = 2606,
   ["ospfapi"]          = 2607,
   ["isisd"]            = 2608,
   ["afbackup"]         = 2988,
   ["afmbackup"]        = 2989,
   ["xtell"]            = 4224,
   ["fax"]              = 4557,
   ["hylafax"]          = 4559,
   ["distmp3"]          = 4600,
   ["munin"]            = 4949,
   ["enbd-cstatd"]      = 5051,
   ["enbd-sstatd"]      = 5052,
   ["pcrd"]             = 5151,
   ["noclog"]           = 5354,
   ["hostmon"]          = 5355,
   ["rplay"]            = 5555,
   ["nrpe"]             = 5666,
   ["nsca"]             = 5667,
   ["mrtd"]             = 5674,
   ["bgpsim"]           = 5675,
   ["canna"]            = 5680,
   ["syslog-tls"]       = 6514,
   ["sane-port"]        = 6566,
   ["ircd"]             = 6667,
   ["zope-ftp"]         = 8021,
   ["tproxy"]           = 8081,
   ["omniorb"]          = 8088,
   ["clc-build-daemon"] = 8990,
   ["xinetd"]           = 9098,
   ["mandelspawn"]      = 9359,
   ["git"]              = 9418,
   ["zope"]             = 9673,
   ["webmin"]           = 10000,
   ["kamanda"]          = 10081,
   ["amandaidx"]        = 10082,
   ["amidxtape"]        = 10083,
   ["smsqp"]            = 11201,
   ["xpilot"]           = 15345,
   ["sgi-cmsd"]         = 17001,
   ["sgi-crsd"]         = 17002,
   ["sgi-gcd"]          = 17003,
   ["sgi-cad"]          = 17004,
   ["isdnlog"]          = 20011,
   ["vboxd"]            = 20012,
   ["binkp"]            = 24554,
   ["asp"]              = 27374,
   ["csync2"]           = 30865,
   ["dircproxy"]        = 57000,
   ["tfido"]            = 60177,
   ["fido"]             = 60179,
}

protocol_header_field_offsets = {
   icmptype = 0,
   icmpcode = 1,
   tcpflags = 13,
}

-- http://support.microsoft.com/kb/170292
icmp_type_fields = {
   ["icmp-echoreply"]     = 0,
   ["icmp-unreach"]       = 3,
   ["icmp-sourcequench"]  = 4,
   ["icmp-redirect"]      = 5,
   ["icmp-echo"]          = 8,
   ["icmp-routeradvert"]  = 9,
   ["icmp-routersolicit"] = 10,
   ["icmp-timxceed"]      = 11,
   ["icmp-paramprob"]     = 12,
   ["icmp-tstamp"]        = 13,
   ["icmp-tstampreply"]   = 14,
   ["icmp-ireq"]          = 15,
   ["icmp-ireqreply"]     = 16,
   ["icmp-maskreq"]       = 17,
   ["icmp-maskreply"]     = 18,
}

-- http://stackoverflow.com/questions/1480548/tcp-flags-present-in-the-header
tcp_flag_fields = {
   ["tcp-fin"]  = 1,
   ["tcp-syn"]  = 2,
   ["tcp-rst"]  = 4,
   ["tcp-push"] = 8,
   ["tcp-ack"]  = 16,
   ["tcp-urg"]  = 32,
}
