yamlnetlink

package module
v0.0.0-...-61a6fe6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2022 License: MIT Imports: 8 Imported by: 0

README

Package yamlnetlink provides support for parsing YAML netlink specifications. MIT Licensed.

For more information, see:

A goal of this project is to provide a yamlnetlink-go tool which automatically generate Go code from YAML netlink specifications using github.com/mdlayher/netlink and github.com/mdlayher/genetlink.

Documentation

Overview

Package yamlnetlink provides support for parsing YAML netlink specifications.

For more information, see: - https://lore.kernel.org/all/20220811022304.583300-1-kuba@kernel.org/ - https://github.com/kuba-moo/ynl/blob/main/Documentation/netlink/netlink-bindings.rst

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(s *Spec, cfg *Config) ([]byte, error)

Generate generates formatted Go code from a YAML netlink Spec. If cfg is nil, a default Config is used.

Types

type Attribute

type Attribute struct {
	Name             string   `yaml:"name"`
	Type             string   `yaml:"type"`
	TypeValue        []string `yaml:"type-value"`
	Len              string   `yaml:"len"`
	Doc              string   `yaml:"doc"`
	NestedAttributes string   `yaml:"nested-attributes"`
}

An Attribute describes a single netlink attribute.

type AttributeSet

type AttributeSet struct {
	Name       string      `yaml:"name"`
	NamePrefix string      `yaml:"name-prefix"`
	Attributes []Attribute `yaml:"attributes"`
}

An AttributeSet describes the netlink attributes for a given family.

type Config

type Config struct {
	// Package specifies an optional package name for the generated code. If
	// unset, the default is to use the Spec.Name field.
	Package string
}

Config specifies configuration for Generate.

type Operation

type Operation struct {
	Name         string              `yaml:"name"`
	Doc          string              `yaml:"doc"`
	AttributeSet string              `yaml:"attribute-set"`
	DontValidate []string            `yaml:"dont-validate"`
	Notify       string              `yaml:"notify"`
	Do           OperationAttributes `yaml:"do"`
	Dump         OperationAttributes `yaml:"dump"`
}

An Operation describes a single netlink request/reply operation.

type OperationAttributes

type OperationAttributes struct {
	Request OperationAttributesList `yaml:"request"`
	Reply   OperationAttributesList `yaml:"reply"`
}

OperationAttributes describes the list of attributes used in netlink request and replies for a given Operation.

type OperationAttributesList

type OperationAttributesList struct {
	Attributes []string `yaml:"attributes"`
}

An OperationAttributesList contains the actual attributes used in a netlink request or reply operation.

type Operations

type Operations struct {
	NamePrefix string      `yaml:"name-prefix"`
	List       []Operation `yaml:"list"`
}

Operations describes the request and reply operations available for a netlink family.

type Spec

type Spec struct {
	Name          string         `yaml:"name"`
	Protocol      string         `yaml:"protocol"`
	Doc           string         `yaml:"doc"`
	UAPIHeader    string         `yaml:"uapi-header"`
	AttributeSets []AttributeSet `yaml:"attribute-sets"`
	Operations    Operations     `yaml:"operations"`
}

A Spec is a YAML netlink specification.

func Parse

func Parse(r io.Reader) (*Spec, error)

Parse parses a YAML netlink specification into a Spec.

Directories

Path Synopsis
cmd
yamlnetlink-go
Command yamlnetlink-go generates Go code from YAML netlink specifications.
Command yamlnetlink-go generates Go code from YAML netlink specifications.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL