yang

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package yang is used to parse .yang files (see RFC 6020).

A generic yang statments takes one of the forms:

keyword [argument] ;
keyword [argument] { [statement [...]] }

At the lowest level, package yang returns a simple tree of statements via the Parse function. The Parse function makes no attempt to determine the validity of the source, other than checking for generic syntax errors.

At it's simplest, the GetModule function is used. The GetModule function searches the current directory, and any directory added to the Path variable, for a matching .yang source file by appending .yang to the name of the module:

// Get the tree for the module module-name by looking for the source
// file named module-name.yang.
e, errs := yang.GetModule("module-name" [, optional sources...])
if len(errs) > 0 {
	for _, err := range errs {
		fmt.Fprintln(os.Stderr, err)
	}
	os.Exit(1)
}

// e is the Entry tree for "module-name"

More complicated uses cases should use NewModules and then some combination of Modules.GetModule, Modules.Read, Modules.Parse, and Modules.GetErrors.

The GetErrors method is mandatory, however, both yang.GetModule and Modules.GetModule automatically call Modules.GetErrors.

Index

Constants

View Source
const (
	TSUnset = TriState(iota)
	TSTrue
	TSFalse
)

The possible states of a TriState.

View Source
const (
	LeafEntry = EntryKind(iota)
	DirectoryEntry
	AnyDataEntry
	AnyXMLEntry
	CaseEntry
	ChoiceEntry
	InputEntry
	NotificationEntry
	OutputEntry
	DeviateEntry
)

Enumeration of the types of entries.

View Source
const (
	// DeviationUnset specifies that the argument was unset, which is invalid.
	DeviationUnset deviationType = iota
	// DeviationNotSupported corresponds to the not-supported deviate argument.
	DeviationNotSupported
	// DeviationAdd corresponds to the add deviate argument to the deviate stmt.
	DeviationAdd
	// DeviationReplace corresponds to the replace argument to the deviate stmt.
	DeviationReplace
	// DeviationDelete corresponds to the delete argument to the deviate stmt.
	DeviationDelete
)
View Source
const (
	// Ynone represents the invalid (unset) type.
	Ynone = TypeKind(iota)
	// Yint8 is an int in the range [-128, 127].
	Yint8
	// Yint16 is an int in the range [-32768, 32767].
	Yint16
	// Yint32 is an int in the range [-2147483648, 2147483647].
	Yint32
	// Yint64 is an int in the range [-9223372036854775808, 9223372036854775807]
	Yint64
	// Yuint8 is an int in the range [0, 255]
	Yuint8
	// Yuint16 is an int in the range [0, 65535]
	Yuint16
	// Yuint32 is an int in the range [0, 4294967295]
	Yuint32
	// Yuint64 is an int in the range [0, 18446744073709551615]
	Yuint64

	// Ybinary stores arbitrary data.
	Ybinary
	// Ybits is a named set of bits or flags.
	Ybits
	// Ybool is true or false.
	Ybool
	// Ydecimal64 is a signed decimal number.
	Ydecimal64
	// Yempty has no associated value.
	Yempty
	// Yenum stores enumerated strings.
	Yenum
	// Yidentityref stores an extensible enumeration.
	Yidentityref
	// YinstanceIdentifier stores a reference to a data tree node.
	YinstanceIdentifier
	// Yleafref stores a reference to a leaf instance.
	Yleafref
	// Ystring is a human readable string.
	Ystring
	// Yunion is a choice of types.
	Yunion
)
View Source
const (
	// MaxInt64 corresponds to the maximum value of a signed int64.
	MaxInt64 = 1<<63 - 1
	// MinInt64 corresponds to the maximum value of a signed int64.
	MinInt64 = -1 << 63
	// AbsMinInt64 is the absolute value of MinInt64.
	AbsMinInt64 = 1 << 63
	// MaxEnum is the maximum value of an enumeration.
	MaxEnum = 1<<31 - 1
	// MinEnum is the minimum value of an enumeration.
	MinEnum = -1 << 31
	// MaxBitfieldSize is the maximum number of bits in a bitfield.
	MaxBitfieldSize = 1 << 32
	// MaxFractionDigits is the maximum number of fractional digits as per RFC6020 Section 9.3.4.
	MaxFractionDigits uint8 = 18
)
View Source
const (
	// Positive indicates that a Number is non-negative.
	Positive = NumberKind(iota)
	// Negative indicates that a Number is negative.
	Negative
	// MinNumber indicates that the Number is the minimum value allowed for the range.
	MinNumber
	// MaxNumber indicates that the Number is the maximum value allowed for the range.
	MaxNumber
)

Variables

View Source
var (
	Int8Range  = mustParseRanges("-128..127")
	Int16Range = mustParseRanges("-32768..32767")
	Int32Range = mustParseRanges("-2147483648..2147483647")
	Int64Range = mustParseRanges("-9223372036854775808..9223372036854775807")

	Uint8Range  = mustParseRanges("0..255")
	Uint16Range = mustParseRanges("0..65535")
	Uint32Range = mustParseRanges("0..4294967295")
	Uint64Range = mustParseRanges("0..18446744073709551615")

	Decimal64Range = mustParseRanges("min..max")
)

These are the default ranges defined by the YANG standard.

View Source
var BaseTypedefs = map[string]*Typedef{}

BaseTypedefs is a map of all base types to the Typedef structure manufactured for the type.

View Source
var EntryKindToName = map[EntryKind]string{
	LeafEntry:         "Leaf",
	DirectoryEntry:    "Directory",
	AnyDataEntry:      "AnyData",
	AnyXMLEntry:       "AnyXML",
	CaseEntry:         "Case",
	ChoiceEntry:       "Choice",
	InputEntry:        "Input",
	NotificationEntry: "Notification",
	OutputEntry:       "Output",
	DeviateEntry:      "Deviate",
}

EntryKindToName maps EntryKind to their names

View Source
var ParseOptions = Options{}

ParseOptions sets the options for the current YANG module parsing. It can be directly set by the caller to influence how goyang will behave in the presence of certain exceptional cases.

View Source
var Path []string

Path is the list of directories to look for .yang files in.

View Source
var TypeKindFromName = map[string]TypeKind{
	"none":                Ynone,
	"int8":                Yint8,
	"int16":               Yint16,
	"int32":               Yint32,
	"int64":               Yint64,
	"uint8":               Yuint8,
	"uint16":              Yuint16,
	"uint32":              Yuint32,
	"uint64":              Yuint64,
	"binary":              Ybinary,
	"bits":                Ybits,
	"boolean":             Ybool,
	"decimal64":           Ydecimal64,
	"empty":               Yempty,
	"enumeration":         Yenum,
	"identityref":         Yidentityref,
	"instance-identifier": YinstanceIdentifier,
	"leafref":             Yleafref,
	"string":              Ystring,
	"union":               Yunion,
}

TypeKindFromName maps the string name used in a YANG file to the enumerated TypeKind used in this library.

View Source
var TypeKindToName = map[TypeKind]string{
	Ynone:               "none",
	Yint8:               "int8",
	Yint16:              "int16",
	Yint32:              "int32",
	Yint64:              "int64",
	Yuint8:              "uint8",
	Yuint16:             "uint16",
	Yuint32:             "uint32",
	Yuint64:             "uint64",
	Ybinary:             "binary",
	Ybits:               "bits",
	Ybool:               "boolean",
	Ydecimal64:          "decimal64",
	Yempty:              "empty",
	Yenum:               "enumeration",
	Yidentityref:        "identityref",
	YinstanceIdentifier: "instance-identifier",
	Yleafref:            "leafref",
	Ystring:             "string",
	Yunion:              "union",
}

TypeKindToName maps the enumerated type used in this library to the string used in a YANG file.

Functions

func AddPath

func AddPath(paths ...string)

AddPath adds the directories specified in p, a colon separated list of directory names, to Path, if they are not already in Path. Using multiple arguments is also supported.

func CamelCase

func CamelCase(s string) string

CamelCase returns the CamelCased name. If there is an interior underscore or dash followed by a lower case letter, drop the underscore or dash and convert the letter to upper case. There is a remote possibility of this rewrite causing a name collision, but it's so remote we're prepared to pretend it's nonexistent - since the C++ generator lowercases names, it's extremely unlikely to have two fields with different capitalizations. In short, _my_field_name_2 becomes XMyFieldName_2.

func Frac

func Frac(f float64) float64

Frac returns the fractional part of f.

func PathsWithModules

func PathsWithModules(root string) (paths []string, err error)

PathsWithModules returns all paths under and including the root containing files with a ".yang" extension, as well as any error encountered

func PrintNode

func PrintNode(w io.Writer, n Node)

PrintNode prints node n to w, recursively. TODO(borman): display more information

func Source

func Source(n Node) string

Source returns the location of the source where n was defined.

Types

type Action

type Action struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Description *Value      `yang:"description"`
	Grouping    []*Grouping `yang:"grouping"`
	IfFeature   []*Value    `yang:"if-feature"`
	Input       *Input      `yang:"input"`
	Output      *Output     `yang:"output"`
	Reference   *Value      `yang:"reference"`
	Status      *Value      `yang:"status"`
	Typedef     []*Typedef  `yang:"typedef"`
}

An Action is defined in http://tools.ietf.org/html/rfc7950#section-7.15

Action define an RPC operation connected to a specific container or list data node in the schema. In the schema tree, Action differ from RPC only in where in the tree they are found. RPC nodes are only found as sub-statements of a Module, while Action are found only as sub-statements of Container, List, Grouping and Augment nodes.

func (*Action) Exts

func (s *Action) Exts() []*Statement

func (*Action) Groupings

func (s *Action) Groupings() []*Grouping

func (Action) Kind

func (Action) Kind() string

func (*Action) NName

func (s *Action) NName() string

func (*Action) ParentNode

func (s *Action) ParentNode() Node

func (*Action) Statement

func (s *Action) Statement() *Statement

func (*Action) Typedefs

func (s *Action) Typedefs() []*Typedef

type AnyData

type AnyData struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Config      *Value   `yang:"config"`
	Description *Value   `yang:"description"`
	IfFeature   []*Value `yang:"if-feature"`
	Mandatory   *Value   `yang:"mandatory"`
	Must        []*Must  `yang:"must"`
	Reference   *Value   `yang:"reference"`
	Status      *Value   `yang:"status"`
	When        *Value   `yang:"when"`
}

An AnyData is defined in: http://tools.ietf.org/html/rfc7950#section-7.10

AnyData are only expected in YANG 1.1 modules (those with a "yang-version 1.1;" statement in the module).

func (*AnyData) Exts

func (s *AnyData) Exts() []*Statement

func (AnyData) Kind

func (AnyData) Kind() string

func (*AnyData) NName

func (s *AnyData) NName() string

func (*AnyData) ParentNode

func (s *AnyData) ParentNode() Node

func (*AnyData) Statement

func (s *AnyData) Statement() *Statement

type AnyXML

type AnyXML struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Config      *Value   `yang:"config"`
	Description *Value   `yang:"description"`
	IfFeature   []*Value `yang:"if-feature"`
	Mandatory   *Value   `yang:"mandatory"`
	Must        []*Must  `yang:"must"`
	Reference   *Value   `yang:"reference"`
	Status      *Value   `yang:"status"`
	When        *Value   `yang:"when"`
}

An AnyXML is defined in: http://tools.ietf.org/html/rfc6020#section-7.10

func (*AnyXML) Exts

func (s *AnyXML) Exts() []*Statement

func (AnyXML) Kind

func (AnyXML) Kind() string

func (*AnyXML) NName

func (s *AnyXML) NName() string

func (*AnyXML) ParentNode

func (s *AnyXML) ParentNode() Node

func (*AnyXML) Statement

func (s *AnyXML) Statement() *Statement

type Argument

type Argument struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	YinElement *Value `yang:"yin-element"`
}

An Argument is defined in: http://tools.ietf.org/html/rfc6020#section-7.17.2

func (*Argument) Exts

func (s *Argument) Exts() []*Statement

func (Argument) Kind

func (Argument) Kind() string

func (*Argument) NName

func (s *Argument) NName() string

func (*Argument) ParentNode

func (s *Argument) ParentNode() Node

func (*Argument) Statement

func (s *Argument) Statement() *Statement

type Augment

type Augment struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Anydata     []*AnyData   `yang:"anydata"`
	Action      []*Action    `yang:"action"`
	Anyxml      []*AnyXML    `yang:"anyxml"`
	Case        []*Case      `yang:"case"`
	Choice      []*Choice    `yang:"choice"`
	Container   []*Container `yang:"container"`
	Description *Value       `yang:"description"`
	IfFeature   []*Value     `yang:"if-feature"`
	Leaf        []*Leaf      `yang:"leaf"`
	LeafList    []*LeafList  `yang:"leaf-list"`
	List        []*List      `yang:"list"`
	Reference   *Value       `yang:"reference"`
	Status      *Value       `yang:"status"`
	Uses        []*Uses      `yang:"uses"`
	When        *Value       `yang:"when"`
}

An Augment is defined in: http://tools.ietf.org/html/rfc6020#section-7.15 and http://tools.ietf.org/html/rfc7950#section-7.17 ("action" sub-statement)

func (*Augment) Exts

func (s *Augment) Exts() []*Statement

func (Augment) Kind

func (Augment) Kind() string

func (*Augment) NName

func (s *Augment) NName() string

func (*Augment) ParentNode

func (s *Augment) ParentNode() Node

func (*Augment) Statement

func (s *Augment) Statement() *Statement

type BelongsTo

type BelongsTo struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Prefix *Value `yang:"prefix,required"`
}

A BelongsTo is defined in: http://tools.ietf.org/html/rfc6020#section-7.2.2

func (*BelongsTo) Exts

func (s *BelongsTo) Exts() []*Statement

func (BelongsTo) Kind

func (BelongsTo) Kind() string

func (*BelongsTo) NName

func (s *BelongsTo) NName() string

func (*BelongsTo) ParentNode

func (s *BelongsTo) ParentNode() Node

func (*BelongsTo) Statement

func (s *BelongsTo) Statement() *Statement

type Bit

type Bit struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Description *Value `yang:"description"`
	Reference   *Value `yang:"reference"`
	Status      *Value `yang:"status"`
	Position    *Value `yang:"position"`
}

A Bit is defined in: http://tools.ietf.org/html/rfc6020#section-9.7.4

func (*Bit) Exts

func (s *Bit) Exts() []*Statement

func (Bit) Kind

func (Bit) Kind() string

func (*Bit) NName

func (s *Bit) NName() string

func (*Bit) ParentNode

func (s *Bit) ParentNode() Node

func (*Bit) Statement

func (s *Bit) Statement() *Statement

type Case

type Case struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Anydata     []*AnyData   `yang:"anydata"`
	Anyxml      []*AnyXML    `yang:"anyxml"`
	Choice      []*Choice    `yang:"choice"`
	Container   []*Container `yang:"container"`
	Description *Value       `yang:"description"`
	IfFeature   []*Value     `yang:"if-feature"`
	Leaf        []*Leaf      `yang:"leaf"`
	LeafList    []*LeafList  `yang:"leaf-list"`
	List        []*List      `yang:"list"`
	Reference   *Value       `yang:"reference"`
	Status      *Value       `yang:"status"`
	Uses        []*Uses      `yang:"uses"`
	When        *Value       `yang:"when"`
}

A Case is defined in: http://tools.ietf.org/html/rfc6020#section-7.9.2

func (*Case) Exts

func (s *Case) Exts() []*Statement

func (Case) Kind

func (Case) Kind() string

func (*Case) NName

func (s *Case) NName() string

func (*Case) ParentNode

func (s *Case) ParentNode() Node

func (*Case) Statement

func (s *Case) Statement() *Statement

type Choice

type Choice struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Anydata     []*AnyData   `yang:"anydata"`
	Anyxml      []*AnyXML    `yang:"anyxml"`
	Case        []*Case      `yang:"case"`
	Choice      []*Choice    `yang:"choice"`
	Config      *Value       `yang:"config"`
	Container   []*Container `yang:"container"`
	Default     *Value       `yang:"default"`
	Description *Value       `yang:"description"`
	IfFeature   []*Value     `yang:"if-feature"`
	Leaf        []*Leaf      `yang:"leaf"`
	LeafList    []*LeafList  `yang:"leaf-list"`
	List        []*List      `yang:"list"`
	Mandatory   *Value       `yang:"mandatory"`
	Reference   *Value       `yang:"reference"`
	Status      *Value       `yang:"status"`
	When        *Value       `yang:"when"`
}

A Choice is defined in: http://tools.ietf.org/html/rfc6020#section-7.9

func (*Choice) Exts

func (s *Choice) Exts() []*Statement

func (Choice) Kind

func (Choice) Kind() string

func (*Choice) NName

func (s *Choice) NName() string

func (*Choice) ParentNode

func (s *Choice) ParentNode() Node

func (*Choice) Statement

func (s *Choice) Statement() *Statement

type Container

type Container struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Anydata     []*AnyData   `yang:"anydata"`
	Action      []*Action    `yang:"action"`
	Anyxml      []*AnyXML    `yang:"anyxml"`
	Choice      []*Choice    `yang:"choice"`
	Config      *Value       `yang:"config"`
	Container   []*Container `yang:"container"`
	Description *Value       `yang:"description"`
	Grouping    []*Grouping  `yang:"grouping"`
	IfFeature   []*Value     `yang:"if-feature"`
	Leaf        []*Leaf      `yang:"leaf"`
	LeafList    []*LeafList  `yang:"leaf-list"`
	List        []*List      `yang:"list"`
	Must        []*Must      `yang:"must"`
	Presence    *Value       `yang:"presence"`
	Reference   *Value       `yang:"reference"`
	Status      *Value       `yang:"status"`
	Typedef     []*Typedef   `yang:"typedef"`
	Uses        []*Uses      `yang:"uses"`
	When        *Value       `yang:"when"`
}

A Container is defined in: http://tools.ietf.org/html/rfc6020#section-7.5 and http://tools.ietf.org/html/rfc7950#section-7.5 ("action" sub-statement)

func (*Container) Exts

func (s *Container) Exts() []*Statement

func (*Container) Groupings

func (s *Container) Groupings() []*Grouping

func (Container) Kind

func (Container) Kind() string

func (*Container) NName

func (s *Container) NName() string

func (*Container) ParentNode

func (s *Container) ParentNode() Node

func (*Container) Statement

func (s *Container) Statement() *Statement

func (*Container) Typedefs

func (s *Container) Typedefs() []*Typedef

type Deviate

type Deviate struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Config      *Value   `yang:"config"`
	Default     *Value   `yang:"default"`
	Mandatory   *Value   `yang:"mandatory"`
	MaxElements *Value   `yang:"max-elements"`
	MinElements *Value   `yang:"min-elements"`
	Must        []*Must  `yang:"must"`
	Type        *Type    `yang:"type"`
	Unique      []*Value `yang:"unique"`
	Units       *Value   `yang:"units"`
}

A Deviate is defined in: http://tools.ietf.org/html/rfc6020#section-7.18.3.2

func (*Deviate) Exts

func (s *Deviate) Exts() []*Statement

func (Deviate) Kind

func (Deviate) Kind() string

func (*Deviate) NName

func (s *Deviate) NName() string

func (*Deviate) ParentNode

func (s *Deviate) ParentNode() Node

func (*Deviate) Statement

func (s *Deviate) Statement() *Statement

type DeviatedEntry

type DeviatedEntry struct {
	Type         deviationType // Type specifies the deviation type.
	DeviatedPath string        // DeviatedPath corresponds to the path that is being deviated.
	// Entry is the embedded Entry storing the deviations that are made. Fields
	// are set to the value in the schema after the deviation has been applied.
	*Entry
}

DeviatedEntry stores a wrapped Entry that corresponds to a deviation.

type Deviation

type Deviation struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Description *Value     `yang:"description"`
	Deviate     []*Deviate `yang:"deviate,required"`
	Reference   *Value     `yang:"reference"`
}

A Deviation is defined in: http://tools.ietf.org/html/rfc6020#section-7.18.3

func (*Deviation) Exts

func (s *Deviation) Exts() []*Statement

func (Deviation) Kind

func (Deviation) Kind() string

func (*Deviation) NName

func (s *Deviation) NName() string

func (*Deviation) ParentNode

func (s *Deviation) ParentNode() Node

func (*Deviation) Statement

func (s *Deviation) Statement() *Statement

type Element

type Element struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	YinElement *Value `yang:"yin-element"`
}

An Element is defined in: http://tools.ietf.org/html/rfc6020#section-7.17.2.2

func (*Element) Exts

func (s *Element) Exts() []*Statement

func (Element) Kind

func (Element) Kind() string

func (*Element) NName

func (s *Element) NName() string

func (*Element) ParentNode

func (s *Element) ParentNode() Node

func (*Element) Statement

func (s *Element) Statement() *Statement

type Entry

type Entry struct {
	Parent      *Entry    `json:"-"`
	Node        Node      `json:"-"` // the base node this Entry was derived from.
	Name        string    // our name, same as the key in our parent Dirs
	Description string    `json:",omitempty"` // description from node, if any
	Default     string    `json:",omitempty"` // default from node, if any
	Units       string    `json:",omitempty"` // units associated with the type, if any
	Errors      []error   `json:"-"`          // list of errors encountered on this node
	Kind        EntryKind // kind of Entry
	Config      TriState  // config state of this entry, if known
	Prefix      *Value    `json:",omitempty"` // prefix to use from this point down
	Mandatory   TriState  `json:",omitempty"` // whether this entry is mandatory in the tree

	// Fields associated with directory nodes
	Dir map[string]*Entry `json:",omitempty"`
	Key string            `json:",omitempty"` // Optional key name for lists (i.e., maps)

	// Fields associated with leaf nodes
	Type *YangType    `json:",omitempty"`
	Exts []*Statement `json:",omitempty"` // extensions found

	// Fields associated with list nodes (both lists and leaf-lists)
	ListAttr *ListAttr `json:",omitempty"`

	RPC *RPCEntry `json:",omitempty"` // set if we are an RPC

	// Identities that are defined in this context, this is set if the Entry
	// is a module only.
	Identities []*Identity `json:",omitempty"`

	Augments   []*Entry                   `json:",omitempty"` // Augments defined in this entry.
	Augmented  []*Entry                   `json:",omitempty"` // Augments merged into this entry.
	Deviations []*DeviatedEntry           `json:"-"`          // Deviations associated with this entry.
	Deviate    map[deviationType][]*Entry `json:"-"`
	Uses       []*UsesStmt                `json:",omitempty"` // Uses merged into this entry.

	// Extra maps all the unsupported fields to their values
	Extra map[string][]interface{} `json:"-"`

	// Annotation stores annotated values, and is not populated by this
	// library but rather can be used by calling code where additional
	// information should be stored alongside the Entry.
	Annotation map[string]interface{} `json:",omitempty"`
	// contains filtered or unexported fields
}

An Entry represents a single node (directory or leaf) created from the AST. Directory entries have a non-nil Dir entry. Leaf nodes have a nil Dir entry. If Errors is not nil then the only other valid field is Node.

func GetModule

func GetModule(name string, sources ...string) (*Entry, []error)

GetModule optionally reads in a set of YANG source files, named by sources, and then returns the Entry for the module named module. If sources is missing, or the named module is not yet known, GetModule searches for name with the suffix ".yang". GetModule either returns an Entry or returns one or more errors.

GetModule is a convience function for calling NewModules, Read, and Process, and then looking up the module name.

func ToEntry

func ToEntry(n Node) (e *Entry)

ToEntry expands node n into a directory Entry. Expansion is based on the YANG tags in the structure behind n. ToEntry must only be used with nodes that are directories, such as top level modules and sub-modules. ToEntry never returns nil. Any errors encountered are found in the Errors fields of the returned Entry and its children. Use GetErrors to determine if there were any errors.

func (*Entry) ApplyDeviate

func (e *Entry) ApplyDeviate() []error

ApplyDeviate walks the deviations within the supplied entry, and applies them to the schema.

func (*Entry) Augment

func (e *Entry) Augment(addErrors bool) (processed, skipped int)

Augment processes augments in e, return the number of augments processed and the augments skipped. If addErrors is true then missing augments will generate errors.

func (*Entry) DefaultValue

func (e *Entry) DefaultValue() string

DefaultValue returns the schema default value for e, if any. If the leaf has no explicit default, its type default (if any) will be used.

func (*Entry) Find

func (e *Entry) Find(name string) *Entry

Find finds the Entry named by name relative to e.

func (*Entry) FixChoice

func (e *Entry) FixChoice()

FixChoice inserts missing Case entries in a choice

func (*Entry) GetErrors

func (e *Entry) GetErrors() []error

GetErrors returns a sorted list of errors found in e.

func (*Entry) GetWhenXPath

func (e *Entry) GetWhenXPath() (string, bool)

GetWhenXPath returns the when XPath statement of e if able.

func (*Entry) InstantiatingModule

func (e *Entry) InstantiatingModule() (string, error)

InstantiatingModule returns the YANG module which instanitated the Entry within the schema tree - using the same rules described in the documentation of the Namespace function. The namespace is resolved in the module name. This approach to namespacing is used when serialising YANG-modelled data to JSON as per RFC7951.

func (*Entry) IsCase

func (e *Entry) IsCase() bool

IsCase returns true if the entry is a case node within the schema.

func (*Entry) IsChoice

func (e *Entry) IsChoice() bool

IsChoice returns true if the entry is a choice node within the schema.

func (*Entry) IsContainer

func (e *Entry) IsContainer() bool

IsContainer returns true if e is a container.

func (*Entry) IsDir

func (e *Entry) IsDir() bool

IsDir returns true if e is a directory.

func (*Entry) IsLeaf

func (e *Entry) IsLeaf() bool

IsLeaf returns true if e is a leaf i.e. is not a container, list, leaf-list, choice or case statement.

func (*Entry) IsLeafList

func (e *Entry) IsLeafList() bool

IsLeafList returns true if e is a leaf-list.

func (*Entry) IsList

func (e *Entry) IsList() bool

IsList returns true if e is a list.

func (*Entry) Modules

func (e *Entry) Modules() *Modules

Modules returns the Modules structure that e is part of. This is needed when looking for rooted nodes not part of this Entry tree.

func (*Entry) Namespace

func (e *Entry) Namespace() *Value

Namespace returns the YANG/XML namespace Value for e as mounted in the Entry tree (e.g., as placed by grouping statements).

Per RFC6020 section 7.12, the namespace on elements in the tree due to a "uses" statement is that of the where the uses statement occurs, i.e., the user, rather than creator (grouping) of those elements, so we follow the usage (Entry) tree up to the parent before obtaining the (then adjacent) root node for its namespace Value.

func (*Entry) Path

func (e *Entry) Path() string

Path returns the path to e. A nil Entry returns "".

func (*Entry) Print

func (e *Entry) Print(w io.Writer)

Print prints e to w in human readable form.

func (*Entry) ReadOnly

func (e *Entry) ReadOnly() bool

ReadOnly returns true if e is a read-only variable (config == false). If Config is unset in e, then false is returned if e has no parent, otherwise the value parent's ReadOnly is returned.

type EntryKind

type EntryKind int

An EntryKind is the kind of node an Entry is. All leaf nodes are of kind LeafEntry. A LeafList is also considered a leaf node. All other kinds are directory nodes.

func (EntryKind) String

func (k EntryKind) String() string

type Enum

type Enum struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Description *Value `yang:"description"`
	Reference   *Value `yang:"reference"`
	Status      *Value `yang:"status"`
	Value       *Value `yang:"value"`
}

An Enum is defined in: http://tools.ietf.org/html/rfc6020#section-9.6.4

func (*Enum) Exts

func (s *Enum) Exts() []*Statement

func (Enum) Kind

func (Enum) Kind() string

func (*Enum) NName

func (s *Enum) NName() string

func (*Enum) ParentNode

func (s *Enum) ParentNode() Node

func (*Enum) Statement

func (s *Enum) Statement() *Statement

type EnumType

type EnumType struct {
	// contains filtered or unexported fields
}

A EnumType represents a mapping of strings to integers. It is used both for enumerations as well as bitfields.

func NewBitfield

func NewBitfield() *EnumType

NewBitfield returns an EnumType initialized as a bitfield. Multiple string values may map to the same numeric values. Numeric values must be small non-negative integers.

func NewEnumType

func NewEnumType() *EnumType

NewEnumType returns an initialized EnumType.

func (*EnumType) IsDefined

func (e *EnumType) IsDefined(name string) bool

IsDefined returns true if name is defined in e, else false.

func (*EnumType) Name

func (e *EnumType) Name(value int64) string

Name returns the name in e associated with value. The empty string is returned if no name has been assigned to value.

func (*EnumType) NameMap

func (e *EnumType) NameMap() map[string]int64

NameMap returns a map of names to values.

func (*EnumType) Names

func (e *EnumType) Names() []string

Names returns the sorted list of enum string names.

func (*EnumType) Set

func (e *EnumType) Set(name string, value int64) error

Set sets name in e to the provided value. Set returns an error if the value is invalid, name is already signed, or when used as an enum rather than a bitfield, the value has previousl been used. When two different names are assigned to the same value, the conversion from value to name will result in the most recently assigned name.

func (*EnumType) SetNext

func (e *EnumType) SetNext(name string) error

SetNext sets the name in e using the next possible value that is greater than all previous values.

func (*EnumType) Value

func (e *EnumType) Value(name string) int64

Value returns the value associated with name in e associated. 0 is returned if name is not in e, or if it is the first value in an unnumbered enum. Use IsDefined to definitively confirm name is in e.

func (*EnumType) ValueMap

func (e *EnumType) ValueMap() map[int64]string

ValueMap returns a map of values to names.

func (*EnumType) Values

func (e *EnumType) Values() []int64

Values returns the sorted list of enum values.

type ErrorNode

type ErrorNode struct {
	Parent Node `yang:"Parent,nomerge"`

	Error error
}

An ErrorNode is a node that only contains an error.

func (*ErrorNode) Exts

func (s *ErrorNode) Exts() []*Statement

func (ErrorNode) Kind

func (ErrorNode) Kind() string

func (*ErrorNode) NName

func (s *ErrorNode) NName() string

func (*ErrorNode) ParentNode

func (s *ErrorNode) ParentNode() Node

func (*ErrorNode) Statement

func (s *ErrorNode) Statement() *Statement

type Extension

type Extension struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Argument    *Argument `yang:"argument"`
	Description *Value    `yang:"description"`
	Reference   *Value    `yang:"reference"`
	Status      *Value    `yang:"status"`
}

An Extension is defined in: http://tools.ietf.org/html/rfc6020#section-7.17

func (*Extension) Exts

func (s *Extension) Exts() []*Statement

func (Extension) Kind

func (Extension) Kind() string

func (*Extension) NName

func (s *Extension) NName() string

func (*Extension) ParentNode

func (s *Extension) ParentNode() Node

func (*Extension) Statement

func (s *Extension) Statement() *Statement

type Feature

type Feature struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Description *Value   `yang:"description"`
	IfFeature   []*Value `yang:"if-feature"`
	Status      *Value   `yang:"status"`
	Reference   *Value   `yang:"reference"`
}

A Feature is defined in: http://tools.ietf.org/html/rfc6020#section-7.18.1

func (*Feature) Exts

func (s *Feature) Exts() []*Statement

func (Feature) Kind

func (Feature) Kind() string

func (*Feature) NName

func (s *Feature) NName() string

func (*Feature) ParentNode

func (s *Feature) ParentNode() Node

func (*Feature) Statement

func (s *Feature) Statement() *Statement

type Grouping

type Grouping struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Anydata     []*AnyData   `yang:"anydata"`
	Action      []*Action    `yang:"action"`
	Anyxml      []*AnyXML    `yang:"anyxml"`
	Choice      []*Choice    `yang:"choice"`
	Container   []*Container `yang:"container"`
	Description *Value       `yang:"description"`
	Grouping    []*Grouping  `yang:"grouping"`
	Leaf        []*Leaf      `yang:"leaf"`
	LeafList    []*LeafList  `yang:"leaf-list"`
	List        []*List      `yang:"list"`
	Reference   *Value       `yang:"reference"`
	Status      *Value       `yang:"status"`
	Typedef     []*Typedef   `yang:"typedef"`
	Uses        []*Uses      `yang:"uses"`
}

A Grouping is defined in: http://tools.ietf.org/html/rfc6020#section-7.11 and http://tools.ietf.org/html/rfc7950#section-7.12 ("action" sub-statement)

func FindGrouping

func FindGrouping(n Node, name string, seen map[string]bool) *Grouping

FindGrouping finds the grouping named name in one of the parent node's grouping fields, seen provides a list of the modules previously seen by FindGrouping during traversal. If no parent has the named grouping, nil is returned. Imported and included modules are also checked.

func (*Grouping) Exts

func (s *Grouping) Exts() []*Statement

func (*Grouping) Groupings

func (s *Grouping) Groupings() []*Grouping

func (Grouping) Kind

func (Grouping) Kind() string

func (*Grouping) NName

func (s *Grouping) NName() string

func (*Grouping) ParentNode

func (s *Grouping) ParentNode() Node

func (*Grouping) Statement

func (s *Grouping) Statement() *Statement

func (*Grouping) Typedefs

func (s *Grouping) Typedefs() []*Typedef

type Identity

type Identity struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge" json:"-"`
	Parent     Node         `yang:"Parent,nomerge" json:"-"`
	Extensions []*Statement `yang:"Ext" json:"-"`

	Base        *Value      `yang:"base" json:"-"`
	Description *Value      `yang:"description" json:"-"`
	Reference   *Value      `yang:"reference" json:"-"`
	Status      *Value      `yang:"status" json:"-"`
	Values      []*Identity `json:",omitempty"`
}

An Identity is defined in: http://tools.ietf.org/html/rfc6020#section-7.16

func (*Identity) Exts

func (s *Identity) Exts() []*Statement

func (*Identity) GetValue

func (s *Identity) GetValue(name string) *Identity

GetValue returns a pointer to the identity with name "name" that is within the values of the identity

func (*Identity) IsDefined

func (s *Identity) IsDefined(name string) bool

IsDefined behaves the same as the implementation for Enum - it returns true if an identity with the name is defined within the Values of the identity

func (Identity) Kind

func (Identity) Kind() string

func (*Identity) NName

func (s *Identity) NName() string

func (*Identity) ParentNode

func (s *Identity) ParentNode() Node

func (*Identity) PrefixedName

func (s *Identity) PrefixedName() string

PrefixedName returns the prefix-qualified name for the identity

func (*Identity) Statement

func (s *Identity) Statement() *Statement

type Import

type Import struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Prefix       *Value `yang:"prefix,required"`
	RevisionDate *Value `yang:"revision-date"`
	Reference    *Value `yang:"reference,nomerge"`
	Description  *Value `yang:"description,nomerge"`

	// Module is the imported module.  The types and groupings are
	// available to the importer with the defined prefix.
	Module *Module
}

An Import is defined in: http://tools.ietf.org/html/rfc6020#section-7.1.5

func (*Import) Exts

func (s *Import) Exts() []*Statement

func (Import) Kind

func (Import) Kind() string

func (*Import) NName

func (s *Import) NName() string

func (*Import) ParentNode

func (s *Import) ParentNode() Node

func (*Import) Statement

func (s *Import) Statement() *Statement

type Include

type Include struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	RevisionDate *Value `yang:"revision-date"`

	// Module is the included module.  The types and groupings are
	// available to the importer with the defined prefix.
	Module *Module
}

An Include is defined in: http://tools.ietf.org/html/rfc6020#section-7.1.6

func (*Include) Exts

func (s *Include) Exts() []*Statement

func (Include) Kind

func (Include) Kind() string

func (*Include) NName

func (s *Include) NName() string

func (*Include) ParentNode

func (s *Include) ParentNode() Node

func (*Include) Statement

func (s *Include) Statement() *Statement

type Input

type Input struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Anydata   []*AnyData   `yang:"anydata"`
	Anyxml    []*AnyXML    `yang:"anyxml"`
	Choice    []*Choice    `yang:"choice"`
	Container []*Container `yang:"container"`
	Grouping  []*Grouping  `yang:"grouping"`
	Leaf      []*Leaf      `yang:"leaf"`
	LeafList  []*LeafList  `yang:"leaf-list"`
	List      []*List      `yang:"list"`
	Typedef   []*Typedef   `yang:"typedef"`
	Uses      []*Uses      `yang:"uses"`
}

An Input is defined in: http://tools.ietf.org/html/rfc6020#section-7.13.2

func (*Input) Exts

func (s *Input) Exts() []*Statement

func (*Input) Groupings

func (s *Input) Groupings() []*Grouping

func (Input) Kind

func (Input) Kind() string

func (*Input) NName

func (s *Input) NName() string

func (*Input) ParentNode

func (s *Input) ParentNode() Node

func (*Input) Statement

func (s *Input) Statement() *Statement

func (*Input) Typedefs

func (s *Input) Typedefs() []*Typedef

type Leaf

type Leaf struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Config      *Value   `yang:"config"`
	Default     *Value   `yang:"default"`
	Description *Value   `yang:"description"`
	IfFeature   []*Value `yang:"if-feature"`
	Mandatory   *Value   `yang:"mandatory"`
	Must        []*Must  `yang:"must"`
	Reference   *Value   `yang:"reference"`
	Status      *Value   `yang:"status"`
	Type        *Type    `yang:"type,required"`
	Units       *Value   `yang:"units"`
	When        *Value   `yang:"when"`
}

A Leaf is defined in: http://tools.ietf.org/html/rfc6020#section-7.6

func (*Leaf) Exts

func (s *Leaf) Exts() []*Statement

func (Leaf) Kind

func (Leaf) Kind() string

func (*Leaf) NName

func (s *Leaf) NName() string

func (*Leaf) ParentNode

func (s *Leaf) ParentNode() Node

func (*Leaf) Statement

func (s *Leaf) Statement() *Statement

type LeafList

type LeafList struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Config      *Value   `yang:"config"`
	Default     *Value   `yang:"default"`
	Description *Value   `yang:"description"`
	IfFeature   []*Value `yang:"if-feature"`
	MaxElements *Value   `yang:"max-elements"`
	MinElements *Value   `yang:"min-elements"`
	Must        []*Must  `yang:"must"`
	OrderedBy   *Value   `yang:"ordered-by"`
	Reference   *Value   `yang:"reference"`
	Status      *Value   `yang:"status"`
	Type        *Type    `yang:"type,required"`
	Units       *Value   `yang:"units"`
	When        *Value   `yang:"when"`
}

A LeafList is defined in: http://tools.ietf.org/html/rfc6020#section-7.7 It this is supposed to be an array of nodes..

func (*LeafList) Exts

func (s *LeafList) Exts() []*Statement

func (LeafList) Kind

func (LeafList) Kind() string

func (*LeafList) NName

func (s *LeafList) NName() string

func (*LeafList) ParentNode

func (s *LeafList) ParentNode() Node

func (*LeafList) Statement

func (s *LeafList) Statement() *Statement

type Length

type Length struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Description  *Value `yang:"description"`
	ErrorAppTag  *Value `yang:"error-app-tag"`
	ErrorMessage *Value `yang:"error-message"`
	Reference    *Value `yang:"reference"`
}

A Length is defined in: http://tools.ietf.org/html/rfc6020#section-9.4.4

func (*Length) Exts

func (s *Length) Exts() []*Statement

func (Length) Kind

func (Length) Kind() string

func (*Length) NName

func (s *Length) NName() string

func (*Length) ParentNode

func (s *Length) ParentNode() Node

func (*Length) Statement

func (s *Length) Statement() *Statement

type List

type List struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Anydata     []*AnyData   `yang:"anydata"`
	Action      []*Action    `yang:"action"`
	Anyxml      []*AnyXML    `yang:"anyxml"`
	Choice      []*Choice    `yang:"choice"`
	Config      *Value       `yang:"config"`
	Container   []*Container `yang:"container"`
	Description *Value       `yang:"description"`
	Grouping    []*Grouping  `yang:"grouping"`
	IfFeature   []*Value     `yang:"if-feature"`
	Key         *Value       `yang:"key"`
	Leaf        []*Leaf      `yang:"leaf"`
	LeafList    []*LeafList  `yang:"leaf-list"`
	List        []*List      `yang:"list"`
	MaxElements *Value       `yang:"max-elements"`
	MinElements *Value       `yang:"min-elements"`
	Must        []*Must      `yang:"must"`
	OrderedBy   *Value       `yang:"ordered-by"`
	Reference   *Value       `yang:"reference"`
	Status      *Value       `yang:"status"`
	Typedef     []*Typedef   `yang:"typedef"`
	Unique      []*Value     `yang:"unique"`
	Uses        []*Uses      `yang:"uses"`
	When        *Value       `yang:"when"`
}

A List is defined in: http://tools.ietf.org/html/rfc6020#section-7.8 and http://tools.ietf.org/html/rfc7950#section-7.8 ("action" sub-statement)

func (*List) Exts

func (s *List) Exts() []*Statement

func (*List) Groupings

func (s *List) Groupings() []*Grouping

func (List) Kind

func (List) Kind() string

func (*List) NName

func (s *List) NName() string

func (*List) ParentNode

func (s *List) ParentNode() Node

func (*List) Statement

func (s *List) Statement() *Statement

func (*List) Typedefs

func (s *List) Typedefs() []*Typedef

type ListAttr

type ListAttr struct {
	MinElements *Value // leaf-list or list MUST have at least min-elements
	MaxElements *Value // leaf-list or list has at most max-elements
	OrderedBy   *Value // order of entries determined by "system" or "user"
}

A ListAttr is associated with an Entry that represents a List node

type Module

type Module struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Anydata      []*AnyData      `yang:"anydata"`
	Anyxml       []*AnyXML       `yang:"anyxml"`
	Augment      []*Augment      `yang:"augment"`
	BelongsTo    *BelongsTo      `yang:"belongs-to,required=submodule,nomerge"`
	Choice       []*Choice       `yang:"choice"`
	Contact      *Value          `yang:"contact,nomerge"`
	Container    []*Container    `yang:"container"`
	Description  *Value          `yang:"description,nomerge"`
	Deviation    []*Deviation    `yang:"deviation"`
	Extension    []*Extension    `yang:"extension"`
	Feature      []*Feature      `yang:"feature"`
	Grouping     []*Grouping     `yang:"grouping"`
	Identity     []*Identity     `yang:"identity"`
	Import       []*Import       `yang:"import"`
	Include      []*Include      `yang:"include"`
	Leaf         []*Leaf         `yang:"leaf"`
	LeafList     []*LeafList     `yang:"leaf-list"`
	List         []*List         `yang:"list"`
	Namespace    *Value          `yang:"namespace,required=module,nomerge"`
	Notification []*Notification `yang:"notification"`
	Organization *Value          `yang:"organization,nomerge"`
	Prefix       *Value          `yang:"prefix,required=module,nomerge"`
	Reference    *Value          `yang:"reference,nomerge"`
	Revision     []*Revision     `yang:"revision,nomerge"`
	RPC          []*RPC          `yang:"rpc"`
	Typedef      []*Typedef      `yang:"typedef"`
	Uses         []*Uses         `yang:"uses"`
	YangVersion  *Value          `yang:"yang-version,nomerge"`
	// contains filtered or unexported fields
}

A Module is defined in: http://tools.ietf.org/html/rfc6020#section-7.1

A SubModule is defined in: http://tools.ietf.org/html/rfc6020#section-7.2

func FindModuleByPrefix

func FindModuleByPrefix(n Node, prefix string) *Module

FindModuleByPrefix finds the module or submodule with the provided prefix relative to where n was defined. If the prefix cannot be resolved then nil is returned.

func RootNode

func RootNode(n Node) *Module

RootNode returns the submodule or module that n was defined in.

func (*Module) Current

func (s *Module) Current() string

Current returns the most recent revision of this module, or "" if the module has no revisions.

func (*Module) Exts

func (s *Module) Exts() []*Statement

func (*Module) FullName

func (s *Module) FullName() string

FullName returns the full name of the module including the most recent revision, if any.

func (*Module) GetPrefix

func (s *Module) GetPrefix() string

GetPrefix returns the proper prefix of m. Useful when looking up types in modules found by FindModuleByPrefix.

func (*Module) Groupings

func (s *Module) Groupings() []*Grouping

func (*Module) Identities

func (s *Module) Identities() []*Identity

func (*Module) Kind

func (s *Module) Kind() string

func (*Module) NName

func (s *Module) NName() string

func (*Module) ParentNode

func (s *Module) ParentNode() Node

func (*Module) Statement

func (s *Module) Statement() *Statement

func (*Module) Typedefs

func (s *Module) Typedefs() []*Typedef

type Modules

type Modules struct {
	Modules    map[string]*Module // All "module" nodes
	SubModules map[string]*Module // All "submodule" nodes
	// contains filtered or unexported fields
}

Modules contains information about all the top level modules and submodules that are read into it via its Read method.

func NewModules

func NewModules() *Modules

NewModules returns a newly created and initialized Modules.

func (*Modules) FindModule

func (ms *Modules) FindModule(n Node) *Module

FindModule returns the Module/Submodule specified by n, which must be a *Include or *Import. If n is a *Include then a submodule is returned. If n is a *Import then a module is returned.

func (*Modules) FindModuleByNamespace

func (ms *Modules) FindModuleByNamespace(ns string) (*Module, error)

FindModuleByNamespace either returns the Module specified by the namespace or returns an error.

func (*Modules) FindModuleByPrefix

func (ms *Modules) FindModuleByPrefix(prefix string) (*Module, error)

FindModuleByPrefix either returns the Module specified by prefix or returns an error.

func (*Modules) GetModule

func (ms *Modules) GetModule(name string) (*Entry, []error)

GetModule returns the Entry of the module named by name. GetModule will search for and read the file named name + ".yang" if it cannot satisfy the request from what it has currntly read.

GetModule is a convience function for calling Read and Process, and then looking up the module name. It is safe to call Read and Process prior to calling GetModule.

func (*Modules) Parse

func (ms *Modules) Parse(data, name string) error

Parse parses data as YANG source and adds it to ms. The name should reflect the source of data.

func (*Modules) Process

func (ms *Modules) Process() []error

Process processes all the modules and submodules that have been read into ms. While processing, if an include or import is found for which there is no matching module, Process attempts to locate the source file (using Path) and automatically load them. If a file cannot be found then an error is returned. When looking for a source file, Process searches for a file using the module's or submodule's name with ".yang" appended. After searching the current directory, the directories in Path are searched.

Process builds Entry trees for each modules and submodules in ms. These trees are accessed using the ToEntry function. Process does augmentation on Entry trees once all the modules and submodules in ms have been built. Following augmentation, Process inserts implied case statements. I.e.,

choice interface-type {
    container ethernet { ... }
}

has a case statement inserted to become:

choice interface-type {
    case ethernet {
        container ethernet { ... }
    }
}

Process may return multiple errors if multiple errors were encountered while processing. Even though multiple errors may be returned, this does not mean these are all the errors. Process will terminate processing early based on the type and location of the error.

func (*Modules) Read

func (ms *Modules) Read(name string) error

Read reads the named yang module into ms. The name can be the name of an actual .yang file or a module/submodule name (the base name of a .yang file, e.g., foo.yang is named foo). An error is returned if the file is not found or there was an error parsing the file.

type Must

type Must struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Description  *Value `yang:"description"`
	ErrorAppTag  *Value `yang:"error-app-tag"`
	ErrorMessage *Value `yang:"error-message"`
	Reference    *Value `yang:"reference"`
}

A Must is defined in: http://tools.ietf.org/html/rfc6020#section-7.5.3

func (*Must) Exts

func (s *Must) Exts() []*Statement

func (Must) Kind

func (Must) Kind() string

func (*Must) NName

func (s *Must) NName() string

func (*Must) ParentNode

func (s *Must) ParentNode() Node

func (*Must) Statement

func (s *Must) Statement() *Statement

type Node

type Node interface {
	// Kind returns the kind of yang statement (the keyword).
	Kind() string
	// NName returns the node's name (the argument)
	NName() string
	// Statement returns the original Statement of this Node.
	Statement() *Statement
	// ParentNode returns the parent of this Node, or nil if the
	// Node has no parent.
	ParentNode() Node
	// Exts returns the list of extension statements found.
	Exts() []*Statement
}

A Node contains a yang statement and all attributes and sub-statements. Only pointers to structures should implement Node.

func BuildAST

func BuildAST(s *Statement) (Node, error)

BuildAST builds an abstract syntax tree based on the yang statement s. Normally it should return a *Module.

func ChildNode

func ChildNode(n Node, name string) Node

ChildNode finds n's child node named name. It returns nil if the node could not be found. ChildNode looks at every direct Node pointer in n as well as every node in all slices of Node pointers. Names must be non-ambiguous, otherwise ChildNode has a non-deterministic result.

func FindNode

func FindNode(n Node, path string) (Node, error)

FindNode finds the node referenced by path relative to n. If path does not reference a node then nil is returned (i.e. path not found). The path looks similar to an XPath but curently has no wildcarding. For example: "/if:interfaces/if:interface" and "../config".

type Notification

type Notification struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Anydata     []*AnyData   `yang:"anydata"`
	Anyxml      []*AnyXML    `yang:"anyxml"`
	Choice      []*Choice    `yang:"choice"`
	Container   []*Container `yang:"container"`
	Description *Value       `yang:"description"`
	Grouping    []*Grouping  `yang:"grouping"`
	IfFeature   []*Value     `yang:"if-feature"`
	Leaf        []*Leaf      `yang:"leaf"`
	LeafList    []*LeafList  `yang:"leaf-list"`
	List        []*List      `yang:"list"`
	Reference   *Value       `yang:"reference"`
	Status      *Value       `yang:"status"`
	Typedef     []*Typedef   `yang:"typedef"`
	Uses        []*Uses      `yang:"uses"`
}

A Notification is defined in: http://tools.ietf.org/html/rfc6020#section-7.14

func (*Notification) Exts

func (s *Notification) Exts() []*Statement

func (*Notification) Groupings

func (s *Notification) Groupings() []*Grouping

func (Notification) Kind

func (Notification) Kind() string

func (*Notification) NName

func (s *Notification) NName() string

func (*Notification) ParentNode

func (s *Notification) ParentNode() Node

func (*Notification) Statement

func (s *Notification) Statement() *Statement

func (*Notification) Typedefs

func (s *Notification) Typedefs() []*Typedef

type Number

type Number struct {
	// Kind is the kind of number (+/-ve, min/max).
	Kind NumberKind
	// Absolute value of the number.
	Value uint64
	// Number of fractional digits.
	FractionDigits uint8
}

A Number is either an integer the range of [-(1<<64) - 1, (1<<64)-1], or a YANG decimal conforming to https://tools.ietf.org/html/rfc6020#section-9.3.4.

func DecimalValueFromString

func DecimalValueFromString(numStr string, fracDigRequired int) (n Number, err error)

DecimalValueFromString returns a decimal Number representation of inStr. If fracDigRequired is >= 0, the number is represented with fracDigRequired fractional digits, regardless of the precision of numStr, otherwise the precision of numStr is used to set the number of fractional digits. numStr must conform to Section 9.3.4.

func FromFloat

func FromFloat(f float64) Number

FromFloat creates a Number from a float64. Input values with absolute value larger than MaxInt64/MinInt64 are converted into maxNumber/minNumber.

func FromInt

func FromInt(i int64) Number

FromInt creates a Number from an int64.

func FromUint

func FromUint(i uint64) Number

FromUint creates a Number from a uint64.

func ParseNumber

func ParseNumber(s string) (n Number, err error)

ParseNumber returns s as a Number. Numbers may be represented in decimal, octal, or hexadecimal using the standard prefix notations (e.g., 0 and 0x)

func (Number) Equal

func (n Number) Equal(m Number) bool

Equal returns true if n is equal to m.

func (Number) Int

func (n Number) Int() (int64, error)

Int returns n as an int64. It returns an error if n overflows an int64 or the number is decimal.

func (Number) IsDecimal

func (n Number) IsDecimal() bool

IsDecimal reports whether n is a decimal number.

func (Number) Less

func (n Number) Less(m Number) bool

Less returns true if n is less than m. Panics if n and m are a mix of integer and decimal.

func (Number) String

func (n Number) String() string

String returns n as a string in decimal.

func (Number) Trunc

func (n Number) Trunc() uint64

Trunc returns the whole part of abs(n) as a signed integer.

type NumberKind

type NumberKind int

type Options

type Options struct {
	// IgnoreSubmoduleCircularDependencies specifies whether circular dependencies
	// between submodules. Setting this value to true will ensure that this
	// package will explicitly ignore the case where a submodule will include
	// itself through a circular reference.
	IgnoreSubmoduleCircularDependencies bool
	// StoreUses controls whether the Uses field of each YANG entry should be
	// populated. Setting this value to true will cause each Entry which is
	// generated within the schema to store the logical grouping from which it
	// is derived.
	StoreUses bool
}

Options defines the options that should be used when parsing YANG modules, including specific overrides for potentially problematic YANG constructs.

type Output

type Output struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Anydata   []*AnyData   `yang:"anydata"`
	Anyxml    []*AnyXML    `yang:"anyxml"`
	Choice    []*Choice    `yang:"choice"`
	Container []*Container `yang:"container"`
	Grouping  []*Grouping  `yang:"grouping"`
	Leaf      []*Leaf      `yang:"leaf"`
	LeafList  []*LeafList  `yang:"leaf-list"`
	List      []*List      `yang:"list"`
	Typedef   []*Typedef   `yang:"typedef"`
	Uses      []*Uses      `yang:"uses"`
}

An Output is defined in: http://tools.ietf.org/html/rfc6020#section-7.13.3

func (*Output) Exts

func (s *Output) Exts() []*Statement

func (*Output) Groupings

func (s *Output) Groupings() []*Grouping

func (Output) Kind

func (Output) Kind() string

func (*Output) NName

func (s *Output) NName() string

func (*Output) ParentNode

func (s *Output) ParentNode() Node

func (*Output) Statement

func (s *Output) Statement() *Statement

func (*Output) Typedefs

func (s *Output) Typedefs() []*Typedef

type Pattern

type Pattern struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Description  *Value `yang:"description"`
	ErrorAppTag  *Value `yang:"error-app-tag"`
	ErrorMessage *Value `yang:"error-message"`
	Reference    *Value `yang:"reference"`
}

A Pattern is defined in: http://tools.ietf.org/html/rfc6020#section-9.4.6

func (*Pattern) Exts

func (s *Pattern) Exts() []*Statement

func (Pattern) Kind

func (Pattern) Kind() string

func (*Pattern) NName

func (s *Pattern) NName() string

func (*Pattern) ParentNode

func (s *Pattern) ParentNode() Node

func (*Pattern) Statement

func (s *Pattern) Statement() *Statement

type RPC

type RPC struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Description *Value      `yang:"description"`
	Grouping    []*Grouping `yang:"grouping"`
	IfFeature   []*Value    `yang:"if-feature"`
	Input       *Input      `yang:"input"`
	Output      *Output     `yang:"output"`
	Reference   *Value      `yang:"reference"`
	Status      *Value      `yang:"status"`
	Typedef     []*Typedef  `yang:"typedef"`
}

An RPC is defined in: http://tools.ietf.org/html/rfc6020#section-7.13

func (*RPC) Exts

func (s *RPC) Exts() []*Statement

func (*RPC) Groupings

func (s *RPC) Groupings() []*Grouping

func (RPC) Kind

func (RPC) Kind() string

func (*RPC) NName

func (s *RPC) NName() string

func (*RPC) ParentNode

func (s *RPC) ParentNode() Node

func (*RPC) Statement

func (s *RPC) Statement() *Statement

func (*RPC) Typedefs

func (s *RPC) Typedefs() []*Typedef

type RPCEntry

type RPCEntry struct {
	Input  *Entry
	Output *Entry
}

An RPCEntry contains information related to an RPC Node.

type Range

type Range struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Description  *Value `yang:"description"`
	ErrorAppTag  *Value `yang:"error-app-tag"`
	ErrorMessage *Value `yang:"error-message"`
	Reference    *Value `yang:"reference"`
}

A Range is defined in: http://tools.ietf.org/html/rfc6020#section-9.2.4

func (*Range) Exts

func (s *Range) Exts() []*Statement

func (Range) Kind

func (Range) Kind() string

func (*Range) NName

func (s *Range) NName() string

func (*Range) ParentNode

func (s *Range) ParentNode() Node

func (*Range) Statement

func (s *Range) Statement() *Statement

type Refine

type Refine struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Default     []*Value `yang:"default"`
	Description *Value   `yang:"description"`
	Reference   *Value   `yang:"reference"`
	Config      *Value   `yang:"config"`
	Mandatory   *Value   `yang:"mandatory"`
	Presence    *Value   `yang:"presence"`
	Must        []*Must  `yang:"must"`
	MaxElements *Value   `yang:"max-elements"`
	MinElements *Value   `yang:"min-elements"`
}

A Refine is defined in: http://tools.ietf.org/html/rfc6020#section-7.12.2

func (*Refine) Exts

func (s *Refine) Exts() []*Statement

func (Refine) Kind

func (Refine) Kind() string

func (*Refine) NName

func (s *Refine) NName() string

func (*Refine) ParentNode

func (s *Refine) ParentNode() Node

func (*Refine) Statement

func (s *Refine) Statement() *Statement

type Revision

type Revision struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Description *Value `yang:"description"`
	Reference   *Value `yang:"reference"`
}

A Revision is defined in: http://tools.ietf.org/html/rfc6020#section-7.1.9

func (*Revision) Exts

func (s *Revision) Exts() []*Statement

func (Revision) Kind

func (Revision) Kind() string

func (*Revision) NName

func (s *Revision) NName() string

func (*Revision) ParentNode

func (s *Revision) ParentNode() Node

func (*Revision) Statement

func (s *Revision) Statement() *Statement

type Statement

type Statement struct {
	Keyword     string
	HasArgument bool
	Argument    string
	// contains filtered or unexported fields
}

A Statement is a generic YANG statement. A Statement may have optional sub-statement (i.e., a Statement is a tree).

func FakeStatement

func FakeStatement(keyword, file string, line, col int) *Statement

FakeStatement returns a statement filled in with keyword, file, line and col.

func Parse

func Parse(input, path string) ([]*Statement, error)

Parse parses the input as generic YANG and returns the statements parsed. The path parameter should be the source name where input was read from (e.g., the file name the input was read from). If one more more errors are encountered, nil and an error are returned. The error's text includes all errors encountered.

func (*Statement) Arg

func (s *Statement) Arg() (string, bool)

Arg returns the optional argument to s. It returns false if s has no argument.

func (*Statement) Exts

func (s *Statement) Exts() []*Statement

func (*Statement) Kind

func (s *Statement) Kind() string

func (*Statement) Location

func (s *Statement) Location() string

Location returns the loction in the source where s was defined.

func (*Statement) NName

func (s *Statement) NName() string

func (*Statement) ParentNode

func (s *Statement) ParentNode() Node

func (*Statement) Statement

func (s *Statement) Statement() *Statement

func (*Statement) String

func (s *Statement) String() string

String returns s's tree as a string.

func (*Statement) SubStatements

func (s *Statement) SubStatements() []*Statement

SubStatements returns a slice of Statements found in s.

func (*Statement) Write

func (s *Statement) Write(w io.Writer, indent string) error

Write writes the tree in s to w, each line indented by ident. Children nodes are indented further by a tab. Typically indent is "" at the top level. Write is intended to display the contents of Statement, but not necessarily reproduce the input of Statement.

type TriState

type TriState int

A TriState may be true, false, or unset

func (TriState) String

func (t TriState) String() string

String displays t as a string.

func (TriState) Value

func (t TriState) Value() bool

Value returns the value of t as a boolean. Unset is returned as false.

type Type

type Type struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	IdentityBase    *Value     `yang:"base"` // Name == identityref
	Bit             []*Bit     `yang:"bit"`
	Enum            []*Enum    `yang:"enum"`
	FractionDigits  *Value     `yang:"fraction-digits"` // Name == decimal64
	Length          *Length    `yang:"length"`
	Path            *Value     `yang:"path"`
	Pattern         []*Pattern `yang:"pattern"`
	Range           *Range     `yang:"range"`
	RequireInstance *Value     `yang:"require-instance"`
	Type            []*Type    `yang:"type"` // len > 1 only when Name is "union"

	YangType *YangType
}

A Type is defined in: http://tools.ietf.org/html/rfc6020#section-7.4 Note that Name is the name of the type we want, it is what must be looked up and resolved.

func (*Type) Exts

func (s *Type) Exts() []*Statement

func (Type) Kind

func (Type) Kind() string

func (*Type) NName

func (s *Type) NName() string

func (*Type) ParentNode

func (s *Type) ParentNode() Node

func (*Type) Statement

func (s *Type) Statement() *Statement

type TypeKind

type TypeKind uint

TypeKind is the enumeration of the base types available in YANG. It is analogous to reflect.Kind.

func (TypeKind) String

func (k TypeKind) String() string

type Typedef

type Typedef struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge"`
	Parent     Node         `yang:"Parent,nomerge"`
	Extensions []*Statement `yang:"Ext"`

	Default     *Value `yang:"default"`
	Description *Value `yang:"description"`
	Reference   *Value `yang:"reference"`
	Status      *Value `yang:"status"`
	Type        *Type  `yang:"type,required"`
	Units       *Value `yang:"units"`

	YangType *YangType `json:"-"`
}

A Typedef is defined in: http://tools.ietf.org/html/rfc6020#section-7.3

func (*Typedef) Exts

func (s *Typedef) Exts() []*Statement

func (Typedef) Kind

func (Typedef) Kind() string

func (*Typedef) NName

func (s *Typedef) NName() string

func (*Typedef) ParentNode

func (s *Typedef) ParentNode() Node

func (*Typedef) Statement

func (s *Typedef) Statement() *Statement

type Typedefer

type Typedefer interface {
	Node
	Typedefs() []*Typedef
}

A Typedefer is a Node that defines typedefs.

type Uses

type Uses struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge" json:"-"`
	Parent     Node         `yang:"Parent,nomerge" json:"-"`
	Extensions []*Statement `yang:"Ext" json:"-"`

	Augment     []*Augment `yang:"augment" json:"-"`
	Description *Value     `yang:"description" json:",omitempty"`
	IfFeature   []*Value   `yang:"if-feature" json:"-"`
	Refine      []*Refine  `yang:"refine" json:"-"`
	Reference   *Value     `yang:"reference" json:"-"`
	Status      *Value     `yang:"status" json:"-"`
	When        *Value     `yang:"when" json:",omitempty"`
}

A Uses is defined in: http://tools.ietf.org/html/rfc6020#section-7.12

func (*Uses) Exts

func (s *Uses) Exts() []*Statement

func (Uses) Kind

func (Uses) Kind() string

func (*Uses) NName

func (s *Uses) NName() string

func (*Uses) ParentNode

func (s *Uses) ParentNode() Node

func (*Uses) Statement

func (s *Uses) Statement() *Statement

type UsesStmt

type UsesStmt struct {
	Uses     *Uses
	Grouping *Entry
}

A UsesStmt associates a *Uses with its referenced grouping *Entry

type Value

type Value struct {
	Name       string       `yang:"Name,nomerge"`
	Source     *Statement   `yang:"Statement,nomerge" json:",omitempty"`
	Parent     Node         `yang:"Parent,nomerge" json:"-"`
	Extensions []*Statement `yang:"Ext" json:",omitempty"`

	Description *Value `yang:"description" json:",omitempty"`
}

A Value is just a string that can have extensions.

func (*Value) Exts

func (s *Value) Exts() []*Statement

func (Value) Kind

func (Value) Kind() string

func (*Value) NName

func (s *Value) NName() string

func (*Value) ParentNode

func (s *Value) ParentNode() Node

func (*Value) Statement

func (s *Value) Statement() *Statement

type YRange

type YRange struct {
	Min Number
	Max Number
}

YRange is a single range of consecutive numbers, inclusive.

func (YRange) String

func (r YRange) String() string

String returns r as a string using YANG notation, either a simple value if min == max or min..max.

func (YRange) Valid

func (r YRange) Valid() bool

Valid returns false if r is not a valid range (min > max).

type YangRange

type YangRange []YRange

A YangRange is a set of non-overlapping ranges.

func ParseRanges

func ParseRanges(s string) (YangRange, error)

ParseRanges parses s into a series of ranges. Each individual range is in s is separated by the pipe character (|). The min and max value of a range are separated by "..". An error is returned if the range is invalid. The resulting range is sorted and coalesced.

func (YangRange) Contains

func (r YangRange) Contains(s YangRange) bool

Contains returns true if all possible values in s are also possible values in r. An empty range is assumed to be min..max.

func (YangRange) Equal

func (r YangRange) Equal(q YangRange) bool

Equal returns true if ranges r and q are identically equivalent. TODO(borman): should we coalesce ranges in the comparison?

func (YangRange) Len

func (r YangRange) Len() int

func (YangRange) Less

func (r YangRange) Less(i, j int) bool

func (YangRange) String

func (r YangRange) String() string

String returns the ranges r using YANG notation. Individual ranges are separated by pipes (|).

func (YangRange) Swap

func (r YangRange) Swap(i, j int)

func (YangRange) Validate

func (r YangRange) Validate() error

Validate sorts r and returns an error if r has either an invalid range or has overlapping ranges.

type YangType

type YangType struct {
	Name             string
	Kind             TypeKind    // Ynone if not a base type
	Base             *Type       `json:"-"`          // Base type for non-builtin types
	IdentityBase     *Identity   `json:",omitempty"` // Base statement for a type using identityref
	Root             *YangType   `json:"-"`          // root of this type that is the same
	Bit              *EnumType   `json:",omitempty"` // bit position, "status" is lost
	Enum             *EnumType   `json:",omitempty"` // enum name to value, "status" is lost
	Units            string      `json:",omitempty"` // units to be used for this type
	Default          string      `json:",omitempty"` // default value, if any
	FractionDigits   int         `json:",omitempty"` // decimal64 fixed point precision
	Length           YangRange   `json:",omitempty"` // this should be processed by section 12
	OptionalInstance bool        `json:",omitempty"` // !require-instances which defaults to true
	Path             string      `json:",omitempty"` // the path in a leafref
	Pattern          []string    `json:",omitempty"` // limiting XSD-TYPES expressions on strings
	Range            YangRange   `json:",omitempty"` // range for integers
	Type             []*YangType `json:",omitempty"` // for unions
}

A YangType is the internal representation of a type in YANG. It may refer to either a builtin type or type specified with typedef. Not all fields in YangType are used for all types.

func (*YangType) Equal

func (y *YangType) Equal(t *YangType) bool

Equal returns true if y and t describe the same type.

Jump to

Keyboard shortcuts

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