Categorygithub.com/thediveo/netdb
modulepackage
1.1.2
Repository: https://github.com/thediveo/netdb.git
Documentation: pkg.go.dev

# README

netdb

pkg.go.dev GitHub build and test Go Report Card Coverage

netdb provides information about TCP/IP subsystem protocols and internet services, all this in (pure) Go. By default, it uses its built-in database instead of consulting /etc/protocols, /etc/services, and /etc/ethertypes. If needed, it can also consult these files, please see the examples in the documentation.

The built-in database has been auto-generated from the etc/protocols, etc/ethertypes, and etc/services files courtesy of the netbase package of the Debian project.

This netdb package does not even try to slavishly replicate the POSIX C API; instead, it attempts to be Go-ish. For instance, the C type servent has simply become the netdb.Service type in order to avoid arcane POSIX-rooted type names.

Please refer to the reference documentation for usage examples.

Acknowledgement

In some sense, this netdb package picks up the baton from the @dominikh/go-netdb package. However, it is not a fork but was written from scratch, considering (at least some of) the advice in issue #1 of the go-netdb package.

Copyright and License

netdb is Copyright 2021-24 Harald Albrecht, and licensed under the Apache License, Version 2.0.

# Functions

EtherTypeByName returns the EtherType details for the specified (native or aliased) name, or nil if not defined.
EtherTypeByNumber returns the EtherType details for the specified EtherType number, or nil if not defined.
LoadEtherTypes returns an EtherTypeIndex object initialized from the defintions in the named file.
LoadProtocols returns a ProtocolIndex object initialized from the definitions in the named file.
LoadServices returns a ServiceIndex object initialized from the definitions in the named file.
NewEtherTypeIndex returns an EtherTypeIndex object initialized with the specified EtherTypes.
NewProtocolIndex returns a ProtocolsIndex object initialized with the specified protocols.
NewServiceIndex returns a Services index object initialized with the specified services.
ParseEtherTypes parses EtherType definitions from the given Reader and returns them as a list of EtherType objects.
ParseProtocols parses Internet protocol definitions for the TCP/IP subsystem from the given Reader and returns them as a list of Protcol(s).
ParseServices parses network service definitions from the given Reader and returns them as a list of Service(s).
ProtocolByName returns the Protocol details for the specified (alias) name, or nil if not defined.
ProtocolByNumber returns the Protocol details for the specified protocol number, or nil if not defined.
ServiceByName returns the Service details for the specified (alias) name and (optional) protocol name, or nil if not defined.
ServiceByPort returns the Service details for the specified port number and (optional) protocol name, or nil if not defined.

# Variables

No description provided by the author
No description provided by the author
No description provided by the author
EtherTypes is the index of EtherType names and numbers.
Protocols is the index of protocol names and numbers.
Services is the index of service names and protocols.

# Structs

EtherType describes an Ethernet frame type/protocol used on an Ethernet network.
EtherTypeIndex index the known EtherTypes by either name (native as well as aliases) and by number.
Protocol describes a network communications protocol by its native name and official protocol number as appearing within IP headers, with optional alias names.
ProtocolIndex indexes the known network communication protocols by either name (native as well as aliases) and by number.
Service describes a network service by its official service name, port number and network protocol, with optional service alias names.
ServiceIndex indexes the known network services by either (alias) name or by transport port number.
ServicePort represents a Service index key.
ServiceProtocol represents a Service index key.