pike.git / lib / modules / Protocols.pmod / Ports.pmod

version» Context lines:

pike.git/lib/modules/Protocols.pmod/Ports.pmod:1:   /*    * IP port assignments    *    * Henrik Grubbström 1998-06-23    */    + //! A list of named ports. + //! This is similar to /etc/services. +    #pike __REAL_VERSION__    - // Contains all UDP ports assigned for private use as of RFC 1700 + //! Contains all UDP ports assigned for private use as of @rfc{1700@}.   constant private_udp = ([    "mail": 24, // any private mail system    "printer": 35, // any private printer server    "terminal": 57, // any private terminal access    "file": 59, // any private file service    "dial": 75, // any private dial out service    "rje": 77, // any private RJE service    "terminal-link": 87, // any private terminal link   ]);    - // Contains all TCP ports assigned for private use as of RFC 1700 + //! Contains all TCP ports assigned for private use as of @rfc{1700@}.   constant private_tcp = ([    "mail": 24, // any private mail system    "printer": 35, // any private printer server    "terminal": 57, // any private terminal access    "file": 59, // any private file service    "dial": 75, // any private dial out service    "rje": 77, // any private RJE service    "terminal-link": 87, // any private terminal link   ]);    - // Contains all non-private UDP port assignments as of RFC 1700 + //! Contains all non-private UDP port assignments as of @rfc{1700@}.   constant udp = ([    "tcpmux": 1, // TCP Port Service Multiplexer    "compressnet-mgmt": 2, // Management Utility    "compressnet": 3, // Compression Process    "rje": 5, // Remote Job Entry    "echo": 7, // Echo    "discard": 9, // Discard    "systat": 11, // Active Users    "daytime": 13, // Daytime    "qotd": 17, // Quote of the Day
pike.git/lib/modules/Protocols.pmod/Ports.pmod:80:    "gopher": 70, // Gopher    "netrjs-1": 71, // Remote Job Service    "netrjs-2": 72, // Remote Job Service    "netrjs-3": 73, // Remote Job Service    "netrjs-4": 74, // Remote Job Service    "deos": 76, // Distributed External Object Store    "vettcp": 78, // vettcp    "finger": 79, // Finger    "www-http": 80, // World Wide Web HTTP    "http": 80, // World Wide Web HTTP +  "ws": 80, // WebSockets    "hosts2-ns": 81, // HOSTS2 Name Server    "xfer": 82, // XFER Utility    "mit-ml-dev": 83, // MIT ML Device    "ctf": 84, // Common Trace Facility    "mit-ml-dev": 85, // MIT ML Device    "mfcobol": 86, // Micro Focus Cobol    "kerberos": 88, // Kerberos    "su-mit-tg": 89, // SU/MIT Telnet Gateway    "dnsix": 90, // DNSIX Securit Attribute Token Map    "mit-dov": 91, // MIT Dover Spooler
pike.git/lib/modules/Protocols.pmod/Ports.pmod:300:    "mobileip-agent": 434, // MobileIP-Agent    "mobilip-mn": 435, // MobilIP-MN    "dna-cml": 436, // DNA-CML    "comscm": 437, // comscm    "dsfgw": 438, // dsfgw    "dasp": 439, // dasp tommy@inlab.m.eunet.de    "sgcp": 440, // sgcp    "decvms-sysmgt": 441, // decvms-sysmgt    "cvc_hostd": 442, // cvc_hostd    "https": 443, // https MCom +  "wss": 443, // Secure WebSocket    "snpp": 444, // Simple Network Paging Protocol    "microsoft-ds": 445, // Microsoft-DS    "ddm-rdb": 446, // DDM-RDB    "ddm-dfm": 447, // DDM-RFM    "ddm-byte": 448, // DDM-BYTE    "as-servermap": 449, // AS Server Mapper    "tserver": 450, // TServer    "biff": 512, // used by mail system to notify users    "who": 513, // maintains data bases showing who's    "syslog": 514, //
pike.git/lib/modules/Protocols.pmod/Ports.pmod:698:    "afs3-bos": 7007, // basic overseer process    "afs3-update": 7008, // server-to-server updater    "afs3-rmtsys": 7009, // remote cache manager service    "ups-onlinet": 7010, // onlinet uninterruptable power supplies    "font-service": 7100, // X Font Service    "fodms": 7200, // FODMS FLIP    "man": 9535, //    "isode-dua": 17007, //   ]);    - // Contains all non-private TCP port assignments as of RFC 1700 - // Extended with some non-official. + //! Contains all non-private TCP port assignments as of @rfc{1700@}. + //! Extended with some non-official.   constant tcp = ([    "tcpmux": 1, // TCP Port Service Multiplexer    "compressnet-mgmt": 2, // Management Utility    "compressnet": 3, // Compression Process    "rje": 5, // Remote Job Entry    "echo": 7, // Echo    "discard": 9, // Discard    "systat": 11, // Active Users    "daytime": 13, // Daytime    "netstat": 15, // Unassigned [was netstat]
pike.git/lib/modules/Protocols.pmod/Ports.pmod:760:    "gopher": 70, // Gopher    "netrjs-1": 71, // Remote Job Service    "netrjs-2": 72, // Remote Job Service    "netrjs-3": 73, // Remote Job Service    "netrjs-4": 74, // Remote Job Service    "deos": 76, // Distributed External Object Store    "vettcp": 78, // vettcp    "finger": 79, // Finger    "www-http": 80, // World Wide Web HTTP    "http": 80, // World Wide Web HTTP +  "ws": 80, // WebSockets    "hosts2-ns": 81, // HOSTS2 Name Server    "xfer": 82, // XFER Utility    "mit-ml-dev": 83, // MIT ML Device    "ctf": 84, // Common Trace Facility    "mit-ml-dev": 85, // MIT ML Device    "mfcobol": 86, // Micro Focus Cobol    "kerberos": 88, // Kerberos    "su-mit-tg": 89, // SU/MIT Telnet Gateway    "dnsix": 90, // DNSIX Securit Attribute Token Map    "mit-dov": 91, // MIT Dover Spooler
pike.git/lib/modules/Protocols.pmod/Ports.pmod:983:    "mobileip-agent": 434, // MobileIP-Agent    "mobilip-mn": 435, // MobilIP-MN    "dna-cml": 436, // DNA-CML    "comscm": 437, // comscm    "dsfgw": 438, // dsfgw    "dasp": 439, // dasp Thomas Obermair    "sgcp": 440, // sgcp    "decvms-sysmgt": 441, // decvms-sysmgt    "cvc_hostd": 442, // cvc_hostd    "https": 443, // https MCom +  "wss": 443, // Secure WebSockets    "snpp": 444, // Simple Network Paging Protocol    "microsoft-ds": 445, // Microsoft-DS    "ddm-rdb": 446, // DDM-RDB    "ddm-dfm": 447, // DDM-RFM    "ddm-byte": 448, // DDM-BYTE    "as-servermap": 449, // AS Server Mapper    "tserver": 450, // TServer    "ssmtp": 465, // SMTP over SSL    "exec": 512, // remote process execution;    "login": 513, // remote login a la telnet;
pike.git/lib/modules/Protocols.pmod/Ports.pmod:1393:    "afs3-errors": 7006, // error interpretation service    "afs3-bos": 7007, // basic overseer process    "afs3-update": 7008, // server-to-server updater    "afs3-rmtsys": 7009, // remote cache manager service    "ups-onlinet": 7010, // onlinet uninterruptable power supplies    "font-service": 7100, // X Font Service    "fodms": 7200, // FODMS FLIP    "man": 9535, //    "isode-dua": 17007, //   ]); +  +  + //! A single service registration. Used as the return value for the + //! @[lookup] method. + class Service(string name, int port, string protocol, string comment) + { +  protected string _sprintf(int flag) { +  if( flag == 'O' ) +  return "Service("+name+" "+port+"/"+protocol+")"; +  if( flag == 'd' ) +  return (string)port; +  return name; +  } +  protected bool `<(Service x ) { +  if( objectp(x) ) return x->port < port ? 1 : x->protocol > protocol; +  } +  protected bool `==(Service x) { +  if( objectp(x) ) return x->port == port && x->name == name && x->protocol == protocol; +  } +  protected int __hash() { return hash(name); } + } +  +  +  + //! If @[name] is not an indentifier in this module, return the first + //! matching protocol. This would be the first element in the array + //! returned by @[lookup] + Service|mixed `[](string name ) + { +  if( mixed res = predef::`->(this,name)) +  return res; +  array x = lookup(name); +  if( sizeof(x) ) +  return x[0]; +  return 0; + } +  + private mapping(string:array(Service)) services = ([]); +  + //! Return all ports registered for the specified name + //! This function also reads data from /etc/services if possible. + array(Service) lookup( string name ) + { +  if( !sizeof( services ) && file_stat("/etc/services") ) +  { +  foreach( (Stdio.read_file("/etc/services")||"")/"\n", string l ) +  { +  sscanf( l, "%s#", l ); +  l = String.trim(l); +  array tk = replace(l,"\t", " ")/" "-({""}); +  if( sizeof( tk ) > 1 && has_value( tk[1],"/") ) +  services[tk[0]] += ({ Service(tk[0],(int)(tk[1]/"/")[0],(tk[1]/"/")[1], tk[2..]*" ") }); +  } +  } +  array x = ({}); +  if( services[name] ) +  x+= services[name]; +  if( tcp[name] ) +  x+=({Service(name,tcp[name],"tcp","")}); +  else if( private_tcp[name] ) +  x+=({Service(name,private_tcp[name],"tcp","")}); +  if( udp[name] ) +  x+=({Service(name,tcp[name],"udp","")}); +  else if( private_udp[name] ) +  x+=({Service(name,private_udp[name],"udp","")}); +  return sort(Array.uniq(x)); + } +  + //! Return the first port registered for the specified name (the + //! lowest numbered tcp port, or if there is no tcp ports, the lowest + //! numbered udp port) + int port( string name ) + { +  array possible = lookup(name); +  if( sizeof( possible ) ) +  return possible[0]->port; + }