This provider uses parsedfile to parse entries in /etc/services. Because
we use composite keys we have to provide an individual match method to
find resources for a single record.

Signed-off-by: Stefan Schulte <stefan.schu...@taunusstein.net>
---
Local-branch: feature/next/5660N
 lib/puppet/provider/port/parsed.rb                 |  228 +---
 lib/puppet/type/port.rb                            |    6 +
 spec/fixtures/unit/provider/port/parsed/nonuniq    |    6 +
 .../unit/provider/port/parsed/realworld_linux      | 1179 ++++++++++++++++++++
 spec/fixtures/unit/provider/port/parsed/uniq       |    7 +
 spec/unit/provider/port/parsed_spec.rb             |  278 +++++
 6 files changed, 1534 insertions(+), 170 deletions(-)
 create mode 100644 spec/fixtures/unit/provider/port/parsed/nonuniq
 create mode 100644 spec/fixtures/unit/provider/port/parsed/realworld_linux
 create mode 100644 spec/fixtures/unit/provider/port/parsed/uniq
 create mode 100644 spec/unit/provider/port/parsed_spec.rb

diff --git a/lib/puppet/provider/port/parsed.rb 
b/lib/puppet/provider/port/parsed.rb
index 5c973b6..ae6fba7 100755
--- a/lib/puppet/provider/port/parsed.rb
+++ b/lib/puppet/provider/port/parsed.rb
@@ -1,173 +1,61 @@
 require 'puppet/provider/parsedfile'
 
-#services = nil
-#case Facter.value(:operatingsystem)
-#when "Solaris"; services = "/etc/inet/services"
-#else
-#    services = "/etc/services"
-#end
-#
-#Puppet::Type.type(:port).provide(:parsed,
-#    :parent => Puppet::Provider::ParsedFile,
-#    :default_target => services,
-#    :filetype => :flat
-#) do
-#    text_line :comment, :match => /^\s*#/
-#    text_line :blank, :match => /^\s*$/
-#
-#    # We're cheating horribly here -- we don't support ddp, because it assigns
-#    # the same number to already-used names, and the same name to different
-#    # numbers.
-#    text_line :ddp, :match => /^\S+\s+\d+\/ddp/
-#
-#    # Also, just ignore the lines on OS X that don't have service names.
-#    text_line :funky_darwin, :match => /^\s+\d+\//
-#
-#    # We have to manually parse the line, since it's so darn complicated.
-#    record_line :parsed, :fields => %w{name port protocols alias description},
-#        :optional => %w{alias description} do |line|
-#        if line =~ /\/ddp/
-#            raise "missed ddp in #{line}"
-#        end
-#        # The record might contain multiple port lines separated by \n.
-#        hashes = line.split("\n").collect { |l| parse_port(l) }
-#
-#        # It's easy if there's just one hash.
-#        if hashes.length == 1
-#            return hashes.shift
-#        end
-#
-#        # Else, merge the two records into one.
-#        return port_merge(*hashes)
-#    end
-#
-#    # Override how we split into lines, so that we always treat both protocol
-#    # lines as a single line.  This drastically simplifies merging the two 
lines
-#    # into one record.
-#    def self.lines(text)
-#        names = {}
-#        lines = []
-#
-#        # We organize by number, because that's apparently how the ports work.
-#        # You'll never be able to use Puppet to manage multiple entries
-#        # with the same name but different numbers, though.
-#        text.split("\n").each do |line|
-#            if line =~ /^([-\w]+)\s+(\d+)\/[^d]/ # We want to skip ddp proto 
stuff
-#                names[$1] ||= []
-#                names[$1] << line
-#                lines << [:special, $1]
-#            else
-#                lines << line
-#            end
-#        end
-#
-#        # Now, return each line in order, but join the ones with the same name
-#        lines.collect do |line|
-#            if line.is_a?(Array)
-#                name = line[1]
-#                if names[name]
-#                    t = names[name].join("\n")
-#                    names.delete(name)
-#                    t
-#                end
-#            else
-#                line
-#            end
-#        end.reject { |l| l.nil? }
-#    end
-#
-#    # Parse a single port line, returning a hash.
-#    def self.parse_port(line)
-#        hash = {}
-#        if line.sub!(/^(\S+)\s+(\d+)\/(\w+)\s*/, '')
-#            hash[:name] = $1
-#            hash[:number] = $2
-#            hash[:protocols] = [$3]
-#
-#            unless line == ""
-#                line.sub!(/^([^#]+)\s*/) do |value|
-#                    aliases = $1
-#
-#                    # Remove any trailing whitespace
-#                    aliases.strip!
-#                    unless aliases =~ /^\s*$/
-#                        hash[:alias] = aliases.split(/\s+/)
-#                    end
-#
-#                    ""
-#                end
-#
-#                line.sub!(/^\s*#\s*(.+)$/) do |value|
-#                    desc = $1
-#                    unless desc =~ /^\s*$/
-#                        hash[:description] = desc.sub(/\s*$/, '')
-#                    end
-#
-#                    ""
-#                end
-#            end
-#        else
-#            if line =~ /^\s+\d+/ and
-#                Facter["operatingsystem"].value == "Darwin"
-#                    #Puppet.notice "Skipping wonky OS X port entry %s" %
-#                    #    line.inspect
-#                    next
-#            end
-#            Puppet.notice "Ignoring unparseable line '#{line}' in 
#{self.target}"
-#        end
-#
-#        if hash.empty?
-#            return nil
-#        else
-#            return hash
-#        end
-#    end
-#
-#    # Merge two records into one.
-#    def self.port_merge(one, two)
-#        keys = [one.keys, two.keys].flatten.uniq
-#
-#        # We'll be returning the 'one' hash. so make any necessary 
modifications
-#        # to it.
-#        keys.each do |key|
-#            # The easy case
-#            if one[key] == two[key]
-#                next
-#            elsif one[key] and ! two[key]
-#                next
-#            elsif ! one[key] and two[key]
-#                one[key] = two[key]
-#            elsif one[key].is_a?(Array) and two[key].is_a?(Array)
-#                one[key] = [one[key], two[key]].flatten.uniq
-#            else
-#                # Keep the info from the first hash, so don't do anything
-#                #Puppet.notice "Cannot merge %s in %s with %s" %
-#                #    [key, one.inspect, two.inspect]
-#            end
-#        end
-#
-#        return one
-#    end
-#
-#    # Convert the current object into one or more services entry.
-#    def self.to_line(hash)
-#        unless hash[:record_type] == :parsed
-#            return super
-#        end
-#
-#        # Strangely, most sites seem to use tabs as separators.
-#        hash[:protocols].collect { |proto|
-#            str = "#{hash[:name]}\t\t#{hash[:number]}/#{proto}"
-#
-#            if value = hash[:alias] and value != :absent
-#                str += "\t\t#{value.join(" ")}"
-#            end
-#
-#            if value = hash[:description] and value != :absent
-#                str += "\t# #{value}"
-#            end
-#            str
-#        }.join("\n")
-#    end
-#end
+services = nil
+case Facter.value(:operatingsystem)
+when "Solaris"
+  services = "/etc/inet/services"
+else
+  services = "/etc/services"
+end
 
+Puppet::Type.type(:port).provide(:parsed, :parent => 
Puppet::Provider::ParsedFile,
+  :default_target => services, :filetype => :flat) do
+
+  text_line :comment, :match => /^\s*#/
+  text_line :blank, :match => /^\s*$/
+
+  record_line :parsed, :fields => %w{name number protocol port_aliases 
description},
+    :optional   => %w{port_aliases description},
+    :match      => /^(\S*)\s+(\d*)\/(\S*)\s*(.*?)?\s*(?:#\s*(.*))?$/,
+    :post_parse => proc { |hash|
+      hash[:protocol] = hash[:protocol].intern if hash[:protocol]
+      hash[:description] = '' if hash[:description].nil? or hash[:description] 
== :absent
+      unless hash[:port_aliases].nil? or hash[:port_aliases] == :absent
+        hash[:port_aliases].gsub!(/\s+/,' ') # Change delimiter
+      end
+    },
+    :to_line => proc { |hash|
+      [:name, :number, :protocol].each do |n|
+        raise Puppet::Error, "#{n} is a required attribute for port but not 
included in #{hash.inspect}" unless hash[n] and hash[n] != :absent
+      end
+
+      str = "#{hash[:name]}\t#{hash[:number]}/#{hash[:protocol]}"
+      if hash.include? :port_aliases and !hash[:port_aliases].nil? and 
hash[:port_aliases] != :absent
+        str += "\t#{hash[:port_aliases]}"
+      end
+      if hash.include? :description and !hash[:description].empty?
+        str += "\t# #{hash[:description]}"
+      end
+      str
+    }
+
+  # This method is important for prefetching and is called from the parsedfile 
provider.
+  # We get one record (one line of /etc/services) and a hash of resources 
(what the user
+  # specified in manifests). This hash is build in transaction.rb and uses 
uniqueness_key
+  # as a hashkey.
+  # Normally the parsedfileprovider loops over every record and uses 
record[:name] to
+  # find a corresponding resources[name]. That works if we only have one 
namevar
+  # because uniqueness_key of this resource will equal record[:name]. Because 
we use
+  # a composite key the parsedfile provider would never find a resource that 
matches
+  # a given record.
+  # Even worse: The parsedfileprovider cannot calculate the uniqueness_key of a
+  # specific record.
+  def self.match(record,resources)
+    # This should never happen but who knows
+    return false unless name = record[:name] and protocol = record[:protocol]
+
+    # We now calculate the uniqueness_key of the resource we want to find
+    uniq_key = [name, protocol]
+    resources[uniq_key] # will be nil if the user doesnt manage record
+  end
+end
diff --git a/lib/puppet/type/port.rb b/lib/puppet/type/port.rb
index f895785..a53d869 100755
--- a/lib/puppet/type/port.rb
+++ b/lib/puppet/type/port.rb
@@ -137,5 +137,11 @@ module Puppet
       end
     end
 
+    validate do
+      unless @parameters[:name] and @parameters[:protocol]
+        raise Puppet::Error, "Attributes 'name' and 'protocol' are mandatory"
+      end
+    end
+
   end
 end
diff --git a/spec/fixtures/unit/provider/port/parsed/nonuniq 
b/spec/fixtures/unit/provider/port/parsed/nonuniq
new file mode 100644
index 0000000..e4eb25a
--- /dev/null
+++ b/spec/fixtures/unit/provider/port/parsed/nonuniq
@@ -0,0 +1,6 @@
+# We test a few comments here
+# and anotherone
+telnet  23/tcp  # Telnet
+telnets 992/tcp # telnet protocol over TLS/SSL
+telnets 992/ud
+telnet  23/udp
diff --git a/spec/fixtures/unit/provider/port/parsed/realworld_linux 
b/spec/fixtures/unit/provider/port/parsed/realworld_linux
new file mode 100644
index 0000000..f7fd67d
--- /dev/null
+++ b/spec/fixtures/unit/provider/port/parsed/realworld_linux
@@ -0,0 +1,1179 @@
+# /etc/services
+#
+# Network services, Internet style
+#
+# Note that it is presently the policy of IANA to assign a single well-known
+# port number for both TCP and UDP; hence, most entries here have two entries
+# even if the protocol doesn't support UDP operations.
+#
+# Some References:
+# http://www.iana.org/assignments/port-numbers
+# http://www.freebsd.org/cgi/cvsweb.cgi/src/etc/services
+#
+# Each line describes one service, and is of the form:
+# service-name  port/protocol  [aliases ...]   [# comment]
+#
+# See services(5) for more info.
+#
+
+#
+# IANA Assignments [Well Known Ports]
+# The Well Known Ports are assigned by the IANA and on most systems can
+# only be used by system (or root) processes or by programs executed by
+# privileged users.
+# The range for assigned ports managed by the IANA is 0-1023.
+#
+tcpmux 1/tcp   # TCP port service multiplexer
+tcpmux 1/udp
+compressnet    2/tcp   # Management Utility
+compressnet    2/udp
+compressnet    3/tcp   # Compression Process
+compressnet    3/udp
+rje    5/tcp   # Remote Job Entry
+rje    5/udp
+echo   7/tcp   # Echo
+echo   7/udp
+discard        9/tcp   sink null       # Discard
+discard        9/udp   sink null
+systat 11/tcp  users   # Active Users
+systat 11/udp  users
+daytime        13/tcp  # Daytime (RFC 867)
+daytime        13/udp
+#netstat       15/tcp                          # (was once asssigned, no more)
+qotd   17/tcp  quote   # Quote of the Day
+qotd   17/udp  quote
+msp    18/tcp  # Message Send Protocol
+msp    18/udp
+chargen        19/tcp  ttytst source   # Character Generator
+chargen        19/udp  ttytst source
+ftp-data       20/tcp  # File Transfer [Default Data]
+ftp-data       20/udp
+ftp    21/tcp  # File Transfer [Control]
+ftp    21/udp  fsp fspd
+ssh    22/tcp  # SSH Remote Login Protocol
+ssh    22/udp
+telnet 23/tcp  # Telnet
+telnet 23/udp
+# private      24/tcp                          # any private mail system
+# private      24/udp
+smtp   25/tcp  mail    # Simple Mail Transfer
+smtp   25/udp
+nsw-fe 27/tcp  # NSW User System FE
+nsw-fe 27/udp
+msg-icp        29/tcp  # MSG ICP
+msg-icp        29/udp
+msg-auth       31/tcp  # MSG Authentication
+msg-auth       31/udp
+dsp    33/tcp  # Display Support Protocol
+dsp    33/udp
+# private      35/tcp                          # any private printer server
+# private      35/udp
+time   37/tcp  timserver
+time   37/udp  timserver
+rap    38/tcp  # Route Access Protocol
+rap    38/udp
+rlp    39/tcp  resource        # Resource Location Protocol
+rlp    39/udp  resource
+graphics       41/tcp  # Graphics
+graphics       41/udp
+nameserver     42/tcp  name    # Host Name Server
+nameserver     42/udp  name
+nicname        43/tcp  whois   # Who Is
+nicname        43/udp  whois
+mpm-flags      44/tcp  # MPM FLAGS Protocol
+mpm-flags      44/udp
+mpm    45/tcp  # Message Processing Module [recv]
+mpm    45/udp
+mpm-snd        46/tcp  # MPM [default send]
+mpm-snd        46/udp
+ni-ftp 47/tcp  # NI FTP
+ni-ftp 47/udp
+auditd 48/tcp  # Digital Audit Daemon
+auditd 48/udp
+tacacs 49/tcp  # Login Host Protocol (TACACS)
+tacacs 49/udp
+re-mail-ck     50/tcp  # Remote Mail Checking Protocol
+re-mail-ck     50/udp
+domain 53/tcp  # Domain Name Server
+domain 53/udp
+xns-ch 54/tcp  # XNS Clearinghouse
+xns-ch 54/udp
+isi-gl 55/tcp  # ISI Graphics Language
+isi-gl 55/udp
+xns-auth       56/tcp  # XNS Authentication
+xns-auth       56/udp
+# private      57/tcp                          # any private terminal access
+# private      57/udp
+xns-mail       58/tcp  # XNS Mail
+xns-mail       58/udp
+# private      59/tcp                          # any private file service
+# private      59/udp
+ni-mail        61/tcp  # NI MAIL
+ni-mail        61/udp
+acas   62/tcp  # ACA Services
+acas   62/udp
+whois++        63/tcp  # whois++
+whois++        63/udp
+covia  64/tcp  # Communications Integrator (CI)
+covia  64/udp
+tacacs-ds      65/tcp  # TACACS-Database Service
+tacacs-ds      65/udp
+sql*net        66/tcp  # Oracle SQL*NET
+sql*net        66/udp
+bootps 67/tcp  # Bootstrap Protocol Server (BOOTP)
+bootps 67/udp
+bootpc 68/tcp  # Bootstrap Protocol Client (BOOTP)
+bootpc 68/udp
+tftp   69/tcp  # Trivial File Transfer
+tftp   69/udp
+gopher 70/tcp  # Gopher
+gopher 70/udp
+netrjs-1       71/tcp  # Remote Job Service
+netrjs-1       71/udp
+netrjs-2       72/tcp
+netrjs-2       72/udp
+netrjs-3       73/tcp
+netrjs-3       73/udp
+netrjs-4       74/tcp
+netrjs-4       74/udp
+# private      75/tcp                          # any private dial out service
+# private      75/udp
+deos   76/tcp  # Distributed External Object Store
+deos   76/udp
+# private      77/tcp                          # any private RJE service
+# private      77/udp
+vettcp 78/tcp  # vettcp
+vettcp 78/udp
+finger 79/tcp  # Finger
+finger 79/udp
+http   80/tcp  www www-http    # World Wide Web HTTP
+http   80/udp  www www-http
+hosts2-ns      81/tcp  # HOSTS2 Name Server
+hosts2-ns      81/udp
+xfer   82/tcp  # XFER Utility
+xfer   82/udp
+mit-ml-dev     83/tcp  # MIT ML Device
+mit-ml-dev     83/udp
+ctf    84/tcp  # Common Trace Facility
+ctf    84/udp
+mit-ml-dev     85/tcp  # MIT ML Device
+mit-ml-dev     85/udp
+mfcobol        86/tcp  # Micro Focus Cobol
+mfcobol        86/udp
+# private      87/tcp                          # any private terminal link
+# private      87/udp
+kerberos       88/tcp  kerberos5 krb5  # Kerberos
+kerberos       88/udp  kerberos5 krb5
+su-mit-tg      89/tcp  # SU/MIT Telnet Gateway
+su-mit-tg      89/udp
+dnsix  90/tcp  # DNSIX Securit Attribute Token Map
+dnsix  90/udp
+mit-dov        91/tcp  # MIT Dover Spooler
+mit-dov        91/udp
+npp    92/tcp  # Network Printing Protocol
+npp    92/udp
+dcp    93/tcp  # Device Control Protocol
+dcp    93/udp
+objcall        94/tcp  # Tivoli Object Dispatcher
+objcall        94/udp
+supdup 95/tcp  # SUPDUP
+supdup 95/udp
+dixie  96/tcp  # DIXIE Protocol Specification
+dixie  96/udp
+swift-rvf      97/tcp  # Swift Remote Virtural File Protocol
+swift-rvf      97/udp
+tacnews        98/tcp  linuxconf       # TAC News
+tacnews        98/udp
+metagram       99/tcp  # Metagram Relay
+metagram       99/udp
+#newacct       100/tcp                         # [unauthorized use]
+hostname       101/tcp hostnames       # NIC Host Name Server
+hostname       101/udp hostnames
+iso-tsap       102/tcp tsap    # ISO-TSAP Class 0
+iso-tsap       102/udp tsap
+gppitnp        103/tcp # Genesis Point-to-Point Trans Net
+gppitnp        103/udp
+acr-nema       104/tcp # ACR-NEMA Digital Imag. & Comm. 300
+acr-nema       104/udp
+cso    105/tcp csnet-ns cso-ns # CCSO name server protocol
+cso    105/udp csnet-ns cso-ns
+3com-tsmux     106/tcp poppassd        # 3COM-TSMUX
+3com-tsmux     106/udp poppassd        # Eudora: Unauthorized use by insecure 
poppassd protocol
+rtelnet        107/tcp # Remote Telnet Service
+rtelnet        107/udp
+snagas 108/tcp # SNA Gateway Access Server
+snagas 108/udp
+pop2   109/tcp pop-2 postoffice        # Post Office Protocol - Version 2
+pop2   109/udp pop-2
+pop3   110/tcp pop-3   # Post Office Protocol - Version 3
+pop3   110/udp pop-3
+sunrpc 111/tcp portmapper rpcbind      # SUN Remote Procedure Call
+sunrpc 111/udp portmapper rpcbind
+mcidas 112/tcp # McIDAS Data Transmission Protocol
+mcidas 112/udp
+auth   113/tcp authentication tap ident        # Authentication Service
+auth   113/udp
+sftp   115/tcp # Simple File Transfer Protocol
+sftp   115/udp
+ansanotify     116/tcp # ANSA REX Notify
+ansanotify     116/udp
+uucp-path      117/tcp # UUCP Path Service
+uucp-path      117/udp
+sqlserv        118/tcp # SQL Services
+sqlserv        118/udp
+nntp   119/tcp readnews untp   # Network News Transfer Protocol
+nntp   119/udp readnews untp
+cfdptkt        120/tcp # CFDPTKT
+cfdptkt        120/udp
+erpc   121/tcp # Encore Expedited Remote Pro.Call
+erpc   121/udp
+smakynet       122/tcp # SMAKYNET
+smakynet       122/udp
+ntp    123/tcp # Network Time Protocol
+ntp    123/udp
+ansatrader     124/tcp # ANSA REX Trader
+ansatrader     124/udp
+locus-map      125/tcp # Locus PC-Interface Net Map Ser
+locus-map      125/udp
+nxedit 126/tcp unitary # NXEdit
+nxedit 126/udp unitary # Unisys Unitary Login
+locus-con      127/tcp # Locus PC-Interface Conn Server
+locus-con      127/udp
+gss-xlicen     128/tcp # GSS X License Verification
+gss-xlicen     128/udp
+pwdgen 129/tcp # Password Generator Protocol
+pwdgen 129/udp
+cisco-fna      130/tcp # cisco FNATIVE
+cisco-fna      130/udp
+cisco-tna      131/tcp # cisco TNATIVE
+cisco-tna      131/udp
+cisco-sys      132/tcp # cisco SYSMAINT
+cisco-sys      132/udp
+statsrv        133/tcp # Statistics Service
+statsrv        133/udp
+ingres-net     134/tcp # INGRES-NET Service
+ingres-net     134/udp
+epmap  135/tcp loc-srv # DCE endpoint resolution
+epmap  135/udp loc-srv
+profile        136/tcp # PROFILE Naming System
+profile        136/udp
+netbios-ns     137/tcp # NETBIOS Name Service
+netbios-ns     137/udp
+netbios-dgm    138/tcp # NETBIOS Datagram Service
+netbios-dgm    138/udp
+netbios-ssn    139/tcp # NETBIOS Session Service
+netbios-ssn    139/udp
+emfis-data     140/tcp # EMFIS Data Service
+emfis-data     140/udp
+emfis-cntl     141/tcp # EMFIS Control Service
+emfis-cntl     141/udp
+imap   143/tcp imap2   # Internet Message Access Protocol
+imap   143/udp imap2
+uma    144/tcp # Universal Management Architecture
+uma    144/udp
+uaac   145/tcp # UAAC Protocol
+uaac   145/udp
+iso-tp0        146/tcp # ISO-TP0
+iso-tp0        146/udp
+iso-ip 147/tcp # ISO-IP
+iso-ip 147/udp
+jargon 148/tcp # Jargon
+jargon 148/udp
+aed-512        149/tcp # AED 512 Emulation Service
+aed-512        149/udp
+sql-net        150/tcp # SQL-NET
+sql-net        150/udp
+hems   151/tcp # HEMS
+hems   151/udp
+bftp   152/tcp # Background File Transfer Program
+bftp   152/udp
+sgmp   153/tcp # SGMP
+sgmp   153/udp
+netsc-prod     154/tcp # NETSC
+netsc-prod     154/udp
+netsc-dev      155/tcp
+netsc-dev      155/udp
+sqlsrv 156/tcp # SQL Service
+sqlsrv 156/udp
+knet-cmp       157/tcp # KNET/VM Command/Message Protocol
+knet-cmp       157/udp
+pcmail-srv     158/tcp # PCMail Server
+pcmail-srv     158/udp
+nss-routing    159/tcp # NSS-Routing
+nss-routing    159/udp
+sgmp-traps     160/tcp # SGMP-TRAPS
+sgmp-traps     160/udp
+snmp   161/tcp # Simple Net Mgmt Proto
+snmp   161/udp
+snmptrap       162/tcp snmp-trap       # Traps for SNMP
+snmptrap       162/udp snmp-trap
+cmip-man       163/tcp # CMIP/TCP Manager
+cmip-man       163/udp
+cmip-agent     164/tcp # CMIP/TCP Agent
+cmip-agent     164/udp
+xns-courier    165/tcp # Xerox
+xns-courier    165/udp
+s-net  166/tcp # Sirius Systems
+s-net  166/udp
+namp   167/tcp # NAMP
+namp   167/udp
+rsvd   168/tcp # RSVD
+rsvd   168/udp
+send   169/tcp # SEND
+send   169/udp
+print-srv      170/tcp # Network PostScript
+print-srv      170/udp
+multiplex      171/tcp # Network Innovations Multiplex
+multiplex      171/udp
+cl/1   172/tcp # Network Innovations CL/1
+cl/1   172/udp
+xyplex-mux     173/tcp # Xyplex
+xyplex-mux     173/udp
+mailq  174/tcp # Mailer transport queue for Zmailer
+mailq  174/udp
+vmnet  175/tcp # VMNET
+vmnet  175/udp
+genrad-mux     176/tcp # GENRAD-MUX
+genrad-mux     176/udp
+xdmcp  177/tcp # X Display Manager Control Protocol
+xdmcp  177/udp
+nextstep       178/tcp NeXTStep NextStep       # NextStep Window Server
+nextstep       178/udp NeXTStep NextStep
+bgp    179/tcp # Border Gateway Protocol
+bgp    179/udp
+ris    180/tcp # Intergraph
+ris    180/udp
+unify  181/tcp # Unify
+unify  181/udp
+audit  182/tcp # Unisys Audit SITP
+audit  182/udp
+ocbinder       183/tcp # OCBinder
+ocbinder       183/udp
+ocserver       184/tcp # OCServer
+ocserver       184/udp
+remote-kis     185/tcp # Remote-KIS
+remote-kis     185/udp
+kis    186/tcp # KIS Protocol
+kis    186/udp
+aci    187/tcp # Application Communication Interface
+aci    187/udp
+mumps  188/tcp # Plus Five's MUMPS
+mumps  188/udp
+qft    189/tcp # Queued File Transport
+qft    189/udp
+gacp   190/tcp # Gateway Access Control Protocol
+gacp   190/udp
+prospero       191/tcp # Prospero Directory Service
+prospero       191/udp
+osu-nms        192/tcp # OSU Network Monitoring System
+osu-nms        192/udp
+srmp   193/tcp # Spider Remote Monitoring Protocol
+srmp   193/udp
+irc    194/tcp # Internet Relay Chat Protocol
+irc    194/udp
+dn6-nlm-aud    195/tcp # DNSIX Network Level Module Audit
+dn6-nlm-aud    195/udp
+dn6-smm-red    196/tcp # DNSIX Session Mgt Module Audit Redir
+dn6-smm-red    196/udp
+dls    197/tcp # Directory Location Service
+dls    197/udp
+dls-mon        198/tcp # Directory Location Service Monitor
+dls-mon        198/udp
+smux   199/tcp # SNMP Unix Multiplexer
+smux   199/udp
+src    200/tcp # IBM System Resource Controller
+src    200/udp
+at-rtmp        201/tcp # AppleTalk Routing Maintenance
+at-rtmp        201/udp
+at-nbp 202/tcp # AppleTalk Name Binding
+at-nbp 202/udp
+at-echo        204/tcp # AppleTalk Echo
+at-echo        204/udp
+at-zis 206/tcp # AppleTalk Zone Information
+at-zis 206/udp
+qmtp   209/tcp # The Quick Mail Transfer Protocol
+qmtp   209/udp
+z39.50 210/tcp wais z3950      # ANSI Z39.50
+z39.50 210/udp wais z3950
+914c/g 211/tcp # Texas Instruments 914C/G Terminal
+914c/g 211/udp
+anet   212/tcp # ATEXSSTR
+anet   212/udp
+ipx    213/tcp # IPX
+ipx    213/udp
+imap3  220/tcp # Interactive Mail Access
+imap3  220/udp
+link   245/tcp # ttylink
+link   245/udp
+pawserv        345/tcp # Perf Analysis Workbench
+pawserv        345/udp
+zserv  346/tcp # Zebra server
+zserv  346/udp
+fatserv        347/tcp # Fatmen Server
+fatserv        347/udp
+scoi2odialog   360/tcp # scoi2odialog
+scoi2odialog   360/udp
+semantix       361/tcp # Semantix
+semantix       361/udp
+srssend        362/tcp # SRS Send
+srssend        362/udp
+rsvp_tunnel    363/tcp # RSVP Tunnel
+rsvp_tunnel    363/udp
+aurora-cmgr    364/tcp # Aurora CMGR
+aurora-cmgr    364/udp
+dtk    365/tcp # Deception Tool Kit
+dtk    365/udp
+odmr   366/tcp # ODMR
+odmr   366/udp
+rpc2portmap    369/tcp # Coda portmapper
+rpc2portmap    369/udp
+codaauth2      370/tcp # Coda authentication server
+codaauth2      370/udp
+clearcase      371/tcp # Clearcase
+clearcase      371/udp
+ulistproc      372/tcp ulistserv       # UNIX Listserv
+ulistproc      372/udp ulistserv
+ldap   389/tcp # Lightweight Directory Access Protocol
+ldap   389/udp
+imsp   406/tcp # Interactive Mail Support Protocol
+imsp   406/udp
+svrloc 427/tcp # Server Location
+svrloc 427/udp
+mobileip-agent 434/tcp # MobileIP-Agent
+mobileip-agent 434/udp
+mobilip-mn     435/tcp # MobilIP-MN
+mobilip-mn     435/udp
+https  443/tcp # MCom
+https  443/udp
+snpp   444/tcp # Simple Network Paging Protocol
+snpp   444/udp
+microsoft-ds   445/tcp Microsoft-DS
+microsoft-ds   445/udp Microsoft-DS
+kpasswd        464/tcp kpwd    # Kerberos "passwd"
+kpasswd        464/udp kpwd
+urd    465/tcp smtps ssmtp     # URL Rendesvous Directory for SSM / smtp 
protocol over TLS/SSL
+igmpv3lite     465/udp smtps ssmtp     # IGMP over UDP for SSM
+photuris       468/tcp
+photuris       468/udp
+rcp    469/tcp # Radio Control Protocol
+rcp    469/udp
+saft   487/tcp # Simple Asynchronous File Transfer
+saft   487/udp
+gss-http       488/tcp
+gss-http       488/udp
+pim-rp-disc    496/tcp
+pim-rp-disc    496/udp
+isakmp 500/tcp # IPsec - Internet Security Association and Key Management 
Protocol
+isakmp 500/udp
+exec   512/tcp # remote process execution
+comsat 512/udp biff    # notify users of new mail received
+login  513/tcp # remote login a la telnet
+who    513/udp whod    # who's logged in to machines
+shell  514/tcp cmd     # no passwords used
+syslog 514/udp
+printer        515/tcp spooler # line printer spooler
+printer        515/udp spooler
+videotex       516/tcp
+videotex       516/udp
+talk   517/tcp # like tenex link
+talk   517/udp
+ntalk  518/tcp
+ntalk  518/udp
+utime  519/tcp unixtime
+utime  519/udp unixtime
+efs    520/tcp # extended file name server
+router 520/udp route routed    # local routing process
+ripng  521/tcp
+ripng  521/udp
+ulp    522/tcp
+ulp    522/udp
+ibm-db2        523/tcp
+ibm-db2        523/udp
+ncp    524/tcp
+ncp    524/udp
+timed  525/tcp timeserver
+timed  525/udp timeserver
+tempo  526/tcp newdate
+tempo  526/udp newdate
+courier        530/tcp rpc
+courier        530/udp rpc
+conference     531/tcp chat
+conference     531/udp chat
+netnews        532/tcp readnews
+netnews        532/udp readnews
+netwall        533/tcp # -for emergency broadcasts
+netwall        533/udp
+mm-admin       534/tcp # MegaMedia Admin
+mm-admin       534/udp
+iiop   535/tcp
+iiop   535/udp
+opalis-rdv     536/tcp
+opalis-rdv     536/udp
+nmsp   537/tcp # Networked Media Streaming Protocol
+nmsp   537/udp
+gdomap 538/tcp # GNUstep distributed objects
+gdomap 538/udp
+uucp   540/tcp uucpd   # uucp daemon
+uucp   540/udp uucpd
+klogin 543/tcp # Kerberized `rlogin' (v5)
+klogin 543/udp
+kshell 544/tcp krcmd   # Kerberized `rsh' (v5)
+kshell 544/udp krcmd
+appleqtcsrvr   545/tcp
+appleqtcsrvr   545/udp
+dhcpv6-client  546/tcp # DHCPv6 Client
+dhcpv6-client  546/udp
+dhcpv6-server  547/tcp # DHCPv6 Server
+dhcpv6-server  547/udp
+afpovertcp     548/tcp # AFP over TCP
+afpovertcp     548/udp
+rtsp   554/tcp # Real Time Stream Control Protocol
+rtsp   554/udp
+dsf    555/tcp
+dsf    555/udp
+remotefs       556/tcp rfs_server rfs  # Brunhoff remote filesystem
+remotefs       556/udp rfs_server rfs
+nntps  563/tcp snntp   # NNTP over SSL
+nntps  563/udp snntp
+9pfs   564/tcp # plan 9 file service
+9pfs   564/udp
+whoami 565/tcp
+whoami 565/udp
+submission     587/tcp # mail message submission
+submission     587/udp
+http-alt       591/tcp # FileMaker, Inc. - HTTP Alternate
+http-alt       591/udp
+nqs    607/tcp # Network Queuing system
+nqs    607/udp
+npmp-local     610/tcp dqs313_qmaster  # npmp-local / DQS
+npmp-local     610/udp dqs313_qmaster
+npmp-gui       611/tcp dqs313_execd    # npmp-gui / DQS
+npmp-gui       611/udp dqs313_execd
+hmmp-ind       612/tcp dqs313_intercell        # HMMP Indication / DQS
+hmmp-ind       612/udp dqs313_intercell
+cryptoadmin    624/tcp # Crypto Admin
+cryptoadmin    624/udp
+dec_dlm        625/tcp # DEC DLM
+dec_dlm        625/udp
+asia   626/tcp
+asia   626/udp
+passgo-tivoli  627/tcp # PassGo Tivoli
+passgo-tivoli  627/udp
+qmqp   628/tcp # Qmail QMQP
+qmqp   628/udp
+3com-amp3      629/tcp
+3com-amp3      629/udp
+rda    630/tcp
+rda    630/udp
+ipp    631/tcp # Internet Printing Protocol
+ipp    631/udp
+ldaps  636/tcp # LDAP over SSL
+ldaps  636/udp
+tinc   655/tcp # TINC control port
+tinc   655/udp
+acap   674/tcp # Application Configuration Access Protocol
+acap   674/udp
+asipregistry   687/tcp
+asipregistry   687/udp
+realm-rusd     688/tcp # ApplianceWare managment protocol
+realm-rusd     688/udp
+nmap   689/tcp # Opensource Network Mapper
+nmap   689/udp
+ha-cluster     694/tcp # Heartbeat HA-cluster
+ha-cluster     694/udp
+epp    700/tcp # Extensible Provisioning Protocol
+epp    700/udp
+iris-beep      702/tcp # IRIS over BEEP
+iris-beep      702/udp
+silc   706/tcp # SILC
+silc   706/udp
+kerberos-adm   749/tcp # Kerberos `kadmin' (v5)
+kerberos-adm   749/udp
+kerberos-iv    750/tcp kerberos4 kdc   # Kerberos (server)
+kerberos-iv    750/udp kerberos4 kdc
+pump   751/tcp kerberos_master
+pump   751/udp kerberos_master # Kerberos authentication
+qrh    752/tcp passwd_server
+qrh    752/udp passwd_server   # Kerberos passwd server
+rrh    753/tcp
+rrh    753/udp
+tell   754/tcp send krb_prop krb5_prop # Kerberos slave propagation
+tell   754/udp send
+nlogin 758/tcp
+nlogin 758/udp
+con    759/tcp
+con    759/udp
+ns     760/tcp krbupdate kreg  # Kerberos registration
+ns     760/udp
+webster        765/tcp # Network dictionary
+webster        765/udp
+phonebook      767/tcp # Network phonebook
+phonebook      767/udp
+rsync  873/tcp # rsync
+rsync  873/udp
+ftps-data      989/tcp # ftp protocol, data, over TLS/SSL
+ftps-data      989/udp
+ftps   990/tcp # ftp protocol, control, over TLS/SSL
+ftps   990/udp
+nas    991/tcp # Netnews Administration System
+nas    991/udp
+telnets        992/tcp # telnet protocol over TLS/SSL
+telnets        992/udp
+imaps  993/tcp # imap4 protocol over TLS/SSL
+imaps  993/udp
+ircs   994/tcp # irc protocol over TLS/SSL
+ircs   994/udp
+pop3s  995/tcp # pop3 protocol over TLS/SSL
+pop3s  995/udp
+
+#
+# IANA Assignments [Registered Ports]
+#
+# The Registered Ports are listed by the IANA and on most systems can be
+# used by ordinary user processes or programs executed by ordinary
+# users.
+# Ports are used in the TCP [RFC793] to name the ends of logical
+# connections which carry long term conversations.  For the purpose of
+# providing services to unknown callers, a service contact port is
+# defined.  This list specifies the port used by the server process as
+# its contact port.
+# The IANA registers uses of these ports as a convenience to the
+# community.
+# To the extent possible, these same port assignments are used with the
+# UDP [RFC768].
+# The Registered Ports are in the range 1024-49151.
+#
+imgames        1077/tcp
+imgames        1077/udp
+socks  1080/tcp        # socks proxy server
+socks  1080/udp
+rmiregistry    1099/tcp        # Java RMI Registry
+rmiregistry    1099/udp
+bnetgame       1119/tcp        # Battle.net Chat/Game Protocol
+bnetgame       1119/udp
+bnetfile       1120/tcp        # Battle.net File Transfer Protocol
+bnetfile       1120/udp
+hpvmmcontrol   1124/tcp        # HP VMM Control
+hpvmmcontrol   1124/udp
+hpvmmagent     1125/tcp        # HP VMM Agent
+hpvmmagent     1125/udp
+hpvmmdata      1126/tcp        # HP VMM Agent
+hpvmmdata      1126/udp
+resacommunity  1154/tcp        # Community Service
+resacommunity  1154/udp
+3comnetman     1181/tcp        # 3Com Net Management
+3comnetman     1181/udp
+mysql-cluster  1186/tcp        # MySQL Cluster Manager
+mysql-cluster  1186/udp
+alias  1187/tcp        # Alias Service
+alias  1187/udp
+openvpn        1194/tcp        # OpenVPN
+openvpn        1194/udp
+kazaa  1214/tcp        # KAZAA
+kazaa  1214/udp
+bvcontrol      1236/tcp        rmtcfg  # Gracilis Packeten remote config server
+bvcontrol      1236/udp        rmtcfg
+nessus 1241/tcp        # Nessus vulnerability assessment scanner
+nessus 1241/udp
+h323hostcallsc 1300/tcp        # H323 Host Call Secure
+h323hostcallsc 1300/udp
+lotusnote      1352/tcp        # Lotus Note
+lotusnote      1352/udp
+ms-sql-s       1433/tcp        # Microsoft-SQL-Server
+ms-sql-s       1433/udp
+ms-sql-m       1434/tcp        # Microsoft-SQL-Monitor
+ms-sql-m       1434/udp
+ica    1494/tcp        # Citrix ICA Client
+ica    1494/udp
+wins   1512/tcp        # Microsoft's Windows Internet Name Service
+wins   1512/udp
+ingreslock     1524/tcp
+ingreslock     1524/udp
+prospero-np    1525/tcp        # Prospero non-privileged
+prospero-np    1525/udp
+datametrics    1645/tcp        old-radius      # datametrics / old radius entry
+datametrics    1645/udp        old-radius
+sa-msg-port    1646/tcp        old-radacct     # sa-msg-port / old radacct 
entry
+sa-msg-port    1646/udp        old-radacct
+rsap   1647/tcp
+rsap   1647/udp
+concurrent-lm  1648/tcp
+concurrent-lm  1648/udp
+kermit 1649/tcp
+kermit 1649/udp
+l2tp   1701/tcp
+l2tp   1701/udp
+h323gatedisc   1718/tcp
+h323gatedisc   1718/udp
+h323gatestat   1719/tcp
+h323gatestat   1719/udp
+h323hostcall   1720/tcp
+h323hostcall   1720/udp
+iberiagames    1726/tcp
+iberiagames    1726/udp
+gamegen1       1738/tcp
+gamegen1       1738/udp
+tftp-mcast     1758/tcp
+tftp-mcast     1758/udp
+hello  1789/tcp
+hello  1789/udp
+radius 1812/tcp        # Radius
+radius 1812/udp
+radius-acct    1813/tcp        radacct # Radius Accounting
+radius-acct    1813/udp        radacct
+mtp    1911/tcp        # Starlight Networks Multimedia Transport Protocol
+mtp    1911/udp
+egs    1926/tcp        # Evolution Game Server
+egs    1926/udp
+unix-status    1957/tcp        # remstats unix-status server
+unix-status    1957/udp
+hsrp   1985/tcp        # Hot Standby Router Protocol
+hsrp   1985/udp
+licensedaemon  1986/tcp        # cisco license management
+licensedaemon  1986/udp
+tr-rsrb-p1     1987/tcp        # cisco RSRB Priority 1 port
+tr-rsrb-p1     1987/udp
+tr-rsrb-p2     1988/tcp        # cisco RSRB Priority 2 port
+tr-rsrb-p2     1988/udp
+tr-rsrb-p3     1989/tcp        # cisco RSRB Priority 3 port
+tr-rsrb-p3     1989/udp
+stun-p1        1990/tcp        # cisco STUN Priority 1 port
+stun-p1        1990/udp
+stun-p2        1991/tcp        # cisco STUN Priority 2 port
+stun-p2        1991/udp
+stun-p3        1992/tcp        # cisco STUN Priority 3 port
+stun-p3        1992/udp
+snmp-tcp-port  1994/tcp        # cisco SNMP TCP port
+snmp-tcp-port  1994/udp
+stun-port      1995/tcp        # cisco serial tunnel port
+stun-port      1995/udp
+perf-port      1996/tcp        # cisco Remote SRB port
+perf-port      1996/udp
+gdp-port       1997/tcp        # cisco Gateway Discovery Protocol
+gdp-port       1997/udp
+x25-svc-port   1998/tcp        # cisco X.25 service (XOT)
+x25-svc-port   1998/udp
+tcp-id-port    1999/tcp        # cisco identification port
+tcp-id-port    1999/udp
+cisco-sccp     2000/tcp        sieve   # Cisco SCCP
+cisco-sccp     2000/udp        sieve
+nfs    2049/tcp        # Network File System
+nfs    2049/udp
+radsec 2083/tcp        # Secure Radius Service
+radsec 2083/udp
+gnunet 2086/tcp        # GNUnet
+gnunet 2086/udp
+rtcm-sc104     2101/tcp        # RTCM SC-104
+rtcm-sc104     2101/udp
+zephyr-srv     2102/tcp        # Zephyr server
+zephyr-srv     2102/udp
+zephyr-clt     2103/tcp        # Zephyr serv-hm connection
+zephyr-clt     2103/udp
+zephyr-hm      2104/tcp        # Zephyr hostmanager
+zephyr-hm      2104/udp
+eyetv  2170/tcp        # EyeTV Server Port
+eyetv  2170/udp
+msfw-storage   2171/tcp        # MS Firewall Storage
+msfw-storage   2171/udp
+msfw-s-storage 2172/tcp        # MS Firewall SecureStorage
+msfw-s-storage 2172/udp
+msfw-replica   2173/tcp        # MS Firewall Replication
+msfw-replica   2173/udp
+msfw-array     2174/tcp        # MS Firewall Intra Array
+msfw-array     2174/udp
+airsync        2175/tcp        # Microsoft Desktop AirSync Protocol
+airsync        2175/udp
+rapi   2176/tcp        # Microsoft ActiveSync Remote API
+rapi   2176/udp
+qwave  2177/tcp        # qWAVE Bandwidth Estimate
+qwave  2177/udp
+tivoconnect    2190/tcp        # TiVoConnect Beacon
+tivoconnect    2190/udp
+tvbus  2191/tcp        # TvBus Messaging
+tvbus  2191/udp
+mysql-im       2273/tcp        # MySQL Instance Manager
+mysql-im       2273/udp
+dict-lookup    2289/tcp        # Lookup dict server
+dict-lookup    2289/udp
+redstorm_join  2346/tcp        # Game Connection Port
+redstorm_join  2346/udp
+redstorm_find  2347/tcp        # Game Announcement and Location
+redstorm_find  2347/udp
+redstorm_info  2348/tcp        # Information to query for game status
+redstorm_info  2348/udp
+cvspserver     2401/tcp        # CVS client/server operations
+cvspserver     2401/udp
+venus  2430/tcp        # codacon port
+venus  2430/udp
+venus-se       2431/tcp        # tcp side effects
+venus-se       2431/udp
+codasrv        2432/tcp        # not used
+codasrv        2432/udp
+codasrv-se     2433/tcp        # tcp side effects
+codasrv-se     2433/udp
+netadmin       2450/tcp
+netadmin       2450/udp
+netchat        2451/tcp
+netchat        2451/udp
+snifferclient  2452/tcp
+snifferclient  2452/udp
+ppcontrol      2505/tcp        # PowerPlay Control
+ppcontrol      2505/udp
+lstp   2559/tcp
+lstp   2559/udp
+mon    2583/tcp
+mon    2583/udp
+hpstgmgr       2600/tcp        zebrasrv
+hpstgmgr       2600/udp        zebrasrv
+discp-client   2601/tcp        zebra   # discp client
+discp-client   2601/udp        zebra
+discp-server   2602/tcp        ripd    # discp server
+discp-server   2602/udp        ripd
+servicemeter   2603/tcp        ripngd  # Service Meter
+servicemeter   2603/udp        ripngd
+nsc-ccs        2604/tcp        ospfd   # NSC CCS
+nsc-ccs        2604/udp        ospfd
+nsc-posa       2605/tcp        bgpd    # NSC POSA
+nsc-posa       2605/udp        bgpd
+netmon 2606/tcp        ospf6d  # Dell Netmon
+netmon 2606/udp        ospf6d
+connection     2607/tcp        # Dell Connection
+connection     2607/udp
+wag-service    2608/tcp        # Wag Service
+wag-service    2608/udp
+dict   2628/tcp        # Dictionary server
+dict   2628/udp
+exce   2769/tcp        # eXcE
+exce   2769/udp
+dvr-esm        2804/tcp        # March Networks Digital Video Recorders and 
Enterprise Service Manager products
+dvr-esm        2804/udp
+corbaloc       2809/tcp        # CORBA LOC
+corbaloc       2809/udp
+ndtp   2882/tcp        # Network Dictionary Transfer Protocol
+ndtp   2882/udp
+gamelobby      2914/tcp        # Game Lobby
+gamelobby      2914/udp
+gds_db 3050/tcp        # InterBase server
+gds_db 3050/udp
+xbox   3074/tcp        # Xbox game port
+xbox   3074/udp
+icpv2  3130/tcp        icp     # Internet Cache Protocol (Squid)
+icpv2  3130/udp        icp
+nm-game-admin  3148/tcp        # NetMike Game Administrator
+nm-game-admin  3148/udp
+nm-game-server 3149/tcp        # NetMike Game Server
+nm-game-server 3149/udp
+mysql  3306/tcp        # MySQL
+mysql  3306/udp
+sftu   3326/tcp
+sftu   3326/udp
+trnsprntproxy  3346/tcp        # Transparent Proxy
+trnsprntproxy  3346/udp
+ms-wbt-server  3389/tcp        rdp     # MS WBT Server
+ms-wbt-server  3389/udp        rdp     # Microsoft Remote Desktop Protocol
+prsvp  3455/tcp        # RSVP Port
+prsvp  3455/udp
+nut    3493/tcp        # Network UPS Tools
+nut    3493/udp
+ironstorm      3504/tcp        # IronStorm game server
+ironstorm      3504/udp
+cctv-port      3559/tcp        # CCTV control port
+cctv-port      3559/udp
+iw-mmogame     3596/tcp        # Illusion Wireless MMOG
+iw-mmogame     3596/udp
+distcc 3632/tcp        # Distributed Compiler
+distcc 3632/udp
+daap   3689/tcp        # Digital Audio Access Protocol
+daap   3689/udp
+svn    3690/tcp        # Subversion
+svn    3690/udp
+blizwow        3724/tcp        # World of Warcraft
+blizwow        3724/udp
+netboot-pxe    3928/tcp        pxe     # PXE NetBoot Manager
+netboot-pxe    3928/udp        pxe
+smauth-port    3929/tcp        # AMS Port
+smauth-port    3929/udp
+treehopper     3959/tcp        # Tree Hopper Networking
+treehopper     3959/udp
+cobraclient    3970/tcp        # Cobra Client
+cobraclient    3970/udp
+cobraserver    3971/tcp        # Cobra Server
+cobraserver    3971/udp
+pxc-spvr-ft    4002/tcp        pxc-spvr-ft
+pxc-spvr-ft    4002/udp        pxc-spvr-ft
+pxc-splr-ft    4003/tcp        pxc-splr-ft rquotad
+pxc-splr-ft    4003/udp        pxc-splr-ft rquotad
+pxc-roid       4004/tcp        pxc-roid
+pxc-roid       4004/udp        pxc-roid
+pxc-pin        4005/tcp        pxc-pin
+pxc-pin        4005/udp        pxc-pin
+pxc-spvr       4006/tcp        pxc-spvr
+pxc-spvr       4006/udp        pxc-spvr
+pxc-splr       4007/tcp        pxc-splr
+pxc-splr       4007/udp        pxc-splr
+xgrid  4111/tcp        # Mac OS X Server Xgrid
+xgrid  4111/udp
+bzr    4155/tcp        # Bazaar Version Control System
+bzr    4155/udp        # Bazaar version control system
+rwhois 4321/tcp        # Remote Who Is
+rwhois 4321/udp
+epmd   4369/tcp        # Erlang Port Mapper Daemon
+epmd   4369/udp
+krb524 4444/tcp
+krb524 4444/udp
+ipsec-nat-t    4500/tcp        # IPsec NAT-Traversal
+ipsec-nat-t    4500/udp
+hylafax        4559/tcp        # HylaFAX client-server protocol  (new)
+hylafax        4559/udp
+piranha1       4600/tcp
+piranha1       4600/udp
+playsta2-app   4658/tcp        # PlayStation2 App Port
+playsta2-app   4658/udp
+playsta2-lob   4659/tcp        # PlayStation2 Lobby Port
+playsta2-lob   4659/udp
+snap   4752/tcp        # Simple Network Audio Protocol
+snap   4752/udp
+radmin-port    4899/tcp        # RAdmin Port
+radmin-port    4899/udp
+rfe    5002/tcp        # Radio Free Ethernet
+rfe    5002/udp
+ita-agent      5051/tcp        # ITA Agent
+ita-agent      5051/udp
+sdl-ets        5081/tcp        # SDL - Ent Trans Server
+sdl-ets        5081/udp
+bzflag 5154/tcp        # BZFlag game server
+bzflag 5154/udp
+aol    5190/tcp        # America-Online
+aol    5190/udp
+xmpp-client    5222/tcp        # XMPP Client Connection
+xmpp-client    5222/udp
+caevms 5251/tcp        # CA eTrust VM Service
+caevms 5251/udp
+xmpp-server    5269/tcp        # XMPP Server Connection
+xmpp-server    5269/udp
+cfengine       5308/tcp        # CFengine
+cfengine       5308/udp
+nat-pmp        5351/tcp        # NAT Port Mapping Protocol
+nat-pmp        5351/udp
+dns-llq        5352/tcp        # DNS Long-Lived Queries
+dns-llq        5352/udp
+mdns   5353/tcp        # Multicast DNS
+mdns   5353/udp
+mdnsresponder  5354/tcp        noclog  # Multicast DNS Responder IPC
+mdnsresponder  5354/udp        noclog  # noclogd with TCP (nocol)
+llmnr  5355/tcp        hostmon # Link-Local Multicast Name Resolution
+llmnr  5355/udp        hostmon # hostmon uses TCP (nocol)
+dj-ice 5419/tcp
+dj-ice 5419/udp
+beyond-remote  5424/tcp        # Beyond Remote
+beyond-remote  5424/udp
+br-channel     5425/tcp        # Beyond Remote Command Channel
+br-channel     5425/udp
+postgresql     5432/tcp        # POSTGRES
+postgresql     5432/udp
+sgi-eventmond  5553/tcp        # SGI Eventmond Port
+sgi-eventmond  5553/udp
+sgi-esphttp    5554/tcp        # SGI ESP HTTP
+sgi-esphttp    5554/udp
+cvsup  5999/tcp        # CVSup
+cvsup  5999/udp
+x11    6000/tcp        # X Window System
+x11    6000/udp
+kftp-data      6620/tcp        # Kerberos V5 FTP Data
+kftp-data      6620/udp
+kftp   6621/tcp        # Kerberos V5 FTP Control
+kftp   6621/udp
+ktelnet        6623/tcp        # Kerberos V5 Telnet
+ktelnet        6623/udp
+gnutella-svc   6346/tcp
+gnutella-svc   6346/udp
+gnutella-rtr   6347/tcp
+gnutella-rtr   6347/udp
+sane-port      6566/tcp        # SANE Network Scanner Control Port
+sane-port      6566/udp
+parsec-game    6582/tcp        # Parsec Gameserver
+parsec-game    6582/udp
+afs3-fileserver        7000/tcp        bbs     # file server itself
+afs3-fileserver        7000/udp        bbs
+afs3-callback  7001/tcp        # callbacks to cache managers
+afs3-callback  7001/udp
+afs3-prserver  7002/tcp        # users & groups database
+afs3-prserver  7002/udp
+afs3-vlserver  7003/tcp        # volume location database
+afs3-vlserver  7003/udp
+afs3-kaserver  7004/tcp        # AFS/Kerberos authentication
+afs3-kaserver  7004/udp
+afs3-volser    7005/tcp        # volume managment server
+afs3-volser    7005/udp
+afs3-errors    7006/tcp        # error interpretation service
+afs3-errors    7006/udp
+afs3-bos       7007/tcp        # basic overseer process
+afs3-bos       7007/udp
+afs3-update    7008/tcp        # server-to-server updater
+afs3-update    7008/udp
+afs3-rmtsys    7009/tcp        # remote cache manager service
+afs3-rmtsys    7009/udp
+font-service   7100/tcp        xfs     # X Font Service
+font-service   7100/udp        xfs
+sncp   7560/tcp        # Sniffer Command Protocol
+sncp   7560/udp
+soap-http      7627/tcp        # SOAP Service Port
+soap-http      7627/udp
+http-alt       8008/tcp        # HTTP Alternate
+http-alt       8008/udp
+http-alt       8080/tcp        webcache        # HTTP Alternate
+http-alt       8080/udp        webcache        # WWW caching service
+sunproxyadmin  8081/tcp        tproxy  # Sun Proxy Admin Service
+sunproxyadmin  8081/udp        tproxy  # Transparent Proxy
+pichat 9009/tcp        # Pichat Server
+pichat 9009/udp
+bacula-dir     9101/tcp        # Bacula Director
+bacula-dir     9101/udp
+bacula-fd      9102/tcp        # Bacula File Daemon
+bacula-fd      9102/udp
+bacula-sd      9103/tcp        # Bacula Storage Daemon
+bacula-sd      9103/udp
+dddp   9131/tcp        # Dynamic Device Discovery
+dddp   9131/udp
+wap-wsp        9200/tcp        # WAP connectionless session service
+wap-wsp        9200/udp
+wap-wsp-wtp    9201/tcp        # WAP session service
+wap-wsp-wtp    9201/udp
+wap-wsp-s      9202/tcp        # WAP secure connectionless session service
+wap-wsp-s      9202/udp
+wap-wsp-wtp-s  9203/tcp        # WAP secure session service
+wap-wsp-wtp-s  9203/udp
+wap-vcard      9204/tcp        # WAP vCard
+wap-vcard      9204/udp
+wap-vcal       9205/tcp        # WAP vCal
+wap-vcal       9205/udp
+wap-vcard-s    9206/tcp        # WAP vCard Secure
+wap-vcard-s    9206/udp
+wap-vcal-s     9207/tcp        # WAP vCal Secure
+wap-vcal-s     9207/udp
+git    9418/tcp        # git pack transfer service
+git    9418/udp
+cba8   9593/tcp        # LANDesk Management Agent
+cba8   9593/udp
+davsrc 9800/tcp        # WebDav Source Port
+davsrc 9800/udp
+sd     9876/tcp        # Session Director
+sd     9876/udp
+cyborg-systems 9888/tcp        # CYBORG Systems
+cyborg-systems 9888/udp
+monkeycom      9898/tcp        # MonkeyCom
+monkeycom      9898/udp
+sctp-tunneling 9899/tcp        # SCTP TUNNELING
+sctp-tunneling 9899/udp
+domaintime     9909/tcp        # domaintime
+domaintime     9909/udp
+amanda 10080/tcp       # amanda backup services
+amanda 10080/udp
+vce    11111/tcp       # Viral Computing Environment (VCE)
+vce    11111/udp
+smsqp  11201/tcp       # Alamin SMS gateway
+smsqp  11201/udp
+hkp    11371/tcp       # OpenPGP HTTP Keyserver
+hkp    11371/udp
+h323callsigalt 11720/tcp       # h323 Call Signal Alternate
+h323callsigalt 11720/udp
+rets-ssl       12109/tcp       # RETS over SSL
+rets-ssl       12109/udp
+cawas  12168/tcp       # CA Web Access Service
+cawas  12168/udp
+bprd   13720/tcp       # BPRD Protocol (VERITAS NetBackup)
+bprd   13720/udp
+bpdbm  13721/tcp       # BPDBM Protocol (VERITAS NetBackup)
+bpdbm  13721/udp
+bpjava-msvc    13722/tcp       # BP Java MSVC Protocol
+bpjava-msvc    13722/udp
+vnetd  13724/tcp       # Veritas Network Utility
+vnetd  13724/udp
+bpcd   13782/tcp       # VERITAS NetBackup
+bpcd   13782/udp
+vopied 13783/tcp       # VOPIED Protocol
+vopied 13783/udp
+xpilot 15345/tcp       # XPilot Contact Port
+xpilot 15345/udp
+wnn6   22273/tcp       # wnn6
+wnn6   22273/udp
+binkp  24554/tcp       # Bink fidonet protocol
+binkp  24554/udp
+quake  26000/tcp       # Quake @!#
+quake  26000/udp
+wnn6-ds        26208/tcp
+wnn6-ds        26208/udp
+tetrinet       31457/tcp       # TetriNET Protocol
+tetrinet       31457/udp
+gamesmith-port 31765/tcp       # GameSmith Port
+gamesmith-port 31765/udp
+traceroute     33434/tcp       # traceroute use
+traceroute     33434/udp
+candp  42508/tcp       # Computer Associates network discovery protocol
+candp  42508/udp
+candrp 42509/tcp       # CA discovery response
+candrp 42509/udp
+caerpc 42510/tcp       # CA eTrust RPC
+caerpc 42510/udp
+
+#=========================================================================
+# The remaining port numbers are not as allocated by IANA.
+
+# Kerberos (Project Athena/MIT) services
+# Note that these are for Kerberos v4, and are unofficial
+kpop   1109/tcp        # Pop with Kerberos
+knetd  2053/tcp        # Kerberos de-multiplexor
+eklogin        2105/tcp        # Kerberos encrypted rlogin
+
+# CVSup support http://www.cvsup.org/
+supfilesrv     871/tcp # SUP server
+supfiledbg     1127/tcp        # SUP debugging
+
+# Datagram Delivery Protocol services
+rtmp   1/ddp   # Routing Table Maintenance Protocol
+nbp    2/ddp   # Name Binding Protocol
+echo   4/ddp   # AppleTalk Echo Protocol
+zip    6/ddp   # Zone Information Protocol
+
+# Many services now accepted as 'standard'
+swat   901/tcp # Samba configuration tool
+rndc   953/tcp # rndc control sockets (BIND 9)
+rndc   953/udp
+skkserv        1178/tcp        # SKK Japanese input method
+xtel   1313/tcp        # french minitel
+support        1529/tcp        # GNATS
+cfinger        2003/tcp        lmtp    # GNU Finger
+ninstall       2150/tcp        # ninstall service
+ninstall       2150/udp
+afbackup       2988/tcp        # Afbackup system
+afbackup       2988/udp
+fax    4557/tcp        # FAX transmission service        (old)
+rplay  5555/tcp        # RPlay audio service
+rplay  5555/udp
+canna  5680/tcp        # Canna (Japanese Input)
+x11-ssh        6010/tcp        x11-ssh-offset
+x11-ssh        6010/udp        x11-ssh-offset
+ircd   6667/tcp        # Internet Relay Chat
+ircd   6667/udp
+jetdirect      9100/tcp        # HP JetDirect card
+jetdirect      9100/udp
+mandelspawn    9359/udp        mandelbrot      # network mandelbrot
+kamanda        10081/tcp       # amanda backup services (Kerberos)
+kamanda        10081/udp
+amandaidx      10082/tcp       # amanda backup services
+amidxtape      10083/tcp       # amanda backup services
+isdnlog        20011/tcp       # isdn logging system
+isdnlog        20011/udp
+vboxd  20012/tcp       # voice box system
+vboxd  20012/udp
+wnn4_Cn        22289/tcp       wnn6_Cn # Wnn (Chinese input)
+wnn4_Kr        22305/tcp       wnn6_Kr # Wnn (Korean input)
+wnn4_Tw        22321/tcp       wnn6_Tw # Wnn (Taiwanse input)
+asp    27374/tcp       # Address Search Protocol
+asp    27374/udp
+tfido  60177/tcp       # Ifmail
+tfido  60177/udp
+fido   60179/tcp       # Ifmail
+fido   60179/udp
+
+# Local services
diff --git a/spec/fixtures/unit/provider/port/parsed/uniq 
b/spec/fixtures/unit/provider/port/parsed/uniq
new file mode 100644
index 0000000..8ed670f
--- /dev/null
+++ b/spec/fixtures/unit/provider/port/parsed/uniq
@@ -0,0 +1,7 @@
+# We test a few comments here
+# and anotherone
+ftp-data       20/tcp  # File Transfer [Default Data]
+ftp    21/tcp  # File Transfer [Control]
+# One comment in the middle
+x11-ssh        6010/tcp        x11-ssh-offset # alias test
+baz 100/tcp alias1  alias # Multiple test
diff --git a/spec/unit/provider/port/parsed_spec.rb 
b/spec/unit/provider/port/parsed_spec.rb
new file mode 100644
index 0000000..fce6baf
--- /dev/null
+++ b/spec/unit/provider/port/parsed_spec.rb
@@ -0,0 +1,278 @@
+#!/usr/bin/env ruby
+
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
+
+require 'shared_behaviours/all_parsedfile_providers'
+require 'puppet_spec/files'
+
+provider_class = Puppet::Type.type(:port).provider(:parsed)
+
+describe provider_class do
+  include PuppetSpec::Files
+
+  before do
+    @host_class = Puppet::Type.type(:port)
+    @provider = @host_class.provider(:parsed)
+    @servicesfile = tmpfile('services')
+    @provider.stubs(:default_target).returns @servicesfile
+    @provider.any_instance.stubs(:target).returns @servicesfile
+  end
+
+  after :each do
+    @provider.initvars
+  end
+
+  def mkport(args)
+    portresource = Puppet::Type::Port.new(:name => args[:name], :protocol => 
args[:protocol])
+    portresource.stubs(:should).with(:target).returns @servicesfile
+
+    # Using setters of provider
+    port = @provider.new(portresource)
+    args.each do |property,value|
+      value = value.join(' ') if property == :port_aliases and 
value.is_a?(Array)
+      port.send("#{property}=", value)
+    end
+    port
+  end
+
+  def genport(port)
+    @provider.stubs(:filetype).returns(Puppet::Util::FileType::FileTypeRam)
+    File.stubs(:chown)
+    File.stubs(:chmod)
+    Puppet::Util::SUIDManager.stubs(:asuser).yields
+    port.flush
+    @provider.target_object(@servicesfile).read
+  end
+
+  describe "when parsing a line with name port and protocol" do
+
+    before do
+      @example_line = "telnet   \t    23/udp"
+    end
+
+    it "should extrace name from the first field" do
+      @provider.parse_line(@example_line)[:name].should == 'telnet'
+    end
+
+    it "should extract number from second field" do
+      @provider.parse_line(@example_line)[:number].should == '23'
+    end
+
+    it "should extract protocol udp from third field" do
+      @provider.parse_line(@example_line)[:protocol].should == :udp
+    end
+
+    it "should extrace protocol tcp from third field" do
+      @provider.parse_line('telnet 23/tcp')[:protocol].should == :tcp
+    end
+
+    it "should drop trailing spaces" do
+      @provider.parse_line('telnet 23/tcp  ')[:protocol].should == :tcp
+    end
+
+    it "should handle different delimiters" do
+      @result = ['telnet','23',:tcp ]
+      [
+        "telnet 23/tcp",
+        "telnet\t23/tcp",
+        "telnet \t23/tcp",
+        "telnet\t 23/tcp",
+        "telnet  \t  23/tcp\t\t"
+      ].each do |sample|
+        hash = @provider.parse_line(sample)
+        hash[:name].should == @result[0]
+        hash[:number].should == @result[1]
+        hash[:protocol].should == @result[2]
+        hash[:description].should == ''
+      end
+    end
+
+  end
+
+  describe "when parsing a line with name, port, protocol, description" do
+
+    before do
+      @example_line = "telnet   \t    23/udp # Telnet"
+    end
+
+    it "should extrace name from the first field" do
+      @provider.parse_line(@example_line)[:name].should == 'telnet'
+    end
+
+    it "should extract number from second field" do
+      @provider.parse_line(@example_line)[:number].should == '23'
+    end
+
+    it "should extract protocol from third field" do
+      @provider.parse_line(@example_line)[:protocol].should == :udp
+    end
+
+    it "should extract description after the first #" do
+      @provider.parse_line(@example_line)[:description].should == 'Telnet'
+    end
+
+    it "should correctly set description with multiple #" do
+      @provider.parse_line('telnet 23/udp # My # desc')[:description].should 
== 'My # desc'
+    end
+
+    it "should handle different delimiters" do
+      @result = ['telnet', '23', :udp, 'My # desc' ]
+      [
+        "telnet 23/udp # My # desc",
+        "telnet\t 23/udp\t# My # desc",
+        "telnet  \t23/udp   #\tMy # desc",
+        "telnet   \t  \t 23/udp \t \t# \tMy # desc"
+      ].each do |sample|
+        hash = @provider.parse_line(sample)
+        hash[:name].should == @result[0]
+        hash[:number].should == @result[1]
+        hash[:protocol].should == @result[2]
+        hash[:description].should == @result[3]
+      end
+
+    end
+
+  end
+
+  describe "when parsing a line with name, number, procotol and aliases" do
+
+    before do
+      @example_line = "telnet   \t    23/udp alias1 alias2"
+    end
+
+    it "should extrace name from the first field" do
+      @provider.parse_line(@example_line)[:name].should == 'telnet'
+    end
+
+    it "should extract number from second field" do
+      @provider.parse_line(@example_line)[:number].should == '23'
+    end
+
+    it "should extract protocol from third field" do
+      @provider.parse_line(@example_line)[:protocol].should == :udp
+    end
+
+    it "should extract single alias" do
+      @example_line = "telnet   \t    23/udp alias1"
+      @provider.parse_line(@example_line)[:port_aliases].should == 'alias1'
+    end
+
+    it "should extract multiple aliases" do
+      @provider.parse_line(@example_line)[:port_aliases].should == 'alias1 
alias2'
+    end
+
+    it "should convert delimiter to single space" do
+      @provider.parse_line("telnet 23/udp alias1\t\t alias2\talias3 
alias4")[:port_aliases].should == 'alias1 alias2 alias3 alias4'
+    end
+
+    it "should set port_aliases to :absent if there is none" do
+      @provider.parse_line("telnet 23/udp")[:port_aliases].should == :absent
+      @provider.parse_line("telnet 23/udp  ")[:port_aliases].should == :absent
+      @provider.parse_line("telnet 23/udp  # Bazinga!")[:port_aliases].should 
== :absent
+    end
+
+  end
+
+  describe "when parsing a line with name, number, protocol, aliases and 
description" do
+
+    before do
+      @example_line = "telnet   \t    23/udp alias1 alias2 # Tel#net"
+      @result = ['telnet','23',:udp,'alias1 alias2','Tel#net']
+    end
+
+    it "should extrace name from the first field" do
+      @provider.parse_line(@example_line)[:name].should == @result[0]
+    end
+
+    it "should extract number from second field" do
+      @provider.parse_line(@example_line)[:number].should == @result[1]
+    end
+
+    it "should extract protocol from third field" do
+      @provider.parse_line(@example_line)[:protocol].should == @result[2]
+    end
+
+    it "should extract aliases from forth field" do
+      @provider.parse_line(@example_line)[:port_aliases].should == @result[3]
+    end
+
+    it "should extract description from the fifth field" do
+      @provider.parse_line(@example_line)[:description].should == @result[4]
+    end
+
+  end
+
+  describe "when operating on /etc/services like files" do
+
+    it_should_behave_like "all parsedfile providers", provider_class
+
+  end
+
+  it "should be able to generate a simple services entry" do
+    port = mkport(
+      :name     => 'telnet',
+      :protocol => :tcp,
+      :number   => '23',
+      :ensure   => :present
+    )
+    genport(port).should == "telnet\t23/tcp\n"
+  end
+
+  it "should be able to generate an entry with one alias" do
+    port = mkport(
+      :name         => 'pcx-pin',
+      :protocol     => :tcp,
+      :number       => '4005',
+      :port_aliases => 'pcx-pin',
+      :ensure       => :present
+    )
+    genport(port).should == "pcx-pin\t4005/tcp\tpcx-pin\n"
+  end
+
+  it "should be able to generate an entry with more than one alias" do
+    port = mkport(
+      :name         => 'pcx-splr-ft',
+      :protocol     => :udp,
+      :number       => '4003',
+      :port_aliases => [ 'pcx-splr-ft', 'rquotad' ],
+      :ensure       => :present
+    )
+    genport(port).should == "pcx-splr-ft\t4003/udp\tpcx-splr-ft rquotad\n"
+  end
+
+  it "should be able to generate a simple hostfile entry with comments" do
+    port = mkport(
+      :name        => 'telnet',
+      :protocol    => :tcp,
+      :number      => '23',
+      :description => 'Fancy # comment',
+      :ensure      => :present
+    )
+    genport(port).should == "telnet\t23/tcp\t# Fancy # comment\n"
+  end
+
+  it "should be able to generate an entry with one alias and a comment" do
+    port = mkport(
+      :name          => 'foo',
+      :protocol      => :tcp,
+      :number        => '1',
+      :port_aliases  => 'bar',
+      :description   => 'Bazinga!',
+      :ensure        => :present
+    )
+    genport(port).should == "foo\t1/tcp\tbar\t# Bazinga!\n"
+  end
+
+  it "should be able to generate an entry with more than one alias and a 
comment" do
+    port = mkport(
+      :name          => 'foo',
+      :protocol      => :udp,
+      :number        => '3000',
+      :port_aliases  => [ 'bar', 'baz', 'zap' ],
+      :description   => 'Bazinga!',
+      :ensure        => :present
+    )
+    genport(port).should == "foo\t3000/udp\tbar baz zap\t# Bazinga!\n"
+  end
+
+end
-- 
1.7.4.1

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to puppet-dev@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to