github.com/geniusesgroup/libgo@v0.0.0-20220713101832-828057a9d3d4/protocol/network-link.go (about)

     1  /* For license and copyright information please see LEGAL file in repository */
     2  
     3  package protocol
     4  
     5  type NetworkLinkNextHeaderID byte
     6  
     7  // https://github.com/GeniusesGroup/RFCs/blob/master/Chapar.md#next-header-standard-supported-protocols
     8  const (
     9  	NetworkLinkNextHeaderSRPC NetworkLinkNextHeaderID = iota
    10  	NetworkLinkNextHeaderGP
    11  	NetworkLinkNextHeaderIPv4
    12  	NetworkLinkNextHeaderIPv6
    13  	NetworkLinkNextHeaderNTP
    14  
    15  	NetworkLinkNextHeaderExperimental1 NetworkLinkNextHeaderID = 251
    16  	NetworkLinkNextHeaderExperimental2 NetworkLinkNextHeaderID = 252
    17  	NetworkLinkNextHeaderExperimental3 NetworkLinkNextHeaderID = 253
    18  	NetworkLinkNextHeaderExperimental4 NetworkLinkNextHeaderID = 254
    19  	NetworkLinkNextHeaderExperimental5 NetworkLinkNextHeaderID = 255
    20  )
    21  
    22  /*
    23  **********************************************************************************
    24  Link - (OSI Layer 2: Data Link)
    25  
    26  It can use to network hardware devices in a computers or connect two or more computers.
    27  **********************************************************************************
    28  */
    29  
    30  // NetworkLinkMultiplexer indicate a link frame multiplexer object methods must implemented by any os!
    31  type NetworkLinkMultiplexer interface {
    32  	// Send usually use to send a broadcast frame
    33  	Send(frame []byte) (err Error)
    34  	Receive(frame []byte)
    35  
    36  	RegisterTransportHandler(transMux NetworkTransportMultiplexer)
    37  	UnRegisterTransportHandler(transMux NetworkTransportMultiplexer)
    38  
    39  	Shutdown()
    40  }
    41  
    42  // NetworkLinkConnection or Device2DeviceConnection
    43  type NetworkLinkConnection interface {
    44  	MTU() int
    45  	// Send transmitting in non blocking mode and just queue frames for congestion situations.
    46  	// Return error not realted to frame situation, just about any hardware error.
    47  	// A situation might be occur that the port available when a frame queued but when the time to send is come, the port broken and sender don't know about this!
    48  	// Due to speed matters in link layer, and it is very rare situation, it is better to ignore suddenly port unavailability.
    49  	Send(nextHeaderID NetworkLinkNextHeaderID, payload Codec) (err Error)
    50  }