Skip to content
Snippets Groups Projects
Select Git revision
  • 16459281dab2b53e6572297762efbd19accf2eea
  • master default protected
  • renovate/configure
  • 2-create-ospf-example
  • feature/isis
  • migrate-to-github-actions
  • aspath/convenience
  • hashroute/public
  • cmd/rismirror
  • riscli/vrf
  • fix/bmp_down
  • ris/logging
  • fix/ris_race
  • fix/bmp_metrics
  • please-go-vet
  • fix/lock_copy
  • fix/dedup_mem
  • add-get-routers-rpc
  • feature/bgp_md5
  • is-is/srv
  • feature/ris/lpm_any
  • v0.0.3-pre4
  • v0.0.3-pre3
  • v0.0.3-pre2
  • v0.0.3-pre1
  • v0.0.2-pre9
  • v0.0.2-pre8
  • v0.0.2-pre7
  • v0.0.2-pre6
  • v0.0.2-pre5
  • v0.0.2-pre4
  • v0.0.2-pre3
  • v0.0.2-pre2
  • v0.0.2-pre1
  • v0.0.1-pre10
  • v0.0.1-pre9
  • v0.0.1-pre7
  • v0.0.1-pre8
  • v0.0.1-pre6
  • v0.0.1-pre4
  • v0.0.1-pre5
41 results

helper.go

Blame
  • user avatar
    takt authored and Daniel Czerwonk committed
    * Add caches
    
    * Replace IPs and Prefixes with pointers to these
    
    * Fix nil pointer derefs
    
    * Fix nil pointer deref
    
    * Fix community encoding
    
    * Fix tests
    
    * Fix tests
    
    * Fix tests
    
    * Fix tests
    
    * Fix tests
    
    * Fix tests
    
    * Fix BGP path hashing
    
    * Fix path attr decoding
    
    * Fix tests
    
    * Fix tests
    
    * Fix tests
    
    * Fix tests
    
    * Cleanup
    
    * Cleanup
    
    * Revert config change
    
    * Fix Benchmark. Fix ClusterList PA.
    
    * Fix ClusterList tests
    
    * Add client
    
    * Remove stale test
    
    * Cleanup
    
    * Increase verbosity on decode failure
    
    * Improve chache layer performance
    
    * Improve bgp path cache performance
    
    * Cleanup
    16459281
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    helper.go 800 B
    package packet
    
    import (
    	"fmt"
    
    	bnet "github.com/bio-routing/bio-rd/net"
    )
    
    func serializePrefix(pfx bnet.Prefix) []byte {
    	if pfx.Pfxlen() == 0 {
    		return []byte{}
    	}
    
    	numBytes := BytesInAddr(pfx.Pfxlen())
    
    	b := make([]byte, numBytes+1)
    	b[0] = pfx.Pfxlen()
    	copy(b[1:numBytes+1], pfx.Addr().Bytes()[0:numBytes])
    
    	return b
    }
    
    func deserializePrefix(b []byte, pfxLen uint8, afi uint16) (*bnet.Prefix, error) {
    	numBytes := BytesInAddr(pfxLen)
    
    	if numBytes != uint8(len(b)) {
    		return nil, fmt.Errorf("could not parse prefix of length %d. Expected %d bytes, got %d", pfxLen, numBytes, len(b))
    	}
    
    	ipBytes := make([]byte, afiAddrLenBytes[afi])
    	copy(ipBytes, b)
    
    	ip, err := bnet.IPFromBytes(ipBytes)
    	if err != nil {
    		return nil, err
    	}
    
    	return bnet.NewPfx(ip.Dedup(), pfxLen).Dedup(), nil
    }