Len (packet/ip4.go)

tailscale · net/packet/ip4.go · go · BSD-3-Clause
infra, tag:knn-classified

Copyright (c) Tailscale Inc & contributors SPDX-License-Identifier: BSD-3-Clause

// Source: https://github.com/tailscale/tailscale | License: BSD-3-Clause | Copyright 2020 Tailscale Inc & contributors
// Provided via justclaw.it.com; keep this notice with the code.
// Copyright (c) Tailscale Inc & contributors
// SPDX-License-Identifier: BSD-3-Clause

package packet

import (
	"encoding/binary"
	"errors"
	"net/netip"

	"tailscale.com/types/ipproto"
)

// ip4HeaderLength is the length of an IPv4 header with no IP options.
const ip4HeaderLength = 20

// IP4Header represents an IPv4 packet header.
type IP4Header struct {
	IPProto ipproto.Proto
	IPID    uint16
	Src     netip.Addr
	Dst     netip.Addr
}

// Len implements Header.
func (h IP4Header) Len() int {
	return ip4HeaderLength
}

var errWrongFamily = errors.New("wrong address family for src/dst IP")

// Marshal implem

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key