id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
25,400 | jroimartin/gocui | gui.go | Size | func (g *Gui) Size() (x, y int) {
return g.maxX, g.maxY
} | go | func (g *Gui) Size() (x, y int) {
return g.maxX, g.maxY
} | [
"func",
"(",
"g",
"*",
"Gui",
")",
"Size",
"(",
")",
"(",
"x",
",",
"y",
"int",
")",
"{",
"return",
"g",
".",
"maxX",
",",
"g",
".",
"maxY",
"\n",
"}"
] | // Size returns the terminal's size. | [
"Size",
"returns",
"the",
"terminal",
"s",
"size",
"."
] | c055c87ae801372cd74a0839b972db4f7697ae5f | https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/gui.go#L100-L102 |
25,401 | jroimartin/gocui | gui.go | SetRune | func (g *Gui) SetRune(x, y int, ch rune, fgColor, bgColor Attribute) error {
if x < 0 || y < 0 || x >= g.maxX || y >= g.maxY {
return errors.New("invalid point")
}
termbox.SetCell(x, y, ch, termbox.Attribute(fgColor), termbox.Attribute(bgColor))
return nil
} | go | func (g *Gui) SetRune(x, y int, ch rune, fgColor, bgColor Attribute) error {
if x < 0 || y < 0 || x >= g.maxX || y >= g.maxY {
return errors.New("invalid point")
}
termbox.SetCell(x, y, ch, termbox.Attribute(fgColor), termbox.Attribute(bgColor))
return nil
} | [
"func",
"(",
"g",
"*",
"Gui",
")",
"SetRune",
"(",
"x",
",",
"y",
"int",
",",
"ch",
"rune",
",",
"fgColor",
",",
"bgColor",
"Attribute",
")",
"error",
"{",
"if",
"x",
"<",
"0",
"||",
"y",
"<",
"0",
"||",
"x",
">=",
"g",
".",
"maxX",
"||",
"... | // SetRune writes a rune at the given point, relative to the top-left
// corner of the terminal. It checks if the position is valid and applies
// the given colors. | [
"SetRune",
"writes",
"a",
"rune",
"at",
"the",
"given",
"point",
"relative",
"to",
"the",
"top",
"-",
"left",
"corner",
"of",
"the",
"terminal",
".",
"It",
"checks",
"if",
"the",
"position",
"is",
"valid",
"and",
"applies",
"the",
"given",
"colors",
"."
... | c055c87ae801372cd74a0839b972db4f7697ae5f | https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/gui.go#L107-L113 |
25,402 | jroimartin/gocui | gui.go | Rune | func (g *Gui) Rune(x, y int) (rune, error) {
if x < 0 || y < 0 || x >= g.maxX || y >= g.maxY {
return ' ', errors.New("invalid point")
}
c := termbox.CellBuffer()[y*g.maxX+x]
return c.Ch, nil
} | go | func (g *Gui) Rune(x, y int) (rune, error) {
if x < 0 || y < 0 || x >= g.maxX || y >= g.maxY {
return ' ', errors.New("invalid point")
}
c := termbox.CellBuffer()[y*g.maxX+x]
return c.Ch, nil
} | [
"func",
"(",
"g",
"*",
"Gui",
")",
"Rune",
"(",
"x",
",",
"y",
"int",
")",
"(",
"rune",
",",
"error",
")",
"{",
"if",
"x",
"<",
"0",
"||",
"y",
"<",
"0",
"||",
"x",
">=",
"g",
".",
"maxX",
"||",
"y",
">=",
"g",
".",
"maxY",
"{",
"return... | // Rune returns the rune contained in the cell at the given position.
// It checks if the position is valid. | [
"Rune",
"returns",
"the",
"rune",
"contained",
"in",
"the",
"cell",
"at",
"the",
"given",
"position",
".",
"It",
"checks",
"if",
"the",
"position",
"is",
"valid",
"."
] | c055c87ae801372cd74a0839b972db4f7697ae5f | https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/gui.go#L117-L123 |
25,403 | jroimartin/gocui | gui.go | SetViewOnTop | func (g *Gui) SetViewOnTop(name string) (*View, error) {
for i, v := range g.views {
if v.name == name {
s := append(g.views[:i], g.views[i+1:]...)
g.views = append(s, v)
return v, nil
}
}
return nil, ErrUnknownView
} | go | func (g *Gui) SetViewOnTop(name string) (*View, error) {
for i, v := range g.views {
if v.name == name {
s := append(g.views[:i], g.views[i+1:]...)
g.views = append(s, v)
return v, nil
}
}
return nil, ErrUnknownView
} | [
"func",
"(",
"g",
"*",
"Gui",
")",
"SetViewOnTop",
"(",
"name",
"string",
")",
"(",
"*",
"View",
",",
"error",
")",
"{",
"for",
"i",
",",
"v",
":=",
"range",
"g",
".",
"views",
"{",
"if",
"v",
".",
"name",
"==",
"name",
"{",
"s",
":=",
"appen... | // SetViewOnTop sets the given view on top of the existing ones. | [
"SetViewOnTop",
"sets",
"the",
"given",
"view",
"on",
"top",
"of",
"the",
"existing",
"ones",
"."
] | c055c87ae801372cd74a0839b972db4f7697ae5f | https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/gui.go#L155-L164 |
25,404 | jroimartin/gocui | gui.go | View | func (g *Gui) View(name string) (*View, error) {
for _, v := range g.views {
if v.name == name {
return v, nil
}
}
return nil, ErrUnknownView
} | go | func (g *Gui) View(name string) (*View, error) {
for _, v := range g.views {
if v.name == name {
return v, nil
}
}
return nil, ErrUnknownView
} | [
"func",
"(",
"g",
"*",
"Gui",
")",
"View",
"(",
"name",
"string",
")",
"(",
"*",
"View",
",",
"error",
")",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"g",
".",
"views",
"{",
"if",
"v",
".",
"name",
"==",
"name",
"{",
"return",
"v",
",",
"ni... | // View returns a pointer to the view with the given name, or error
// ErrUnknownView if a view with that name does not exist. | [
"View",
"returns",
"a",
"pointer",
"to",
"the",
"view",
"with",
"the",
"given",
"name",
"or",
"error",
"ErrUnknownView",
"if",
"a",
"view",
"with",
"that",
"name",
"does",
"not",
"exist",
"."
] | c055c87ae801372cd74a0839b972db4f7697ae5f | https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/gui.go#L185-L192 |
25,405 | jroimartin/gocui | gui.go | ViewByPosition | func (g *Gui) ViewByPosition(x, y int) (*View, error) {
// traverse views in reverse order checking top views first
for i := len(g.views); i > 0; i-- {
v := g.views[i-1]
if x > v.x0 && x < v.x1 && y > v.y0 && y < v.y1 {
return v, nil
}
}
return nil, ErrUnknownView
} | go | func (g *Gui) ViewByPosition(x, y int) (*View, error) {
// traverse views in reverse order checking top views first
for i := len(g.views); i > 0; i-- {
v := g.views[i-1]
if x > v.x0 && x < v.x1 && y > v.y0 && y < v.y1 {
return v, nil
}
}
return nil, ErrUnknownView
} | [
"func",
"(",
"g",
"*",
"Gui",
")",
"ViewByPosition",
"(",
"x",
",",
"y",
"int",
")",
"(",
"*",
"View",
",",
"error",
")",
"{",
"// traverse views in reverse order checking top views first",
"for",
"i",
":=",
"len",
"(",
"g",
".",
"views",
")",
";",
"i",
... | // ViewByPosition returns a pointer to a view matching the given position, or
// error ErrUnknownView if a view in that position does not exist. | [
"ViewByPosition",
"returns",
"a",
"pointer",
"to",
"a",
"view",
"matching",
"the",
"given",
"position",
"or",
"error",
"ErrUnknownView",
"if",
"a",
"view",
"in",
"that",
"position",
"does",
"not",
"exist",
"."
] | c055c87ae801372cd74a0839b972db4f7697ae5f | https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/gui.go#L196-L205 |
25,406 | jroimartin/gocui | gui.go | ViewPosition | func (g *Gui) ViewPosition(name string) (x0, y0, x1, y1 int, err error) {
for _, v := range g.views {
if v.name == name {
return v.x0, v.y0, v.x1, v.y1, nil
}
}
return 0, 0, 0, 0, ErrUnknownView
} | go | func (g *Gui) ViewPosition(name string) (x0, y0, x1, y1 int, err error) {
for _, v := range g.views {
if v.name == name {
return v.x0, v.y0, v.x1, v.y1, nil
}
}
return 0, 0, 0, 0, ErrUnknownView
} | [
"func",
"(",
"g",
"*",
"Gui",
")",
"ViewPosition",
"(",
"name",
"string",
")",
"(",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
"int",
",",
"err",
"error",
")",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"g",
".",
"views",
"{",
"if",
"v",
".",
"n... | // ViewPosition returns the coordinates of the view with the given name, or
// error ErrUnknownView if a view with that name does not exist. | [
"ViewPosition",
"returns",
"the",
"coordinates",
"of",
"the",
"view",
"with",
"the",
"given",
"name",
"or",
"error",
"ErrUnknownView",
"if",
"a",
"view",
"with",
"that",
"name",
"does",
"not",
"exist",
"."
] | c055c87ae801372cd74a0839b972db4f7697ae5f | https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/gui.go#L209-L216 |
25,407 | jroimartin/gocui | gui.go | DeleteView | func (g *Gui) DeleteView(name string) error {
for i, v := range g.views {
if v.name == name {
g.views = append(g.views[:i], g.views[i+1:]...)
return nil
}
}
return ErrUnknownView
} | go | func (g *Gui) DeleteView(name string) error {
for i, v := range g.views {
if v.name == name {
g.views = append(g.views[:i], g.views[i+1:]...)
return nil
}
}
return ErrUnknownView
} | [
"func",
"(",
"g",
"*",
"Gui",
")",
"DeleteView",
"(",
"name",
"string",
")",
"error",
"{",
"for",
"i",
",",
"v",
":=",
"range",
"g",
".",
"views",
"{",
"if",
"v",
".",
"name",
"==",
"name",
"{",
"g",
".",
"views",
"=",
"append",
"(",
"g",
"."... | // DeleteView deletes a view by name. | [
"DeleteView",
"deletes",
"a",
"view",
"by",
"name",
"."
] | c055c87ae801372cd74a0839b972db4f7697ae5f | https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/gui.go#L219-L227 |
25,408 | jroimartin/gocui | gui.go | DeleteKeybinding | func (g *Gui) DeleteKeybinding(viewname string, key interface{}, mod Modifier) error {
k, ch, err := getKey(key)
if err != nil {
return err
}
for i, kb := range g.keybindings {
if kb.viewName == viewname && kb.ch == ch && kb.key == k && kb.mod == mod {
g.keybindings = append(g.keybindings[:i], g.keybindings... | go | func (g *Gui) DeleteKeybinding(viewname string, key interface{}, mod Modifier) error {
k, ch, err := getKey(key)
if err != nil {
return err
}
for i, kb := range g.keybindings {
if kb.viewName == viewname && kb.ch == ch && kb.key == k && kb.mod == mod {
g.keybindings = append(g.keybindings[:i], g.keybindings... | [
"func",
"(",
"g",
"*",
"Gui",
")",
"DeleteKeybinding",
"(",
"viewname",
"string",
",",
"key",
"interface",
"{",
"}",
",",
"mod",
"Modifier",
")",
"error",
"{",
"k",
",",
"ch",
",",
"err",
":=",
"getKey",
"(",
"key",
")",
"\n",
"if",
"err",
"!=",
... | // DeleteKeybinding deletes a keybinding. | [
"DeleteKeybinding",
"deletes",
"a",
"keybinding",
"."
] | c055c87ae801372cd74a0839b972db4f7697ae5f | https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/gui.go#L262-L275 |
25,409 | jroimartin/gocui | gui.go | DeleteKeybindings | func (g *Gui) DeleteKeybindings(viewname string) {
var s []*keybinding
for _, kb := range g.keybindings {
if kb.viewName != viewname {
s = append(s, kb)
}
}
g.keybindings = s
} | go | func (g *Gui) DeleteKeybindings(viewname string) {
var s []*keybinding
for _, kb := range g.keybindings {
if kb.viewName != viewname {
s = append(s, kb)
}
}
g.keybindings = s
} | [
"func",
"(",
"g",
"*",
"Gui",
")",
"DeleteKeybindings",
"(",
"viewname",
"string",
")",
"{",
"var",
"s",
"[",
"]",
"*",
"keybinding",
"\n",
"for",
"_",
",",
"kb",
":=",
"range",
"g",
".",
"keybindings",
"{",
"if",
"kb",
".",
"viewName",
"!=",
"view... | // DeleteKeybindings deletes all keybindings of view. | [
"DeleteKeybindings",
"deletes",
"all",
"keybindings",
"of",
"view",
"."
] | c055c87ae801372cd74a0839b972db4f7697ae5f | https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/gui.go#L278-L286 |
25,410 | jroimartin/gocui | gui.go | getKey | func getKey(key interface{}) (Key, rune, error) {
switch t := key.(type) {
case Key:
return t, 0, nil
case rune:
return 0, t, nil
default:
return 0, 0, errors.New("unknown type")
}
} | go | func getKey(key interface{}) (Key, rune, error) {
switch t := key.(type) {
case Key:
return t, 0, nil
case rune:
return 0, t, nil
default:
return 0, 0, errors.New("unknown type")
}
} | [
"func",
"getKey",
"(",
"key",
"interface",
"{",
"}",
")",
"(",
"Key",
",",
"rune",
",",
"error",
")",
"{",
"switch",
"t",
":=",
"key",
".",
"(",
"type",
")",
"{",
"case",
"Key",
":",
"return",
"t",
",",
"0",
",",
"nil",
"\n",
"case",
"rune",
... | // getKey takes an empty interface with a key and returns the corresponding
// typed Key or rune. | [
"getKey",
"takes",
"an",
"empty",
"interface",
"with",
"a",
"key",
"and",
"returns",
"the",
"corresponding",
"typed",
"Key",
"or",
"rune",
"."
] | c055c87ae801372cd74a0839b972db4f7697ae5f | https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/gui.go#L290-L299 |
25,411 | jroimartin/gocui | gui.go | Update | func (g *Gui) Update(f func(*Gui) error) {
go func() { g.userEvents <- userEvent{f: f} }()
} | go | func (g *Gui) Update(f func(*Gui) error) {
go func() { g.userEvents <- userEvent{f: f} }()
} | [
"func",
"(",
"g",
"*",
"Gui",
")",
"Update",
"(",
"f",
"func",
"(",
"*",
"Gui",
")",
"error",
")",
"{",
"go",
"func",
"(",
")",
"{",
"g",
".",
"userEvents",
"<-",
"userEvent",
"{",
"f",
":",
"f",
"}",
"}",
"(",
")",
"\n",
"}"
] | // Update executes the passed function. This method can be called safely from a
// goroutine in order to update the GUI. It is important to note that the
// passed function won't be executed immediately, instead it will be added to
// the user events queue. Given that Update spawns a goroutine, the order in
// which th... | [
"Update",
"executes",
"the",
"passed",
"function",
".",
"This",
"method",
"can",
"be",
"called",
"safely",
"from",
"a",
"goroutine",
"in",
"order",
"to",
"update",
"the",
"GUI",
".",
"It",
"is",
"important",
"to",
"note",
"that",
"the",
"passed",
"function... | c055c87ae801372cd74a0839b972db4f7697ae5f | https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/gui.go#L311-L313 |
25,412 | jroimartin/gocui | gui.go | SetManager | func (g *Gui) SetManager(managers ...Manager) {
g.managers = managers
g.currentView = nil
g.views = nil
g.keybindings = nil
go func() { g.tbEvents <- termbox.Event{Type: termbox.EventResize} }()
} | go | func (g *Gui) SetManager(managers ...Manager) {
g.managers = managers
g.currentView = nil
g.views = nil
g.keybindings = nil
go func() { g.tbEvents <- termbox.Event{Type: termbox.EventResize} }()
} | [
"func",
"(",
"g",
"*",
"Gui",
")",
"SetManager",
"(",
"managers",
"...",
"Manager",
")",
"{",
"g",
".",
"managers",
"=",
"managers",
"\n",
"g",
".",
"currentView",
"=",
"nil",
"\n",
"g",
".",
"views",
"=",
"nil",
"\n",
"g",
".",
"keybindings",
"=",... | // SetManager sets the given GUI managers. It deletes all views and
// keybindings. | [
"SetManager",
"sets",
"the",
"given",
"GUI",
"managers",
".",
"It",
"deletes",
"all",
"views",
"and",
"keybindings",
"."
] | c055c87ae801372cd74a0839b972db4f7697ae5f | https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/gui.go#L334-L341 |
25,413 | jroimartin/gocui | gui.go | SetManagerFunc | func (g *Gui) SetManagerFunc(manager func(*Gui) error) {
g.SetManager(ManagerFunc(manager))
} | go | func (g *Gui) SetManagerFunc(manager func(*Gui) error) {
g.SetManager(ManagerFunc(manager))
} | [
"func",
"(",
"g",
"*",
"Gui",
")",
"SetManagerFunc",
"(",
"manager",
"func",
"(",
"*",
"Gui",
")",
"error",
")",
"{",
"g",
".",
"SetManager",
"(",
"ManagerFunc",
"(",
"manager",
")",
")",
"\n",
"}"
] | // SetManagerFunc sets the given manager function. It deletes all views and
// keybindings. | [
"SetManagerFunc",
"sets",
"the",
"given",
"manager",
"function",
".",
"It",
"deletes",
"all",
"views",
"and",
"keybindings",
"."
] | c055c87ae801372cd74a0839b972db4f7697ae5f | https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/gui.go#L345-L347 |
25,414 | jroimartin/gocui | gui.go | MainLoop | func (g *Gui) MainLoop() error {
go func() {
for {
g.tbEvents <- termbox.PollEvent()
}
}()
inputMode := termbox.InputAlt
if g.InputEsc {
inputMode = termbox.InputEsc
}
if g.Mouse {
inputMode |= termbox.InputMouse
}
termbox.SetInputMode(inputMode)
if err := g.flush(); err != nil {
return err
}
... | go | func (g *Gui) MainLoop() error {
go func() {
for {
g.tbEvents <- termbox.PollEvent()
}
}()
inputMode := termbox.InputAlt
if g.InputEsc {
inputMode = termbox.InputEsc
}
if g.Mouse {
inputMode |= termbox.InputMouse
}
termbox.SetInputMode(inputMode)
if err := g.flush(); err != nil {
return err
}
... | [
"func",
"(",
"g",
"*",
"Gui",
")",
"MainLoop",
"(",
")",
"error",
"{",
"go",
"func",
"(",
")",
"{",
"for",
"{",
"g",
".",
"tbEvents",
"<-",
"termbox",
".",
"PollEvent",
"(",
")",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n\n",
"inputMode",
":=",
"termb... | // MainLoop runs the main loop until an error is returned. A successful
// finish should return ErrQuit. | [
"MainLoop",
"runs",
"the",
"main",
"loop",
"until",
"an",
"error",
"is",
"returned",
".",
"A",
"successful",
"finish",
"should",
"return",
"ErrQuit",
"."
] | c055c87ae801372cd74a0839b972db4f7697ae5f | https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/gui.go#L351-L388 |
25,415 | jroimartin/gocui | gui.go | consumeevents | func (g *Gui) consumeevents() error {
for {
select {
case ev := <-g.tbEvents:
if err := g.handleEvent(&ev); err != nil {
return err
}
case ev := <-g.userEvents:
if err := ev.f(g); err != nil {
return err
}
default:
return nil
}
}
} | go | func (g *Gui) consumeevents() error {
for {
select {
case ev := <-g.tbEvents:
if err := g.handleEvent(&ev); err != nil {
return err
}
case ev := <-g.userEvents:
if err := ev.f(g); err != nil {
return err
}
default:
return nil
}
}
} | [
"func",
"(",
"g",
"*",
"Gui",
")",
"consumeevents",
"(",
")",
"error",
"{",
"for",
"{",
"select",
"{",
"case",
"ev",
":=",
"<-",
"g",
".",
"tbEvents",
":",
"if",
"err",
":=",
"g",
".",
"handleEvent",
"(",
"&",
"ev",
")",
";",
"err",
"!=",
"nil"... | // consumeevents handles the remaining events in the events pool. | [
"consumeevents",
"handles",
"the",
"remaining",
"events",
"in",
"the",
"events",
"pool",
"."
] | c055c87ae801372cd74a0839b972db4f7697ae5f | https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/gui.go#L391-L406 |
25,416 | jroimartin/gocui | gui.go | flush | func (g *Gui) flush() error {
termbox.Clear(termbox.Attribute(g.FgColor), termbox.Attribute(g.BgColor))
maxX, maxY := termbox.Size()
// if GUI's size has changed, we need to redraw all views
if maxX != g.maxX || maxY != g.maxY {
for _, v := range g.views {
v.tainted = true
}
}
g.maxX, g.maxY = maxX, maxY
... | go | func (g *Gui) flush() error {
termbox.Clear(termbox.Attribute(g.FgColor), termbox.Attribute(g.BgColor))
maxX, maxY := termbox.Size()
// if GUI's size has changed, we need to redraw all views
if maxX != g.maxX || maxY != g.maxY {
for _, v := range g.views {
v.tainted = true
}
}
g.maxX, g.maxY = maxX, maxY
... | [
"func",
"(",
"g",
"*",
"Gui",
")",
"flush",
"(",
")",
"error",
"{",
"termbox",
".",
"Clear",
"(",
"termbox",
".",
"Attribute",
"(",
"g",
".",
"FgColor",
")",
",",
"termbox",
".",
"Attribute",
"(",
"g",
".",
"BgColor",
")",
")",
"\n\n",
"maxX",
",... | // flush updates the gui, re-drawing frames and buffers. | [
"flush",
"updates",
"the",
"gui",
"re",
"-",
"drawing",
"frames",
"and",
"buffers",
"."
] | c055c87ae801372cd74a0839b972db4f7697ae5f | https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/gui.go#L422-L468 |
25,417 | jroimartin/gocui | gui.go | drawFrameEdges | func (g *Gui) drawFrameEdges(v *View, fgColor, bgColor Attribute) error {
runeH, runeV := '─', '│'
if g.ASCII {
runeH, runeV = '-', '|'
}
for x := v.x0 + 1; x < v.x1 && x < g.maxX; x++ {
if x < 0 {
continue
}
if v.y0 > -1 && v.y0 < g.maxY {
if err := g.SetRune(x, v.y0, runeH, fgColor, bgColor); err !... | go | func (g *Gui) drawFrameEdges(v *View, fgColor, bgColor Attribute) error {
runeH, runeV := '─', '│'
if g.ASCII {
runeH, runeV = '-', '|'
}
for x := v.x0 + 1; x < v.x1 && x < g.maxX; x++ {
if x < 0 {
continue
}
if v.y0 > -1 && v.y0 < g.maxY {
if err := g.SetRune(x, v.y0, runeH, fgColor, bgColor); err !... | [
"func",
"(",
"g",
"*",
"Gui",
")",
"drawFrameEdges",
"(",
"v",
"*",
"View",
",",
"fgColor",
",",
"bgColor",
"Attribute",
")",
"error",
"{",
"runeH",
",",
"runeV",
":=",
"'─', ",
"'",
"'",
"\n",
"if",
"g",
".",
"ASCII",
"{",
"runeH",
",",
"runeV",
... | // drawFrameEdges draws the horizontal and vertical edges of a view. | [
"drawFrameEdges",
"draws",
"the",
"horizontal",
"and",
"vertical",
"edges",
"of",
"a",
"view",
"."
] | c055c87ae801372cd74a0839b972db4f7697ae5f | https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/gui.go#L471-L508 |
25,418 | jroimartin/gocui | gui.go | drawFrameCorners | func (g *Gui) drawFrameCorners(v *View, fgColor, bgColor Attribute) error {
runeTL, runeTR, runeBL, runeBR := '┌', '┐', '└', '┘'
if g.ASCII {
runeTL, runeTR, runeBL, runeBR = '+', '+', '+', '+'
}
corners := []struct {
x, y int
ch rune
}{{v.x0, v.y0, runeTL}, {v.x1, v.y0, runeTR}, {v.x0, v.y1, runeBL}, {v.... | go | func (g *Gui) drawFrameCorners(v *View, fgColor, bgColor Attribute) error {
runeTL, runeTR, runeBL, runeBR := '┌', '┐', '└', '┘'
if g.ASCII {
runeTL, runeTR, runeBL, runeBR = '+', '+', '+', '+'
}
corners := []struct {
x, y int
ch rune
}{{v.x0, v.y0, runeTL}, {v.x1, v.y0, runeTR}, {v.x0, v.y1, runeBL}, {v.... | [
"func",
"(",
"g",
"*",
"Gui",
")",
"drawFrameCorners",
"(",
"v",
"*",
"View",
",",
"fgColor",
",",
"bgColor",
"Attribute",
")",
"error",
"{",
"runeTL",
",",
"runeTR",
",",
"runeBL",
",",
"runeBR",
":=",
"'┌', ",
"'",
"', '└",
"'",
" '┘'",
"",
"",
"... | // drawFrameCorners draws the corners of the view. | [
"drawFrameCorners",
"draws",
"the",
"corners",
"of",
"the",
"view",
"."
] | c055c87ae801372cd74a0839b972db4f7697ae5f | https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/gui.go#L511-L530 |
25,419 | jroimartin/gocui | gui.go | drawTitle | func (g *Gui) drawTitle(v *View, fgColor, bgColor Attribute) error {
if v.y0 < 0 || v.y0 >= g.maxY {
return nil
}
for i, ch := range v.Title {
x := v.x0 + i + 2
if x < 0 {
continue
} else if x > v.x1-2 || x >= g.maxX {
break
}
if err := g.SetRune(x, v.y0, ch, fgColor, bgColor); err != nil {
ret... | go | func (g *Gui) drawTitle(v *View, fgColor, bgColor Attribute) error {
if v.y0 < 0 || v.y0 >= g.maxY {
return nil
}
for i, ch := range v.Title {
x := v.x0 + i + 2
if x < 0 {
continue
} else if x > v.x1-2 || x >= g.maxX {
break
}
if err := g.SetRune(x, v.y0, ch, fgColor, bgColor); err != nil {
ret... | [
"func",
"(",
"g",
"*",
"Gui",
")",
"drawTitle",
"(",
"v",
"*",
"View",
",",
"fgColor",
",",
"bgColor",
"Attribute",
")",
"error",
"{",
"if",
"v",
".",
"y0",
"<",
"0",
"||",
"v",
".",
"y0",
">=",
"g",
".",
"maxY",
"{",
"return",
"nil",
"\n",
"... | // drawTitle draws the title of the view. | [
"drawTitle",
"draws",
"the",
"title",
"of",
"the",
"view",
"."
] | c055c87ae801372cd74a0839b972db4f7697ae5f | https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/gui.go#L533-L550 |
25,420 | jroimartin/gocui | gui.go | draw | func (g *Gui) draw(v *View) error {
if g.Cursor {
if curview := g.currentView; curview != nil {
vMaxX, vMaxY := curview.Size()
if curview.cx < 0 {
curview.cx = 0
} else if curview.cx >= vMaxX {
curview.cx = vMaxX - 1
}
if curview.cy < 0 {
curview.cy = 0
} else if curview.cy >= vMaxY {
... | go | func (g *Gui) draw(v *View) error {
if g.Cursor {
if curview := g.currentView; curview != nil {
vMaxX, vMaxY := curview.Size()
if curview.cx < 0 {
curview.cx = 0
} else if curview.cx >= vMaxX {
curview.cx = vMaxX - 1
}
if curview.cy < 0 {
curview.cy = 0
} else if curview.cy >= vMaxY {
... | [
"func",
"(",
"g",
"*",
"Gui",
")",
"draw",
"(",
"v",
"*",
"View",
")",
"error",
"{",
"if",
"g",
".",
"Cursor",
"{",
"if",
"curview",
":=",
"g",
".",
"currentView",
";",
"curview",
"!=",
"nil",
"{",
"vMaxX",
",",
"vMaxY",
":=",
"curview",
".",
"... | // draw manages the cursor and calls the draw function of a view. | [
"draw",
"manages",
"the",
"cursor",
"and",
"calls",
"the",
"draw",
"function",
"of",
"a",
"view",
"."
] | c055c87ae801372cd74a0839b972db4f7697ae5f | https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/gui.go#L553-L585 |
25,421 | jroimartin/gocui | gui.go | onKey | func (g *Gui) onKey(ev *termbox.Event) error {
switch ev.Type {
case termbox.EventKey:
matched, err := g.execKeybindings(g.currentView, ev)
if err != nil {
return err
}
if matched {
break
}
if g.currentView != nil && g.currentView.Editable && g.currentView.Editor != nil {
g.currentView.Editor.Edi... | go | func (g *Gui) onKey(ev *termbox.Event) error {
switch ev.Type {
case termbox.EventKey:
matched, err := g.execKeybindings(g.currentView, ev)
if err != nil {
return err
}
if matched {
break
}
if g.currentView != nil && g.currentView.Editable && g.currentView.Editor != nil {
g.currentView.Editor.Edi... | [
"func",
"(",
"g",
"*",
"Gui",
")",
"onKey",
"(",
"ev",
"*",
"termbox",
".",
"Event",
")",
"error",
"{",
"switch",
"ev",
".",
"Type",
"{",
"case",
"termbox",
".",
"EventKey",
":",
"matched",
",",
"err",
":=",
"g",
".",
"execKeybindings",
"(",
"g",
... | // onKey manages key-press events. A keybinding handler is called when
// a key-press or mouse event satisfies a configured keybinding. Furthermore,
// currentView's internal buffer is modified if currentView.Editable is true. | [
"onKey",
"manages",
"key",
"-",
"press",
"events",
".",
"A",
"keybinding",
"handler",
"is",
"called",
"when",
"a",
"key",
"-",
"press",
"or",
"mouse",
"event",
"satisfies",
"a",
"configured",
"keybinding",
".",
"Furthermore",
"currentView",
"s",
"internal",
... | c055c87ae801372cd74a0839b972db4f7697ae5f | https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/gui.go#L590-L618 |
25,422 | jroimartin/gocui | gui.go | execKeybindings | func (g *Gui) execKeybindings(v *View, ev *termbox.Event) (matched bool, err error) {
matched = false
for _, kb := range g.keybindings {
if kb.handler == nil {
continue
}
if kb.matchKeypress(Key(ev.Key), ev.Ch, Modifier(ev.Mod)) && kb.matchView(v) {
if err := kb.handler(g, v); err != nil {
return fals... | go | func (g *Gui) execKeybindings(v *View, ev *termbox.Event) (matched bool, err error) {
matched = false
for _, kb := range g.keybindings {
if kb.handler == nil {
continue
}
if kb.matchKeypress(Key(ev.Key), ev.Ch, Modifier(ev.Mod)) && kb.matchView(v) {
if err := kb.handler(g, v); err != nil {
return fals... | [
"func",
"(",
"g",
"*",
"Gui",
")",
"execKeybindings",
"(",
"v",
"*",
"View",
",",
"ev",
"*",
"termbox",
".",
"Event",
")",
"(",
"matched",
"bool",
",",
"err",
"error",
")",
"{",
"matched",
"=",
"false",
"\n",
"for",
"_",
",",
"kb",
":=",
"range",... | // execKeybindings executes the keybinding handlers that match the passed view
// and event. The value of matched is true if there is a match and no errors. | [
"execKeybindings",
"executes",
"the",
"keybinding",
"handlers",
"that",
"match",
"the",
"passed",
"view",
"and",
"event",
".",
"The",
"value",
"of",
"matched",
"is",
"true",
"if",
"there",
"is",
"a",
"match",
"and",
"no",
"errors",
"."
] | c055c87ae801372cd74a0839b972db4f7697ae5f | https://github.com/jroimartin/gocui/blob/c055c87ae801372cd74a0839b972db4f7697ae5f/gui.go#L622-L636 |
25,423 | envoyproxy/protoc-gen-validate | templates/java/register.go | makeInvalidClassnameCharactersUnderscores | func makeInvalidClassnameCharactersUnderscores(name string) string {
var sb strings.Builder
for _, c := range name {
switch {
case c >= '0' && c <= '9':
sb.WriteRune(c)
case c >= 'a' && c <= 'z':
sb.WriteRune(c)
case c >= 'A' && c <= 'Z':
sb.WriteRune(c)
default:
sb.WriteRune('_')
}
}
return... | go | func makeInvalidClassnameCharactersUnderscores(name string) string {
var sb strings.Builder
for _, c := range name {
switch {
case c >= '0' && c <= '9':
sb.WriteRune(c)
case c >= 'a' && c <= 'z':
sb.WriteRune(c)
case c >= 'A' && c <= 'Z':
sb.WriteRune(c)
default:
sb.WriteRune('_')
}
}
return... | [
"func",
"makeInvalidClassnameCharactersUnderscores",
"(",
"name",
"string",
")",
"string",
"{",
"var",
"sb",
"strings",
".",
"Builder",
"\n",
"for",
"_",
",",
"c",
":=",
"range",
"name",
"{",
"switch",
"{",
"case",
"c",
">=",
"'0'",
"&&",
"c",
"<=",
"'9'... | // Replace invalid identifier characters with an underscore | [
"Replace",
"invalid",
"identifier",
"characters",
"with",
"an",
"underscore"
] | fcf5978a9d1e0d26f3239a013c54dc65dae6c768 | https://github.com/envoyproxy/protoc-gen-validate/blob/fcf5978a9d1e0d26f3239a013c54dc65dae6c768/templates/java/register.go#L193-L208 |
25,424 | envoyproxy/protoc-gen-validate | templates/shared/reflection.go | Has | func Has(msg proto.Message, fld string) bool {
val := extractVal(msg)
return val.IsValid() &&
val.FieldByName(fld).IsValid()
} | go | func Has(msg proto.Message, fld string) bool {
val := extractVal(msg)
return val.IsValid() &&
val.FieldByName(fld).IsValid()
} | [
"func",
"Has",
"(",
"msg",
"proto",
".",
"Message",
",",
"fld",
"string",
")",
"bool",
"{",
"val",
":=",
"extractVal",
"(",
"msg",
")",
"\n",
"return",
"val",
".",
"IsValid",
"(",
")",
"&&",
"val",
".",
"FieldByName",
"(",
"fld",
")",
".",
"IsValid... | // Has returns true if the provided Message has the a field fld. | [
"Has",
"returns",
"true",
"if",
"the",
"provided",
"Message",
"has",
"the",
"a",
"field",
"fld",
"."
] | fcf5978a9d1e0d26f3239a013c54dc65dae6c768 | https://github.com/envoyproxy/protoc-gen-validate/blob/fcf5978a9d1e0d26f3239a013c54dc65dae6c768/templates/shared/reflection.go#L24-L28 |
25,425 | envoyproxy/protoc-gen-validate | templates/shared/disabled.go | Disabled | func Disabled(msg pgs.Message) (disabled bool, err error) {
_, err = msg.Extension(validate.E_Disabled, &disabled)
return
} | go | func Disabled(msg pgs.Message) (disabled bool, err error) {
_, err = msg.Extension(validate.E_Disabled, &disabled)
return
} | [
"func",
"Disabled",
"(",
"msg",
"pgs",
".",
"Message",
")",
"(",
"disabled",
"bool",
",",
"err",
"error",
")",
"{",
"_",
",",
"err",
"=",
"msg",
".",
"Extension",
"(",
"validate",
".",
"E_Disabled",
",",
"&",
"disabled",
")",
"\n",
"return",
"\n",
... | // Disabled returns true if validations are disabled for msg | [
"Disabled",
"returns",
"true",
"if",
"validations",
"are",
"disabled",
"for",
"msg"
] | fcf5978a9d1e0d26f3239a013c54dc65dae6c768 | https://github.com/envoyproxy/protoc-gen-validate/blob/fcf5978a9d1e0d26f3239a013c54dc65dae6c768/templates/shared/disabled.go#L9-L12 |
25,426 | envoyproxy/protoc-gen-validate | templates/shared/disabled.go | RequiredOneOf | func RequiredOneOf(oo pgs.OneOf) (required bool, err error) {
_, err = oo.Extension(validate.E_Required, &required)
return
} | go | func RequiredOneOf(oo pgs.OneOf) (required bool, err error) {
_, err = oo.Extension(validate.E_Required, &required)
return
} | [
"func",
"RequiredOneOf",
"(",
"oo",
"pgs",
".",
"OneOf",
")",
"(",
"required",
"bool",
",",
"err",
"error",
")",
"{",
"_",
",",
"err",
"=",
"oo",
".",
"Extension",
"(",
"validate",
".",
"E_Required",
",",
"&",
"required",
")",
"\n",
"return",
"\n",
... | // RequiredOneOf returns true if the oneof field requires a field to be set | [
"RequiredOneOf",
"returns",
"true",
"if",
"the",
"oneof",
"field",
"requires",
"a",
"field",
"to",
"be",
"set"
] | fcf5978a9d1e0d26f3239a013c54dc65dae6c768 | https://github.com/envoyproxy/protoc-gen-validate/blob/fcf5978a9d1e0d26f3239a013c54dc65dae6c768/templates/shared/disabled.go#L15-L18 |
25,427 | envoyproxy/protoc-gen-validate | templates/shared/well_known.go | Needs | func Needs(m pgs.Message, wk WellKnown) bool {
for _, f := range m.Fields() {
var rules validate.FieldRules
if _, err := f.Extension(validate.E_Rules, &rules); err != nil {
continue
}
switch {
case f.Type().IsRepeated() && f.Type().Element().ProtoType() == pgs.StringT:
if strRulesNeeds(rules.GetRepea... | go | func Needs(m pgs.Message, wk WellKnown) bool {
for _, f := range m.Fields() {
var rules validate.FieldRules
if _, err := f.Extension(validate.E_Rules, &rules); err != nil {
continue
}
switch {
case f.Type().IsRepeated() && f.Type().Element().ProtoType() == pgs.StringT:
if strRulesNeeds(rules.GetRepea... | [
"func",
"Needs",
"(",
"m",
"pgs",
".",
"Message",
",",
"wk",
"WellKnown",
")",
"bool",
"{",
"for",
"_",
",",
"f",
":=",
"range",
"m",
".",
"Fields",
"(",
")",
"{",
"var",
"rules",
"validate",
".",
"FieldRules",
"\n",
"if",
"_",
",",
"err",
":=",
... | // Needs returns true if a well-known string validator is needed for this
// message. | [
"Needs",
"returns",
"true",
"if",
"a",
"well",
"-",
"known",
"string",
"validator",
"is",
"needed",
"for",
"this",
"message",
"."
] | fcf5978a9d1e0d26f3239a013c54dc65dae6c768 | https://github.com/envoyproxy/protoc-gen-validate/blob/fcf5978a9d1e0d26f3239a013c54dc65dae6c768/templates/shared/well_known.go#L17-L47 |
25,428 | vishvananda/netlink | addr_linux.go | AddrSubscribe | func AddrSubscribe(ch chan<- AddrUpdate, done <-chan struct{}) error {
return addrSubscribeAt(netns.None(), netns.None(), ch, done, nil, false)
} | go | func AddrSubscribe(ch chan<- AddrUpdate, done <-chan struct{}) error {
return addrSubscribeAt(netns.None(), netns.None(), ch, done, nil, false)
} | [
"func",
"AddrSubscribe",
"(",
"ch",
"chan",
"<-",
"AddrUpdate",
",",
"done",
"<-",
"chan",
"struct",
"{",
"}",
")",
"error",
"{",
"return",
"addrSubscribeAt",
"(",
"netns",
".",
"None",
"(",
")",
",",
"netns",
".",
"None",
"(",
")",
",",
"ch",
",",
... | // AddrSubscribe takes a chan down which notifications will be sent
// when addresses change. Close the 'done' chan to stop subscription. | [
"AddrSubscribe",
"takes",
"a",
"chan",
"down",
"which",
"notifications",
"will",
"be",
"sent",
"when",
"addresses",
"change",
".",
"Close",
"the",
"done",
"chan",
"to",
"stop",
"subscription",
"."
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/addr_linux.go#L272-L274 |
25,429 | vishvananda/netlink | addr_linux.go | AddrSubscribeWithOptions | func AddrSubscribeWithOptions(ch chan<- AddrUpdate, done <-chan struct{}, options AddrSubscribeOptions) error {
if options.Namespace == nil {
none := netns.None()
options.Namespace = &none
}
return addrSubscribeAt(*options.Namespace, netns.None(), ch, done, options.ErrorCallback, options.ListExisting)
} | go | func AddrSubscribeWithOptions(ch chan<- AddrUpdate, done <-chan struct{}, options AddrSubscribeOptions) error {
if options.Namespace == nil {
none := netns.None()
options.Namespace = &none
}
return addrSubscribeAt(*options.Namespace, netns.None(), ch, done, options.ErrorCallback, options.ListExisting)
} | [
"func",
"AddrSubscribeWithOptions",
"(",
"ch",
"chan",
"<-",
"AddrUpdate",
",",
"done",
"<-",
"chan",
"struct",
"{",
"}",
",",
"options",
"AddrSubscribeOptions",
")",
"error",
"{",
"if",
"options",
".",
"Namespace",
"==",
"nil",
"{",
"none",
":=",
"netns",
... | // AddrSubscribeWithOptions work like AddrSubscribe but enable to
// provide additional options to modify the behavior. Currently, the
// namespace can be provided as well as an error callback. | [
"AddrSubscribeWithOptions",
"work",
"like",
"AddrSubscribe",
"but",
"enable",
"to",
"provide",
"additional",
"options",
"to",
"modify",
"the",
"behavior",
".",
"Currently",
"the",
"namespace",
"can",
"be",
"provided",
"as",
"well",
"as",
"an",
"error",
"callback",... | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/addr_linux.go#L293-L299 |
25,430 | vishvananda/netlink | nl/nl_linux.go | GetIPFamily | func GetIPFamily(ip net.IP) int {
if len(ip) <= net.IPv4len {
return FAMILY_V4
}
if ip.To4() != nil {
return FAMILY_V4
}
return FAMILY_V6
} | go | func GetIPFamily(ip net.IP) int {
if len(ip) <= net.IPv4len {
return FAMILY_V4
}
if ip.To4() != nil {
return FAMILY_V4
}
return FAMILY_V6
} | [
"func",
"GetIPFamily",
"(",
"ip",
"net",
".",
"IP",
")",
"int",
"{",
"if",
"len",
"(",
"ip",
")",
"<=",
"net",
".",
"IPv4len",
"{",
"return",
"FAMILY_V4",
"\n",
"}",
"\n",
"if",
"ip",
".",
"To4",
"(",
")",
"!=",
"nil",
"{",
"return",
"FAMILY_V4",... | // GetIPFamily returns the family type of a net.IP. | [
"GetIPFamily",
"returns",
"the",
"family",
"type",
"of",
"a",
"net",
".",
"IP",
"."
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/nl/nl_linux.go#L37-L45 |
25,431 | vishvananda/netlink | nl/nl_linux.go | NewIfInfomsg | func NewIfInfomsg(family int) *IfInfomsg {
return &IfInfomsg{
IfInfomsg: unix.IfInfomsg{
Family: uint8(family),
},
}
} | go | func NewIfInfomsg(family int) *IfInfomsg {
return &IfInfomsg{
IfInfomsg: unix.IfInfomsg{
Family: uint8(family),
},
}
} | [
"func",
"NewIfInfomsg",
"(",
"family",
"int",
")",
"*",
"IfInfomsg",
"{",
"return",
"&",
"IfInfomsg",
"{",
"IfInfomsg",
":",
"unix",
".",
"IfInfomsg",
"{",
"Family",
":",
"uint8",
"(",
"family",
")",
",",
"}",
",",
"}",
"\n",
"}"
] | // Create an IfInfomsg with family specified | [
"Create",
"an",
"IfInfomsg",
"with",
"family",
"specified"
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/nl/nl_linux.go#L89-L95 |
25,432 | vishvananda/netlink | nl/nl_linux.go | NewRtAttr | func NewRtAttr(attrType int, data []byte) *RtAttr {
return &RtAttr{
RtAttr: unix.RtAttr{
Type: uint16(attrType),
},
children: []NetlinkRequestData{},
Data: data,
}
} | go | func NewRtAttr(attrType int, data []byte) *RtAttr {
return &RtAttr{
RtAttr: unix.RtAttr{
Type: uint16(attrType),
},
children: []NetlinkRequestData{},
Data: data,
}
} | [
"func",
"NewRtAttr",
"(",
"attrType",
"int",
",",
"data",
"[",
"]",
"byte",
")",
"*",
"RtAttr",
"{",
"return",
"&",
"RtAttr",
"{",
"RtAttr",
":",
"unix",
".",
"RtAttr",
"{",
"Type",
":",
"uint16",
"(",
"attrType",
")",
",",
"}",
",",
"children",
":... | // Create a new Extended RtAttr object | [
"Create",
"a",
"new",
"Extended",
"RtAttr",
"object"
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/nl/nl_linux.go#L268-L276 |
25,433 | vishvananda/netlink | nl/nl_linux.go | AddRtAttr | func (a *RtAttr) AddRtAttr(attrType int, data []byte) *RtAttr {
attr := NewRtAttr(attrType, data)
a.children = append(a.children, attr)
return attr
} | go | func (a *RtAttr) AddRtAttr(attrType int, data []byte) *RtAttr {
attr := NewRtAttr(attrType, data)
a.children = append(a.children, attr)
return attr
} | [
"func",
"(",
"a",
"*",
"RtAttr",
")",
"AddRtAttr",
"(",
"attrType",
"int",
",",
"data",
"[",
"]",
"byte",
")",
"*",
"RtAttr",
"{",
"attr",
":=",
"NewRtAttr",
"(",
"attrType",
",",
"data",
")",
"\n",
"a",
".",
"children",
"=",
"append",
"(",
"a",
... | // AddRtAttr adds an RtAttr as a child and returns the new attribute | [
"AddRtAttr",
"adds",
"an",
"RtAttr",
"as",
"a",
"child",
"and",
"returns",
"the",
"new",
"attribute"
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/nl/nl_linux.go#L286-L290 |
25,434 | vishvananda/netlink | nl/nl_linux.go | AddChild | func (a *RtAttr) AddChild(attr NetlinkRequestData) {
a.children = append(a.children, attr)
} | go | func (a *RtAttr) AddChild(attr NetlinkRequestData) {
a.children = append(a.children, attr)
} | [
"func",
"(",
"a",
"*",
"RtAttr",
")",
"AddChild",
"(",
"attr",
"NetlinkRequestData",
")",
"{",
"a",
".",
"children",
"=",
"append",
"(",
"a",
".",
"children",
",",
"attr",
")",
"\n",
"}"
] | // AddChild adds an existing NetlinkRequestData as a child. | [
"AddChild",
"adds",
"an",
"existing",
"NetlinkRequestData",
"as",
"a",
"child",
"."
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/nl/nl_linux.go#L293-L295 |
25,435 | vishvananda/netlink | nl/nl_linux.go | Serialize | func (req *NetlinkRequest) Serialize() []byte {
length := unix.SizeofNlMsghdr
dataBytes := make([][]byte, len(req.Data))
for i, data := range req.Data {
dataBytes[i] = data.Serialize()
length = length + len(dataBytes[i])
}
length += len(req.RawData)
req.Len = uint32(length)
b := make([]byte, length)
hdr :=... | go | func (req *NetlinkRequest) Serialize() []byte {
length := unix.SizeofNlMsghdr
dataBytes := make([][]byte, len(req.Data))
for i, data := range req.Data {
dataBytes[i] = data.Serialize()
length = length + len(dataBytes[i])
}
length += len(req.RawData)
req.Len = uint32(length)
b := make([]byte, length)
hdr :=... | [
"func",
"(",
"req",
"*",
"NetlinkRequest",
")",
"Serialize",
"(",
")",
"[",
"]",
"byte",
"{",
"length",
":=",
"unix",
".",
"SizeofNlMsghdr",
"\n",
"dataBytes",
":=",
"make",
"(",
"[",
"]",
"[",
"]",
"byte",
",",
"len",
"(",
"req",
".",
"Data",
")",... | // Serialize the Netlink Request into a byte array | [
"Serialize",
"the",
"Netlink",
"Request",
"into",
"a",
"byte",
"array"
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/nl/nl_linux.go#L346-L371 |
25,436 | vishvananda/netlink | nl/nl_linux.go | AddRawData | func (req *NetlinkRequest) AddRawData(data []byte) {
req.RawData = append(req.RawData, data...)
} | go | func (req *NetlinkRequest) AddRawData(data []byte) {
req.RawData = append(req.RawData, data...)
} | [
"func",
"(",
"req",
"*",
"NetlinkRequest",
")",
"AddRawData",
"(",
"data",
"[",
"]",
"byte",
")",
"{",
"req",
".",
"RawData",
"=",
"append",
"(",
"req",
".",
"RawData",
",",
"data",
"...",
")",
"\n",
"}"
] | // AddRawData adds raw bytes to the end of the NetlinkRequest object during serialization | [
"AddRawData",
"adds",
"raw",
"bytes",
"to",
"the",
"end",
"of",
"the",
"NetlinkRequest",
"object",
"during",
"serialization"
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/nl/nl_linux.go#L378-L380 |
25,437 | vishvananda/netlink | nl/nl_linux.go | Execute | func (req *NetlinkRequest) Execute(sockType int, resType uint16) ([][]byte, error) {
var (
s *NetlinkSocket
err error
)
if req.Sockets != nil {
if sh, ok := req.Sockets[sockType]; ok {
s = sh.Socket
req.Seq = atomic.AddUint32(&sh.Seq, 1)
}
}
sharedSocket := s != nil
if s == nil {
s, err = getN... | go | func (req *NetlinkRequest) Execute(sockType int, resType uint16) ([][]byte, error) {
var (
s *NetlinkSocket
err error
)
if req.Sockets != nil {
if sh, ok := req.Sockets[sockType]; ok {
s = sh.Socket
req.Seq = atomic.AddUint32(&sh.Seq, 1)
}
}
sharedSocket := s != nil
if s == nil {
s, err = getN... | [
"func",
"(",
"req",
"*",
"NetlinkRequest",
")",
"Execute",
"(",
"sockType",
"int",
",",
"resType",
"uint16",
")",
"(",
"[",
"]",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"(",
"s",
"*",
"NetlinkSocket",
"\n",
"err",
"error",
"\n",
")",
"\n\n... | // Execute the request against a the given sockType.
// Returns a list of netlink messages in serialized format, optionally filtered
// by resType. | [
"Execute",
"the",
"request",
"against",
"a",
"the",
"given",
"sockType",
".",
"Returns",
"a",
"list",
"of",
"netlink",
"messages",
"in",
"serialized",
"format",
"optionally",
"filtered",
"by",
"resType",
"."
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/nl/nl_linux.go#L385-L458 |
25,438 | vishvananda/netlink | nl/nl_linux.go | NewNetlinkRequest | func NewNetlinkRequest(proto, flags int) *NetlinkRequest {
return &NetlinkRequest{
NlMsghdr: unix.NlMsghdr{
Len: uint32(unix.SizeofNlMsghdr),
Type: uint16(proto),
Flags: unix.NLM_F_REQUEST | uint16(flags),
Seq: atomic.AddUint32(&nextSeqNr, 1),
},
}
} | go | func NewNetlinkRequest(proto, flags int) *NetlinkRequest {
return &NetlinkRequest{
NlMsghdr: unix.NlMsghdr{
Len: uint32(unix.SizeofNlMsghdr),
Type: uint16(proto),
Flags: unix.NLM_F_REQUEST | uint16(flags),
Seq: atomic.AddUint32(&nextSeqNr, 1),
},
}
} | [
"func",
"NewNetlinkRequest",
"(",
"proto",
",",
"flags",
"int",
")",
"*",
"NetlinkRequest",
"{",
"return",
"&",
"NetlinkRequest",
"{",
"NlMsghdr",
":",
"unix",
".",
"NlMsghdr",
"{",
"Len",
":",
"uint32",
"(",
"unix",
".",
"SizeofNlMsghdr",
")",
",",
"Type"... | // Create a new netlink request from proto and flags
// Note the Len value will be inaccurate once data is added until
// the message is serialized | [
"Create",
"a",
"new",
"netlink",
"request",
"from",
"proto",
"and",
"flags",
"Note",
"the",
"Len",
"value",
"will",
"be",
"inaccurate",
"once",
"data",
"is",
"added",
"until",
"the",
"message",
"is",
"serialized"
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/nl/nl_linux.go#L463-L472 |
25,439 | vishvananda/netlink | nl/nl_linux.go | GetNetlinkSocketAt | func GetNetlinkSocketAt(newNs, curNs netns.NsHandle, protocol int) (*NetlinkSocket, error) {
c, err := executeInNetns(newNs, curNs)
if err != nil {
return nil, err
}
defer c()
return getNetlinkSocket(protocol)
} | go | func GetNetlinkSocketAt(newNs, curNs netns.NsHandle, protocol int) (*NetlinkSocket, error) {
c, err := executeInNetns(newNs, curNs)
if err != nil {
return nil, err
}
defer c()
return getNetlinkSocket(protocol)
} | [
"func",
"GetNetlinkSocketAt",
"(",
"newNs",
",",
"curNs",
"netns",
".",
"NsHandle",
",",
"protocol",
"int",
")",
"(",
"*",
"NetlinkSocket",
",",
"error",
")",
"{",
"c",
",",
"err",
":=",
"executeInNetns",
"(",
"newNs",
",",
"curNs",
")",
"\n",
"if",
"e... | // GetNetlinkSocketAt opens a netlink socket in the network namespace newNs
// and positions the thread back into the network namespace specified by curNs,
// when done. If curNs is close, the function derives the current namespace and
// moves back into it when done. If newNs is close, the socket will be opened
// in ... | [
"GetNetlinkSocketAt",
"opens",
"a",
"netlink",
"socket",
"in",
"the",
"network",
"namespace",
"newNs",
"and",
"positions",
"the",
"thread",
"back",
"into",
"the",
"network",
"namespace",
"specified",
"by",
"curNs",
"when",
"done",
".",
"If",
"curNs",
"is",
"cl... | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/nl/nl_linux.go#L502-L509 |
25,440 | vishvananda/netlink | nl/nl_linux.go | SetSendTimeout | func (s *NetlinkSocket) SetSendTimeout(timeout *unix.Timeval) error {
// Set a send timeout of SOCKET_SEND_TIMEOUT, this will allow the Send to periodically unblock and avoid that a routine
// remains stuck on a send on a closed fd
return unix.SetsockoptTimeval(int(s.fd), unix.SOL_SOCKET, unix.SO_SNDTIMEO, timeout)
... | go | func (s *NetlinkSocket) SetSendTimeout(timeout *unix.Timeval) error {
// Set a send timeout of SOCKET_SEND_TIMEOUT, this will allow the Send to periodically unblock and avoid that a routine
// remains stuck on a send on a closed fd
return unix.SetsockoptTimeval(int(s.fd), unix.SOL_SOCKET, unix.SO_SNDTIMEO, timeout)
... | [
"func",
"(",
"s",
"*",
"NetlinkSocket",
")",
"SetSendTimeout",
"(",
"timeout",
"*",
"unix",
".",
"Timeval",
")",
"error",
"{",
"// Set a send timeout of SOCKET_SEND_TIMEOUT, this will allow the Send to periodically unblock and avoid that a routine",
"// remains stuck on a send on a... | // SetSendTimeout allows to set a send timeout on the socket | [
"SetSendTimeout",
"allows",
"to",
"set",
"a",
"send",
"timeout",
"on",
"the",
"socket"
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/nl/nl_linux.go#L639-L643 |
25,441 | vishvananda/netlink | nl/nl_linux.go | SetReceiveTimeout | func (s *NetlinkSocket) SetReceiveTimeout(timeout *unix.Timeval) error {
// Set a read timeout of SOCKET_READ_TIMEOUT, this will allow the Read to periodically unblock and avoid that a routine
// remains stuck on a recvmsg on a closed fd
return unix.SetsockoptTimeval(int(s.fd), unix.SOL_SOCKET, unix.SO_RCVTIMEO, tim... | go | func (s *NetlinkSocket) SetReceiveTimeout(timeout *unix.Timeval) error {
// Set a read timeout of SOCKET_READ_TIMEOUT, this will allow the Read to periodically unblock and avoid that a routine
// remains stuck on a recvmsg on a closed fd
return unix.SetsockoptTimeval(int(s.fd), unix.SOL_SOCKET, unix.SO_RCVTIMEO, tim... | [
"func",
"(",
"s",
"*",
"NetlinkSocket",
")",
"SetReceiveTimeout",
"(",
"timeout",
"*",
"unix",
".",
"Timeval",
")",
"error",
"{",
"// Set a read timeout of SOCKET_READ_TIMEOUT, this will allow the Read to periodically unblock and avoid that a routine",
"// remains stuck on a recvms... | // SetReceiveTimeout allows to set a receive timeout on the socket | [
"SetReceiveTimeout",
"allows",
"to",
"set",
"a",
"receive",
"timeout",
"on",
"the",
"socket"
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/nl/nl_linux.go#L646-L650 |
25,442 | vishvananda/netlink | neigh_linux.go | NeighListExecute | func (h *Handle) NeighListExecute(msg Ndmsg) ([]Neigh, error) {
req := h.newNetlinkRequest(unix.RTM_GETNEIGH, unix.NLM_F_DUMP)
req.AddData(&msg)
msgs, err := req.Execute(unix.NETLINK_ROUTE, unix.RTM_NEWNEIGH)
if err != nil {
return nil, err
}
var res []Neigh
for _, m := range msgs {
ndm := deserializeNdmsg... | go | func (h *Handle) NeighListExecute(msg Ndmsg) ([]Neigh, error) {
req := h.newNetlinkRequest(unix.RTM_GETNEIGH, unix.NLM_F_DUMP)
req.AddData(&msg)
msgs, err := req.Execute(unix.NETLINK_ROUTE, unix.RTM_NEWNEIGH)
if err != nil {
return nil, err
}
var res []Neigh
for _, m := range msgs {
ndm := deserializeNdmsg... | [
"func",
"(",
"h",
"*",
"Handle",
")",
"NeighListExecute",
"(",
"msg",
"Ndmsg",
")",
"(",
"[",
"]",
"Neigh",
",",
"error",
")",
"{",
"req",
":=",
"h",
".",
"newNetlinkRequest",
"(",
"unix",
".",
"RTM_GETNEIGH",
",",
"unix",
".",
"NLM_F_DUMP",
")",
"\n... | // NeighListExecute returns a list of neighbour entries filtered by link, ip family, flag and state. | [
"NeighListExecute",
"returns",
"a",
"list",
"of",
"neighbour",
"entries",
"filtered",
"by",
"link",
"ip",
"family",
"flag",
"and",
"state",
"."
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/neigh_linux.go#L221-L247 |
25,443 | vishvananda/netlink | neigh_linux.go | NeighSubscribe | func NeighSubscribe(ch chan<- NeighUpdate, done <-chan struct{}) error {
return neighSubscribeAt(netns.None(), netns.None(), ch, done, nil, false)
} | go | func NeighSubscribe(ch chan<- NeighUpdate, done <-chan struct{}) error {
return neighSubscribeAt(netns.None(), netns.None(), ch, done, nil, false)
} | [
"func",
"NeighSubscribe",
"(",
"ch",
"chan",
"<-",
"NeighUpdate",
",",
"done",
"<-",
"chan",
"struct",
"{",
"}",
")",
"error",
"{",
"return",
"neighSubscribeAt",
"(",
"netns",
".",
"None",
"(",
")",
",",
"netns",
".",
"None",
"(",
")",
",",
"ch",
","... | // NeighSubscribe takes a chan down which notifications will be sent
// when neighbors are added or deleted. Close the 'done' chan to stop subscription. | [
"NeighSubscribe",
"takes",
"a",
"chan",
"down",
"which",
"notifications",
"will",
"be",
"sent",
"when",
"neighbors",
"are",
"added",
"or",
"deleted",
".",
"Close",
"the",
"done",
"chan",
"to",
"stop",
"subscription",
"."
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/neigh_linux.go#L299-L301 |
25,444 | vishvananda/netlink | neigh_linux.go | NeighSubscribeWithOptions | func NeighSubscribeWithOptions(ch chan<- NeighUpdate, done <-chan struct{}, options NeighSubscribeOptions) error {
if options.Namespace == nil {
none := netns.None()
options.Namespace = &none
}
return neighSubscribeAt(*options.Namespace, netns.None(), ch, done, options.ErrorCallback, options.ListExisting)
} | go | func NeighSubscribeWithOptions(ch chan<- NeighUpdate, done <-chan struct{}, options NeighSubscribeOptions) error {
if options.Namespace == nil {
none := netns.None()
options.Namespace = &none
}
return neighSubscribeAt(*options.Namespace, netns.None(), ch, done, options.ErrorCallback, options.ListExisting)
} | [
"func",
"NeighSubscribeWithOptions",
"(",
"ch",
"chan",
"<-",
"NeighUpdate",
",",
"done",
"<-",
"chan",
"struct",
"{",
"}",
",",
"options",
"NeighSubscribeOptions",
")",
"error",
"{",
"if",
"options",
".",
"Namespace",
"==",
"nil",
"{",
"none",
":=",
"netns"... | // NeighSubscribeWithOptions work like NeighSubscribe but enable to
// provide additional options to modify the behavior. Currently, the
// namespace can be provided as well as an error callback. | [
"NeighSubscribeWithOptions",
"work",
"like",
"NeighSubscribe",
"but",
"enable",
"to",
"provide",
"additional",
"options",
"to",
"modify",
"the",
"behavior",
".",
"Currently",
"the",
"namespace",
"can",
"be",
"provided",
"as",
"well",
"as",
"an",
"error",
"callback... | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/neigh_linux.go#L320-L326 |
25,445 | vishvananda/netlink | conntrack_linux.go | AddIP | func (f *ConntrackFilter) AddIP(tp ConntrackFilterType, ip net.IP) error {
if f.ipFilter == nil {
f.ipFilter = make(map[ConntrackFilterType]net.IP)
}
if _, ok := f.ipFilter[tp]; ok {
return errors.New("Filter attribute already present")
}
f.ipFilter[tp] = ip
return nil
} | go | func (f *ConntrackFilter) AddIP(tp ConntrackFilterType, ip net.IP) error {
if f.ipFilter == nil {
f.ipFilter = make(map[ConntrackFilterType]net.IP)
}
if _, ok := f.ipFilter[tp]; ok {
return errors.New("Filter attribute already present")
}
f.ipFilter[tp] = ip
return nil
} | [
"func",
"(",
"f",
"*",
"ConntrackFilter",
")",
"AddIP",
"(",
"tp",
"ConntrackFilterType",
",",
"ip",
"net",
".",
"IP",
")",
"error",
"{",
"if",
"f",
".",
"ipFilter",
"==",
"nil",
"{",
"f",
".",
"ipFilter",
"=",
"make",
"(",
"map",
"[",
"ConntrackFilt... | // AddIP adds an IP to the conntrack filter | [
"AddIP",
"adds",
"an",
"IP",
"to",
"the",
"conntrack",
"filter"
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/conntrack_linux.go#L350-L359 |
25,446 | vishvananda/netlink | conntrack_linux.go | MatchConntrackFlow | func (f *ConntrackFilter) MatchConntrackFlow(flow *ConntrackFlow) bool {
if len(f.ipFilter) == 0 {
// empty filter always not match
return false
}
match := true
// -orig-src ip Source address from original direction
if elem, found := f.ipFilter[ConntrackOrigSrcIP]; found {
match = match && elem.Equal(flow... | go | func (f *ConntrackFilter) MatchConntrackFlow(flow *ConntrackFlow) bool {
if len(f.ipFilter) == 0 {
// empty filter always not match
return false
}
match := true
// -orig-src ip Source address from original direction
if elem, found := f.ipFilter[ConntrackOrigSrcIP]; found {
match = match && elem.Equal(flow... | [
"func",
"(",
"f",
"*",
"ConntrackFilter",
")",
"MatchConntrackFlow",
"(",
"flow",
"*",
"ConntrackFlow",
")",
"bool",
"{",
"if",
"len",
"(",
"f",
".",
"ipFilter",
")",
"==",
"0",
"{",
"// empty filter always not match",
"return",
"false",
"\n",
"}",
"\n\n",
... | // MatchConntrackFlow applies the filter to the flow and returns true if the flow matches the filter
// false otherwise | [
"MatchConntrackFlow",
"applies",
"the",
"filter",
"to",
"the",
"flow",
"and",
"returns",
"true",
"if",
"the",
"flow",
"matches",
"the",
"filter",
"false",
"otherwise"
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/conntrack_linux.go#L363-L396 |
25,447 | vishvananda/netlink | protinfo.go | String | func (prot *Protinfo) String() string {
if prot == nil {
return "<nil>"
}
var boolStrings []string
if prot.Hairpin {
boolStrings = append(boolStrings, "Hairpin")
}
if prot.Guard {
boolStrings = append(boolStrings, "Guard")
}
if prot.FastLeave {
boolStrings = append(boolStrings, "FastLeave")
}
if prot... | go | func (prot *Protinfo) String() string {
if prot == nil {
return "<nil>"
}
var boolStrings []string
if prot.Hairpin {
boolStrings = append(boolStrings, "Hairpin")
}
if prot.Guard {
boolStrings = append(boolStrings, "Guard")
}
if prot.FastLeave {
boolStrings = append(boolStrings, "FastLeave")
}
if prot... | [
"func",
"(",
"prot",
"*",
"Protinfo",
")",
"String",
"(",
")",
"string",
"{",
"if",
"prot",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"var",
"boolStrings",
"[",
"]",
"string",
"\n",
"if",
"prot",
".",
"Hairpin",
"{",
"boolStrings",
... | // String returns a list of enabled flags | [
"String",
"returns",
"a",
"list",
"of",
"enabled",
"flags"
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/protinfo.go#L20-L51 |
25,448 | vishvananda/netlink | class.go | Attrs | func (c *ServiceCurve) Attrs() (uint32, uint32, uint32) {
return c.m1, c.d, c.m2
} | go | func (c *ServiceCurve) Attrs() (uint32, uint32, uint32) {
return c.m1, c.d, c.m2
} | [
"func",
"(",
"c",
"*",
"ServiceCurve",
")",
"Attrs",
"(",
")",
"(",
"uint32",
",",
"uint32",
",",
"uint32",
")",
"{",
"return",
"c",
".",
"m1",
",",
"c",
".",
"d",
",",
"c",
".",
"m2",
"\n",
"}"
] | // Attrs return the parameters of the service curve | [
"Attrs",
"return",
"the",
"parameters",
"of",
"the",
"service",
"curve"
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/class.go#L143-L145 |
25,449 | vishvananda/netlink | class.go | SetRsc | func (hfsc *HfscClass) SetRsc(m1 uint32, d uint32, m2 uint32) {
hfsc.Rsc = ServiceCurve{m1: m1 / 8, d: d, m2: m2 / 8}
} | go | func (hfsc *HfscClass) SetRsc(m1 uint32, d uint32, m2 uint32) {
hfsc.Rsc = ServiceCurve{m1: m1 / 8, d: d, m2: m2 / 8}
} | [
"func",
"(",
"hfsc",
"*",
"HfscClass",
")",
"SetRsc",
"(",
"m1",
"uint32",
",",
"d",
"uint32",
",",
"m2",
"uint32",
")",
"{",
"hfsc",
".",
"Rsc",
"=",
"ServiceCurve",
"{",
"m1",
":",
"m1",
"/",
"8",
",",
"d",
":",
"d",
",",
"m2",
":",
"m2",
"... | // SetRsc sets the Rsc curve | [
"SetRsc",
"sets",
"the",
"Rsc",
"curve"
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/class.go#L166-L168 |
25,450 | vishvananda/netlink | class.go | SetSC | func (hfsc *HfscClass) SetSC(m1 uint32, d uint32, m2 uint32) {
hfsc.Rsc = ServiceCurve{m1: m1 / 8, d: d, m2: m2 / 8}
hfsc.Fsc = ServiceCurve{m1: m1 / 8, d: d, m2: m2 / 8}
} | go | func (hfsc *HfscClass) SetSC(m1 uint32, d uint32, m2 uint32) {
hfsc.Rsc = ServiceCurve{m1: m1 / 8, d: d, m2: m2 / 8}
hfsc.Fsc = ServiceCurve{m1: m1 / 8, d: d, m2: m2 / 8}
} | [
"func",
"(",
"hfsc",
"*",
"HfscClass",
")",
"SetSC",
"(",
"m1",
"uint32",
",",
"d",
"uint32",
",",
"m2",
"uint32",
")",
"{",
"hfsc",
".",
"Rsc",
"=",
"ServiceCurve",
"{",
"m1",
":",
"m1",
"/",
"8",
",",
"d",
":",
"d",
",",
"m2",
":",
"m2",
"/... | // SetSC implements the SC from the tc CLI | [
"SetSC",
"implements",
"the",
"SC",
"from",
"the",
"tc",
"CLI"
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/class.go#L171-L174 |
25,451 | vishvananda/netlink | class.go | SetUL | func (hfsc *HfscClass) SetUL(m1 uint32, d uint32, m2 uint32) {
hfsc.Usc = ServiceCurve{m1: m1 / 8, d: d, m2: m2 / 8}
} | go | func (hfsc *HfscClass) SetUL(m1 uint32, d uint32, m2 uint32) {
hfsc.Usc = ServiceCurve{m1: m1 / 8, d: d, m2: m2 / 8}
} | [
"func",
"(",
"hfsc",
"*",
"HfscClass",
")",
"SetUL",
"(",
"m1",
"uint32",
",",
"d",
"uint32",
",",
"m2",
"uint32",
")",
"{",
"hfsc",
".",
"Usc",
"=",
"ServiceCurve",
"{",
"m1",
":",
"m1",
"/",
"8",
",",
"d",
":",
"d",
",",
"m2",
":",
"m2",
"/... | // SetUL implements the UL from the tc CLI | [
"SetUL",
"implements",
"the",
"UL",
"from",
"the",
"tc",
"CLI"
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/class.go#L177-L179 |
25,452 | vishvananda/netlink | class.go | SetLS | func (hfsc *HfscClass) SetLS(m1 uint32, d uint32, m2 uint32) {
hfsc.Fsc = ServiceCurve{m1: m1 / 8, d: d, m2: m2 / 8}
} | go | func (hfsc *HfscClass) SetLS(m1 uint32, d uint32, m2 uint32) {
hfsc.Fsc = ServiceCurve{m1: m1 / 8, d: d, m2: m2 / 8}
} | [
"func",
"(",
"hfsc",
"*",
"HfscClass",
")",
"SetLS",
"(",
"m1",
"uint32",
",",
"d",
"uint32",
",",
"m2",
"uint32",
")",
"{",
"hfsc",
".",
"Fsc",
"=",
"ServiceCurve",
"{",
"m1",
":",
"m1",
"/",
"8",
",",
"d",
":",
"d",
",",
"m2",
":",
"m2",
"/... | // SetLS implements the LS from the tc CLI | [
"SetLS",
"implements",
"the",
"LS",
"from",
"the",
"tc",
"CLI"
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/class.go#L182-L184 |
25,453 | vishvananda/netlink | class.go | NewHfscClass | func NewHfscClass(attrs ClassAttrs) *HfscClass {
return &HfscClass{
ClassAttrs: attrs,
Rsc: ServiceCurve{},
Fsc: ServiceCurve{},
Usc: ServiceCurve{},
}
} | go | func NewHfscClass(attrs ClassAttrs) *HfscClass {
return &HfscClass{
ClassAttrs: attrs,
Rsc: ServiceCurve{},
Fsc: ServiceCurve{},
Usc: ServiceCurve{},
}
} | [
"func",
"NewHfscClass",
"(",
"attrs",
"ClassAttrs",
")",
"*",
"HfscClass",
"{",
"return",
"&",
"HfscClass",
"{",
"ClassAttrs",
":",
"attrs",
",",
"Rsc",
":",
"ServiceCurve",
"{",
"}",
",",
"Fsc",
":",
"ServiceCurve",
"{",
"}",
",",
"Usc",
":",
"ServiceCu... | // NewHfscClass returns a new HFSC struct with the set parameters | [
"NewHfscClass",
"returns",
"a",
"new",
"HFSC",
"struct",
"with",
"the",
"set",
"parameters"
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/class.go#L187-L194 |
25,454 | vishvananda/netlink | link.go | StringToBondMode | func StringToBondMode(s string) BondMode {
mode, ok := StringToBondModeMap[s]
if !ok {
return BOND_MODE_UNKNOWN
}
return mode
} | go | func StringToBondMode(s string) BondMode {
mode, ok := StringToBondModeMap[s]
if !ok {
return BOND_MODE_UNKNOWN
}
return mode
} | [
"func",
"StringToBondMode",
"(",
"s",
"string",
")",
"BondMode",
"{",
"mode",
",",
"ok",
":=",
"StringToBondModeMap",
"[",
"s",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"BOND_MODE_UNKNOWN",
"\n",
"}",
"\n",
"return",
"mode",
"\n",
"}"
] | // StringToBondMode returns bond mode, or uknonw is the s is invalid. | [
"StringToBondMode",
"returns",
"bond",
"mode",
"or",
"uknonw",
"is",
"the",
"s",
"is",
"invalid",
"."
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/link.go#L420-L426 |
25,455 | vishvananda/netlink | link.go | StringToBondXmitHashPolicy | func StringToBondXmitHashPolicy(s string) BondXmitHashPolicy {
lacp, ok := StringToBondXmitHashPolicyMap[s]
if !ok {
return BOND_XMIT_HASH_POLICY_UNKNOWN
}
return lacp
} | go | func StringToBondXmitHashPolicy(s string) BondXmitHashPolicy {
lacp, ok := StringToBondXmitHashPolicyMap[s]
if !ok {
return BOND_XMIT_HASH_POLICY_UNKNOWN
}
return lacp
} | [
"func",
"StringToBondXmitHashPolicy",
"(",
"s",
"string",
")",
"BondXmitHashPolicy",
"{",
"lacp",
",",
"ok",
":=",
"StringToBondXmitHashPolicyMap",
"[",
"s",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"BOND_XMIT_HASH_POLICY_UNKNOWN",
"\n",
"}",
"\n",
"return",
"... | // StringToBondXmitHashPolicy returns bond lacp arte, or uknonw is the s is invalid. | [
"StringToBondXmitHashPolicy",
"returns",
"bond",
"lacp",
"arte",
"or",
"uknonw",
"is",
"the",
"s",
"is",
"invalid",
"."
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/link.go#L511-L517 |
25,456 | vishvananda/netlink | link.go | StringToBondLacpRate | func StringToBondLacpRate(s string) BondLacpRate {
lacp, ok := StringToBondLacpRateMap[s]
if !ok {
return BOND_LACP_RATE_UNKNOWN
}
return lacp
} | go | func StringToBondLacpRate(s string) BondLacpRate {
lacp, ok := StringToBondLacpRateMap[s]
if !ok {
return BOND_LACP_RATE_UNKNOWN
}
return lacp
} | [
"func",
"StringToBondLacpRate",
"(",
"s",
"string",
")",
"BondLacpRate",
"{",
"lacp",
",",
"ok",
":=",
"StringToBondLacpRateMap",
"[",
"s",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"BOND_LACP_RATE_UNKNOWN",
"\n",
"}",
"\n",
"return",
"lacp",
"\n",
"}"
] | // StringToBondLacpRate returns bond lacp arte, or uknonw is the s is invalid. | [
"StringToBondLacpRate",
"returns",
"bond",
"lacp",
"arte",
"or",
"uknonw",
"is",
"the",
"s",
"is",
"invalid",
"."
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/link.go#L556-L562 |
25,457 | vishvananda/netlink | devlink_linux.go | DevLinkGetDeviceList | func (h *Handle) DevLinkGetDeviceList() ([]*DevlinkDevice, error) {
f, err := h.GenlFamilyGet(nl.GENL_DEVLINK_NAME)
if err != nil {
return nil, err
}
msg := &nl.Genlmsg{
Command: nl.DEVLINK_CMD_GET,
Version: nl.GENL_DEVLINK_VERSION,
}
req := h.newNetlinkRequest(int(f.ID),
unix.NLM_F_REQUEST|unix.NLM_F_ACK... | go | func (h *Handle) DevLinkGetDeviceList() ([]*DevlinkDevice, error) {
f, err := h.GenlFamilyGet(nl.GENL_DEVLINK_NAME)
if err != nil {
return nil, err
}
msg := &nl.Genlmsg{
Command: nl.DEVLINK_CMD_GET,
Version: nl.GENL_DEVLINK_VERSION,
}
req := h.newNetlinkRequest(int(f.ID),
unix.NLM_F_REQUEST|unix.NLM_F_ACK... | [
"func",
"(",
"h",
"*",
"Handle",
")",
"DevLinkGetDeviceList",
"(",
")",
"(",
"[",
"]",
"*",
"DevlinkDevice",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"h",
".",
"GenlFamilyGet",
"(",
"nl",
".",
"GENL_DEVLINK_NAME",
")",
"\n",
"if",
"err",
"!=",
... | // DevLinkGetDeviceList provides a pointer to devlink devices and nil error,
// otherwise returns an error code. | [
"DevLinkGetDeviceList",
"provides",
"a",
"pointer",
"to",
"devlink",
"devices",
"and",
"nil",
"error",
"otherwise",
"returns",
"an",
"error",
"code",
"."
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/devlink_linux.go#L148-L172 |
25,458 | vishvananda/netlink | rdma_link_linux.go | RdmaLinkByName | func (h *Handle) RdmaLinkByName(name string) (*RdmaLink, error) {
proto := getProtoField(nl.RDMA_NL_NLDEV, nl.RDMA_NLDEV_CMD_GET)
req := h.newNetlinkRequest(proto, unix.NLM_F_ACK|unix.NLM_F_DUMP)
return execRdmaGetLink(req, name)
} | go | func (h *Handle) RdmaLinkByName(name string) (*RdmaLink, error) {
proto := getProtoField(nl.RDMA_NL_NLDEV, nl.RDMA_NLDEV_CMD_GET)
req := h.newNetlinkRequest(proto, unix.NLM_F_ACK|unix.NLM_F_DUMP)
return execRdmaGetLink(req, name)
} | [
"func",
"(",
"h",
"*",
"Handle",
")",
"RdmaLinkByName",
"(",
"name",
"string",
")",
"(",
"*",
"RdmaLink",
",",
"error",
")",
"{",
"proto",
":=",
"getProtoField",
"(",
"nl",
".",
"RDMA_NL_NLDEV",
",",
"nl",
".",
"RDMA_NLDEV_CMD_GET",
")",
"\n",
"req",
"... | // RdmaLinkByName finds a link by name and returns a pointer to the object if
// found and nil error, otherwise returns error code. | [
"RdmaLinkByName",
"finds",
"a",
"link",
"by",
"name",
"and",
"returns",
"a",
"pointer",
"to",
"the",
"object",
"if",
"found",
"and",
"nil",
"error",
"otherwise",
"returns",
"error",
"code",
"."
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/rdma_link_linux.go#L112-L118 |
25,459 | vishvananda/netlink | netlink.go | NewIPNet | func NewIPNet(ip net.IP) *net.IPNet {
if ip.To4() != nil {
return &net.IPNet{IP: ip, Mask: net.CIDRMask(32, 32)}
}
return &net.IPNet{IP: ip, Mask: net.CIDRMask(128, 128)}
} | go | func NewIPNet(ip net.IP) *net.IPNet {
if ip.To4() != nil {
return &net.IPNet{IP: ip, Mask: net.CIDRMask(32, 32)}
}
return &net.IPNet{IP: ip, Mask: net.CIDRMask(128, 128)}
} | [
"func",
"NewIPNet",
"(",
"ip",
"net",
".",
"IP",
")",
"*",
"net",
".",
"IPNet",
"{",
"if",
"ip",
".",
"To4",
"(",
")",
"!=",
"nil",
"{",
"return",
"&",
"net",
".",
"IPNet",
"{",
"IP",
":",
"ip",
",",
"Mask",
":",
"net",
".",
"CIDRMask",
"(",
... | // NewIPNet generates an IPNet from an ip address using a netmask of 32 or 128. | [
"NewIPNet",
"generates",
"an",
"IPNet",
"from",
"an",
"ip",
"address",
"using",
"a",
"netmask",
"of",
"32",
"or",
"128",
"."
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/netlink.go#L35-L40 |
25,460 | vishvananda/netlink | link_linux.go | LinkSetVfGUID | func (h *Handle) LinkSetVfGUID(link Link, vf int, vfGuid net.HardwareAddr, guidType int) error {
var err error
var guid uint64
buf := bytes.NewBuffer(vfGuid)
err = binary.Read(buf, binary.LittleEndian, &guid)
if err != nil {
return err
}
base := link.Attrs()
h.ensureIndex(base)
req := h.newNetlinkRequest(u... | go | func (h *Handle) LinkSetVfGUID(link Link, vf int, vfGuid net.HardwareAddr, guidType int) error {
var err error
var guid uint64
buf := bytes.NewBuffer(vfGuid)
err = binary.Read(buf, binary.LittleEndian, &guid)
if err != nil {
return err
}
base := link.Attrs()
h.ensureIndex(base)
req := h.newNetlinkRequest(u... | [
"func",
"(",
"h",
"*",
"Handle",
")",
"LinkSetVfGUID",
"(",
"link",
"Link",
",",
"vf",
"int",
",",
"vfGuid",
"net",
".",
"HardwareAddr",
",",
"guidType",
"int",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"var",
"guid",
"uint64",
"\n\n",
"buf",
"... | // LinkSetVfGUID sets the node or port GUID of a vf for the link. | [
"LinkSetVfGUID",
"sets",
"the",
"node",
"or",
"port",
"GUID",
"of",
"a",
"vf",
"for",
"the",
"link",
"."
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/link_linux.go#L579-L608 |
25,461 | vishvananda/netlink | link_linux.go | LinkByName | func (h *Handle) LinkByName(name string) (Link, error) {
if h.lookupByDump {
return h.linkByNameDump(name)
}
req := h.newNetlinkRequest(unix.RTM_GETLINK, unix.NLM_F_ACK)
msg := nl.NewIfInfomsg(unix.AF_UNSPEC)
req.AddData(msg)
attr := nl.NewRtAttr(unix.IFLA_EXT_MASK, nl.Uint32Attr(nl.RTEXT_FILTER_VF))
req.Ad... | go | func (h *Handle) LinkByName(name string) (Link, error) {
if h.lookupByDump {
return h.linkByNameDump(name)
}
req := h.newNetlinkRequest(unix.RTM_GETLINK, unix.NLM_F_ACK)
msg := nl.NewIfInfomsg(unix.AF_UNSPEC)
req.AddData(msg)
attr := nl.NewRtAttr(unix.IFLA_EXT_MASK, nl.Uint32Attr(nl.RTEXT_FILTER_VF))
req.Ad... | [
"func",
"(",
"h",
"*",
"Handle",
")",
"LinkByName",
"(",
"name",
"string",
")",
"(",
"Link",
",",
"error",
")",
"{",
"if",
"h",
".",
"lookupByDump",
"{",
"return",
"h",
".",
"linkByNameDump",
"(",
"name",
")",
"\n",
"}",
"\n\n",
"req",
":=",
"h",
... | // LinkByName finds a link by name and returns a pointer to the object. | [
"LinkByName",
"finds",
"a",
"link",
"by",
"name",
"and",
"returns",
"a",
"pointer",
"to",
"the",
"object",
"."
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/link_linux.go#L1283-L1308 |
25,462 | vishvananda/netlink | link_linux.go | LinkByAlias | func (h *Handle) LinkByAlias(alias string) (Link, error) {
if h.lookupByDump {
return h.linkByAliasDump(alias)
}
req := h.newNetlinkRequest(unix.RTM_GETLINK, unix.NLM_F_ACK)
msg := nl.NewIfInfomsg(unix.AF_UNSPEC)
req.AddData(msg)
attr := nl.NewRtAttr(unix.IFLA_EXT_MASK, nl.Uint32Attr(nl.RTEXT_FILTER_VF))
re... | go | func (h *Handle) LinkByAlias(alias string) (Link, error) {
if h.lookupByDump {
return h.linkByAliasDump(alias)
}
req := h.newNetlinkRequest(unix.RTM_GETLINK, unix.NLM_F_ACK)
msg := nl.NewIfInfomsg(unix.AF_UNSPEC)
req.AddData(msg)
attr := nl.NewRtAttr(unix.IFLA_EXT_MASK, nl.Uint32Attr(nl.RTEXT_FILTER_VF))
re... | [
"func",
"(",
"h",
"*",
"Handle",
")",
"LinkByAlias",
"(",
"alias",
"string",
")",
"(",
"Link",
",",
"error",
")",
"{",
"if",
"h",
".",
"lookupByDump",
"{",
"return",
"h",
".",
"linkByAliasDump",
"(",
"alias",
")",
"\n",
"}",
"\n\n",
"req",
":=",
"h... | // LinkByAlias finds a link by its alias and returns a pointer to the object.
// If there are multiple links with the alias it returns the first one | [
"LinkByAlias",
"finds",
"a",
"link",
"by",
"its",
"alias",
"and",
"returns",
"a",
"pointer",
"to",
"the",
"object",
".",
"If",
"there",
"are",
"multiple",
"links",
"with",
"the",
"alias",
"it",
"returns",
"the",
"first",
"one"
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/link_linux.go#L1318-L1343 |
25,463 | vishvananda/netlink | link_linux.go | LinkByIndex | func (h *Handle) LinkByIndex(index int) (Link, error) {
req := h.newNetlinkRequest(unix.RTM_GETLINK, unix.NLM_F_ACK)
msg := nl.NewIfInfomsg(unix.AF_UNSPEC)
msg.Index = int32(index)
req.AddData(msg)
attr := nl.NewRtAttr(unix.IFLA_EXT_MASK, nl.Uint32Attr(nl.RTEXT_FILTER_VF))
req.AddData(attr)
return execGetLink(... | go | func (h *Handle) LinkByIndex(index int) (Link, error) {
req := h.newNetlinkRequest(unix.RTM_GETLINK, unix.NLM_F_ACK)
msg := nl.NewIfInfomsg(unix.AF_UNSPEC)
msg.Index = int32(index)
req.AddData(msg)
attr := nl.NewRtAttr(unix.IFLA_EXT_MASK, nl.Uint32Attr(nl.RTEXT_FILTER_VF))
req.AddData(attr)
return execGetLink(... | [
"func",
"(",
"h",
"*",
"Handle",
")",
"LinkByIndex",
"(",
"index",
"int",
")",
"(",
"Link",
",",
"error",
")",
"{",
"req",
":=",
"h",
".",
"newNetlinkRequest",
"(",
"unix",
".",
"RTM_GETLINK",
",",
"unix",
".",
"NLM_F_ACK",
")",
"\n\n",
"msg",
":=",
... | // LinkByIndex finds a link by index and returns a pointer to the object. | [
"LinkByIndex",
"finds",
"a",
"link",
"by",
"index",
"and",
"returns",
"a",
"pointer",
"to",
"the",
"object",
"."
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/link_linux.go#L1351-L1361 |
25,464 | vishvananda/netlink | link_linux.go | LinkSubscribe | func LinkSubscribe(ch chan<- LinkUpdate, done <-chan struct{}) error {
return linkSubscribeAt(netns.None(), netns.None(), ch, done, nil, false)
} | go | func LinkSubscribe(ch chan<- LinkUpdate, done <-chan struct{}) error {
return linkSubscribeAt(netns.None(), netns.None(), ch, done, nil, false)
} | [
"func",
"LinkSubscribe",
"(",
"ch",
"chan",
"<-",
"LinkUpdate",
",",
"done",
"<-",
"chan",
"struct",
"{",
"}",
")",
"error",
"{",
"return",
"linkSubscribeAt",
"(",
"netns",
".",
"None",
"(",
")",
",",
"netns",
".",
"None",
"(",
")",
",",
"ch",
",",
... | // LinkSubscribe takes a chan down which notifications will be sent
// when links change. Close the 'done' chan to stop subscription. | [
"LinkSubscribe",
"takes",
"a",
"chan",
"down",
"which",
"notifications",
"will",
"be",
"sent",
"when",
"links",
"change",
".",
"Close",
"the",
"done",
"chan",
"to",
"stop",
"subscription",
"."
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/link_linux.go#L1626-L1628 |
25,465 | vishvananda/netlink | link_linux.go | LinkSubscribeWithOptions | func LinkSubscribeWithOptions(ch chan<- LinkUpdate, done <-chan struct{}, options LinkSubscribeOptions) error {
if options.Namespace == nil {
none := netns.None()
options.Namespace = &none
}
return linkSubscribeAt(*options.Namespace, netns.None(), ch, done, options.ErrorCallback, options.ListExisting)
} | go | func LinkSubscribeWithOptions(ch chan<- LinkUpdate, done <-chan struct{}, options LinkSubscribeOptions) error {
if options.Namespace == nil {
none := netns.None()
options.Namespace = &none
}
return linkSubscribeAt(*options.Namespace, netns.None(), ch, done, options.ErrorCallback, options.ListExisting)
} | [
"func",
"LinkSubscribeWithOptions",
"(",
"ch",
"chan",
"<-",
"LinkUpdate",
",",
"done",
"<-",
"chan",
"struct",
"{",
"}",
",",
"options",
"LinkSubscribeOptions",
")",
"error",
"{",
"if",
"options",
".",
"Namespace",
"==",
"nil",
"{",
"none",
":=",
"netns",
... | // LinkSubscribeWithOptions work like LinkSubscribe but enable to
// provide additional options to modify the behavior. Currently, the
// namespace can be provided as well as an error callback. | [
"LinkSubscribeWithOptions",
"work",
"like",
"LinkSubscribe",
"but",
"enable",
"to",
"provide",
"additional",
"options",
"to",
"modify",
"the",
"behavior",
".",
"Currently",
"the",
"namespace",
"can",
"be",
"provided",
"as",
"well",
"as",
"an",
"error",
"callback",... | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/link_linux.go#L1647-L1653 |
25,466 | vishvananda/netlink | link_linux.go | LinkSetBondSlave | func LinkSetBondSlave(link Link, master *Bond) error {
fd, err := getSocketUDP()
if err != nil {
return err
}
defer syscall.Close(fd)
ifreq := newIocltSlaveReq(link.Attrs().Name, master.Attrs().Name)
_, _, errno := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), unix.SIOCBONDENSLAVE, uintptr(unsafe.Pointer(if... | go | func LinkSetBondSlave(link Link, master *Bond) error {
fd, err := getSocketUDP()
if err != nil {
return err
}
defer syscall.Close(fd)
ifreq := newIocltSlaveReq(link.Attrs().Name, master.Attrs().Name)
_, _, errno := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), unix.SIOCBONDENSLAVE, uintptr(unsafe.Pointer(if... | [
"func",
"LinkSetBondSlave",
"(",
"link",
"Link",
",",
"master",
"*",
"Bond",
")",
"error",
"{",
"fd",
",",
"err",
":=",
"getSocketUDP",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"syscall",
".",
"Close",... | // LinkSetBondSlave add slave to bond link via ioctl interface. | [
"LinkSetBondSlave",
"add",
"slave",
"to",
"bond",
"link",
"via",
"ioctl",
"interface",
"."
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/link_linux.go#L2531-L2545 |
25,467 | vishvananda/netlink | link_linux.go | VethPeerIndex | func VethPeerIndex(link *Veth) (int, error) {
fd, err := getSocketUDP()
if err != nil {
return -1, err
}
defer syscall.Close(fd)
ifreq, sSet := newIocltStringSetReq(link.Name)
_, _, errno := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), SIOCETHTOOL, uintptr(unsafe.Pointer(ifreq)))
if errno != 0 {
return -... | go | func VethPeerIndex(link *Veth) (int, error) {
fd, err := getSocketUDP()
if err != nil {
return -1, err
}
defer syscall.Close(fd)
ifreq, sSet := newIocltStringSetReq(link.Name)
_, _, errno := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), SIOCETHTOOL, uintptr(unsafe.Pointer(ifreq)))
if errno != 0 {
return -... | [
"func",
"VethPeerIndex",
"(",
"link",
"*",
"Veth",
")",
"(",
"int",
",",
"error",
")",
"{",
"fd",
",",
"err",
":=",
"getSocketUDP",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"-",
"1",
",",
"err",
"\n",
"}",
"\n",
"defer",
"syscall"... | // VethPeerIndex get veth peer index. | [
"VethPeerIndex",
"get",
"veth",
"peer",
"index",
"."
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/link_linux.go#L2548-L2582 |
25,468 | vishvananda/netlink | netns_linux.go | GetNetNsIdByFd | func (h *Handle) GetNetNsIdByFd(fd int) (int, error) {
return h.getNetNsId(NETNSA_FD, uint32(fd))
} | go | func (h *Handle) GetNetNsIdByFd(fd int) (int, error) {
return h.getNetNsId(NETNSA_FD, uint32(fd))
} | [
"func",
"(",
"h",
"*",
"Handle",
")",
"GetNetNsIdByFd",
"(",
"fd",
"int",
")",
"(",
"int",
",",
"error",
")",
"{",
"return",
"h",
".",
"getNetNsId",
"(",
"NETNSA_FD",
",",
"uint32",
"(",
"fd",
")",
")",
"\n",
"}"
] | // GetNetNsIdByFd looks up the network namespace ID for a given fd.
// fd must be an open file descriptor to a namespace file.
// Returns -1 if the namespace does not have an ID set. | [
"GetNetNsIdByFd",
"looks",
"up",
"the",
"network",
"namespace",
"ID",
"for",
"a",
"given",
"fd",
".",
"fd",
"must",
"be",
"an",
"open",
"file",
"descriptor",
"to",
"a",
"namespace",
"file",
".",
"Returns",
"-",
"1",
"if",
"the",
"namespace",
"does",
"not... | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/netns_linux.go#L57-L59 |
25,469 | vishvananda/netlink | netns_linux.go | SetNetNsIdByFd | func (h *Handle) SetNetNsIdByFd(fd, nsid int) error {
return h.setNetNsId(NETNSA_FD, uint32(fd), uint32(nsid))
} | go | func (h *Handle) SetNetNsIdByFd(fd, nsid int) error {
return h.setNetNsId(NETNSA_FD, uint32(fd), uint32(nsid))
} | [
"func",
"(",
"h",
"*",
"Handle",
")",
"SetNetNsIdByFd",
"(",
"fd",
",",
"nsid",
"int",
")",
"error",
"{",
"return",
"h",
".",
"setNetNsId",
"(",
"NETNSA_FD",
",",
"uint32",
"(",
"fd",
")",
",",
"uint32",
"(",
"nsid",
")",
")",
"\n",
"}"
] | // SetNetNSIdByFd sets the ID of the network namespace for a given fd.
// fd must be an open file descriptor to a namespace file.
// The ID can only be set for namespaces without an ID already set. | [
"SetNetNSIdByFd",
"sets",
"the",
"ID",
"of",
"the",
"network",
"namespace",
"for",
"a",
"given",
"fd",
".",
"fd",
"must",
"be",
"an",
"open",
"file",
"descriptor",
"to",
"a",
"namespace",
"file",
".",
"The",
"ID",
"can",
"only",
"be",
"set",
"for",
"na... | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/netns_linux.go#L71-L73 |
25,470 | vishvananda/netlink | netns_linux.go | getNetNsId | func (h *Handle) getNetNsId(attrType int, val uint32) (int, error) {
req := h.newNetlinkRequest(unix.RTM_GETNSID, unix.NLM_F_REQUEST)
rtgen := nl.NewRtGenMsg()
req.AddData(rtgen)
b := make([]byte, 4, 4)
native.PutUint32(b, val)
attr := nl.NewRtAttr(attrType, b)
req.AddData(attr)
msgs, err := req.Execute(unix... | go | func (h *Handle) getNetNsId(attrType int, val uint32) (int, error) {
req := h.newNetlinkRequest(unix.RTM_GETNSID, unix.NLM_F_REQUEST)
rtgen := nl.NewRtGenMsg()
req.AddData(rtgen)
b := make([]byte, 4, 4)
native.PutUint32(b, val)
attr := nl.NewRtAttr(attrType, b)
req.AddData(attr)
msgs, err := req.Execute(unix... | [
"func",
"(",
"h",
"*",
"Handle",
")",
"getNetNsId",
"(",
"attrType",
"int",
",",
"val",
"uint32",
")",
"(",
"int",
",",
"error",
")",
"{",
"req",
":=",
"h",
".",
"newNetlinkRequest",
"(",
"unix",
".",
"RTM_GETNSID",
",",
"unix",
".",
"NLM_F_REQUEST",
... | // getNetNsId requests the netnsid for a given type-val pair
// type should be either NETNSA_PID or NETNSA_FD | [
"getNetNsId",
"requests",
"the",
"netnsid",
"for",
"a",
"given",
"type",
"-",
"val",
"pair",
"type",
"should",
"be",
"either",
"NETNSA_PID",
"or",
"NETNSA_FD"
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/netns_linux.go#L84-L118 |
25,471 | vishvananda/netlink | netns_linux.go | setNetNsId | func (h *Handle) setNetNsId(attrType int, val uint32, newnsid uint32) error {
req := h.newNetlinkRequest(unix.RTM_NEWNSID, unix.NLM_F_REQUEST|unix.NLM_F_ACK)
rtgen := nl.NewRtGenMsg()
req.AddData(rtgen)
b := make([]byte, 4, 4)
native.PutUint32(b, val)
attr := nl.NewRtAttr(attrType, b)
req.AddData(attr)
b1 :=... | go | func (h *Handle) setNetNsId(attrType int, val uint32, newnsid uint32) error {
req := h.newNetlinkRequest(unix.RTM_NEWNSID, unix.NLM_F_REQUEST|unix.NLM_F_ACK)
rtgen := nl.NewRtGenMsg()
req.AddData(rtgen)
b := make([]byte, 4, 4)
native.PutUint32(b, val)
attr := nl.NewRtAttr(attrType, b)
req.AddData(attr)
b1 :=... | [
"func",
"(",
"h",
"*",
"Handle",
")",
"setNetNsId",
"(",
"attrType",
"int",
",",
"val",
"uint32",
",",
"newnsid",
"uint32",
")",
"error",
"{",
"req",
":=",
"h",
".",
"newNetlinkRequest",
"(",
"unix",
".",
"RTM_NEWNSID",
",",
"unix",
".",
"NLM_F_REQUEST",... | // setNetNsId sets the netnsid for a given type-val pair
// type should be either NETNSA_PID or NETNSA_FD
// The ID can only be set for namespaces without an ID already set | [
"setNetNsId",
"sets",
"the",
"netnsid",
"for",
"a",
"given",
"type",
"-",
"val",
"pair",
"type",
"should",
"be",
"either",
"NETNSA_PID",
"or",
"NETNSA_FD",
"The",
"ID",
"can",
"only",
"be",
"set",
"for",
"namespaces",
"without",
"an",
"ID",
"already",
"set... | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/netns_linux.go#L123-L141 |
25,472 | vishvananda/netlink | route.go | ipNetEqual | func ipNetEqual(ipn1 *net.IPNet, ipn2 *net.IPNet) bool {
if ipn1 == ipn2 {
return true
}
if ipn1 == nil || ipn2 == nil {
return false
}
m1, _ := ipn1.Mask.Size()
m2, _ := ipn2.Mask.Size()
return m1 == m2 && ipn1.IP.Equal(ipn2.IP)
} | go | func ipNetEqual(ipn1 *net.IPNet, ipn2 *net.IPNet) bool {
if ipn1 == ipn2 {
return true
}
if ipn1 == nil || ipn2 == nil {
return false
}
m1, _ := ipn1.Mask.Size()
m2, _ := ipn2.Mask.Size()
return m1 == m2 && ipn1.IP.Equal(ipn2.IP)
} | [
"func",
"ipNetEqual",
"(",
"ipn1",
"*",
"net",
".",
"IPNet",
",",
"ipn2",
"*",
"net",
".",
"IPNet",
")",
"bool",
"{",
"if",
"ipn1",
"==",
"ipn2",
"{",
"return",
"true",
"\n",
"}",
"\n",
"if",
"ipn1",
"==",
"nil",
"||",
"ipn2",
"==",
"nil",
"{",
... | // ipNetEqual returns true iff both IPNet are equal | [
"ipNetEqual",
"returns",
"true",
"iff",
"both",
"IPNet",
"are",
"equal"
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/route.go#L170-L180 |
25,473 | vishvananda/netlink | ioctl_linux.go | newIocltSlaveReq | func newIocltSlaveReq(slave, master string) *IfreqSlave {
ifreq := &IfreqSlave{}
copy(ifreq.Name[:unix.IFNAMSIZ-1], master)
copy(ifreq.Slave[:unix.IFNAMSIZ-1], slave)
return ifreq
} | go | func newIocltSlaveReq(slave, master string) *IfreqSlave {
ifreq := &IfreqSlave{}
copy(ifreq.Name[:unix.IFNAMSIZ-1], master)
copy(ifreq.Slave[:unix.IFNAMSIZ-1], slave)
return ifreq
} | [
"func",
"newIocltSlaveReq",
"(",
"slave",
",",
"master",
"string",
")",
"*",
"IfreqSlave",
"{",
"ifreq",
":=",
"&",
"IfreqSlave",
"{",
"}",
"\n",
"copy",
"(",
"ifreq",
".",
"Name",
"[",
":",
"unix",
".",
"IFNAMSIZ",
"-",
"1",
"]",
",",
"master",
")",... | // newIocltSlaveReq returns filled IfreqSlave with proper interface names
// It is used by ioctl to assign slave to bond master | [
"newIocltSlaveReq",
"returns",
"filled",
"IfreqSlave",
"with",
"proper",
"interface",
"names",
"It",
"is",
"used",
"by",
"ioctl",
"to",
"assign",
"slave",
"to",
"bond",
"master"
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/ioctl_linux.go#L75-L80 |
25,474 | vishvananda/netlink | ioctl_linux.go | newIocltStringSetReq | func newIocltStringSetReq(linkName string) (*Ifreq, *ethtoolSset) {
e := ðtoolSset{
cmd: ETHTOOL_GSSET_INFO,
mask: 1 << ETH_SS_STATS,
}
ifreq := &Ifreq{Data: uintptr(unsafe.Pointer(e))}
copy(ifreq.Name[:unix.IFNAMSIZ-1], linkName)
return ifreq, e
} | go | func newIocltStringSetReq(linkName string) (*Ifreq, *ethtoolSset) {
e := ðtoolSset{
cmd: ETHTOOL_GSSET_INFO,
mask: 1 << ETH_SS_STATS,
}
ifreq := &Ifreq{Data: uintptr(unsafe.Pointer(e))}
copy(ifreq.Name[:unix.IFNAMSIZ-1], linkName)
return ifreq, e
} | [
"func",
"newIocltStringSetReq",
"(",
"linkName",
"string",
")",
"(",
"*",
"Ifreq",
",",
"*",
"ethtoolSset",
")",
"{",
"e",
":=",
"&",
"ethtoolSset",
"{",
"cmd",
":",
"ETHTOOL_GSSET_INFO",
",",
"mask",
":",
"1",
"<<",
"ETH_SS_STATS",
",",
"}",
"\n\n",
"if... | // newIocltStringSetReq creates request to get interface string set | [
"newIocltStringSetReq",
"creates",
"request",
"to",
"get",
"interface",
"string",
"set"
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/ioctl_linux.go#L83-L92 |
25,475 | vishvananda/netlink | addr.go | Equal | func (a Addr) Equal(x Addr) bool {
sizea, _ := a.Mask.Size()
sizeb, _ := x.Mask.Size()
// ignore label for comparison
return a.IP.Equal(x.IP) && sizea == sizeb
} | go | func (a Addr) Equal(x Addr) bool {
sizea, _ := a.Mask.Size()
sizeb, _ := x.Mask.Size()
// ignore label for comparison
return a.IP.Equal(x.IP) && sizea == sizeb
} | [
"func",
"(",
"a",
"Addr",
")",
"Equal",
"(",
"x",
"Addr",
")",
"bool",
"{",
"sizea",
",",
"_",
":=",
"a",
".",
"Mask",
".",
"Size",
"(",
")",
"\n",
"sizeb",
",",
"_",
":=",
"x",
".",
"Mask",
".",
"Size",
"(",
")",
"\n",
"// ignore label for com... | // Equal returns true if both Addrs have the same net.IPNet value. | [
"Equal",
"returns",
"true",
"if",
"both",
"Addrs",
"have",
"the",
"same",
"net",
".",
"IPNet",
"value",
"."
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/addr.go#L44-L49 |
25,476 | vishvananda/netlink | socket_linux.go | SocketGet | func SocketGet(local, remote net.Addr) (*Socket, error) {
localTCP, ok := local.(*net.TCPAddr)
if !ok {
return nil, ErrNotImplemented
}
remoteTCP, ok := remote.(*net.TCPAddr)
if !ok {
return nil, ErrNotImplemented
}
localIP := localTCP.IP.To4()
if localIP == nil {
return nil, ErrNotImplemented
}
remoteI... | go | func SocketGet(local, remote net.Addr) (*Socket, error) {
localTCP, ok := local.(*net.TCPAddr)
if !ok {
return nil, ErrNotImplemented
}
remoteTCP, ok := remote.(*net.TCPAddr)
if !ok {
return nil, ErrNotImplemented
}
localIP := localTCP.IP.To4()
if localIP == nil {
return nil, ErrNotImplemented
}
remoteI... | [
"func",
"SocketGet",
"(",
"local",
",",
"remote",
"net",
".",
"Addr",
")",
"(",
"*",
"Socket",
",",
"error",
")",
"{",
"localTCP",
",",
"ok",
":=",
"local",
".",
"(",
"*",
"net",
".",
"TCPAddr",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
... | // SocketGet returns the Socket identified by its local and remote addresses. | [
"SocketGet",
"returns",
"the",
"Socket",
"identified",
"by",
"its",
"local",
"and",
"remote",
"addresses",
"."
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/socket_linux.go#L108-L159 |
25,477 | vishvananda/netlink | route_linux.go | RouteSubscribe | func RouteSubscribe(ch chan<- RouteUpdate, done <-chan struct{}) error {
return routeSubscribeAt(netns.None(), netns.None(), ch, done, nil, false)
} | go | func RouteSubscribe(ch chan<- RouteUpdate, done <-chan struct{}) error {
return routeSubscribeAt(netns.None(), netns.None(), ch, done, nil, false)
} | [
"func",
"RouteSubscribe",
"(",
"ch",
"chan",
"<-",
"RouteUpdate",
",",
"done",
"<-",
"chan",
"struct",
"{",
"}",
")",
"error",
"{",
"return",
"routeSubscribeAt",
"(",
"netns",
".",
"None",
"(",
")",
",",
"netns",
".",
"None",
"(",
")",
",",
"ch",
","... | // RouteSubscribe takes a chan down which notifications will be sent
// when routes are added or deleted. Close the 'done' chan to stop subscription. | [
"RouteSubscribe",
"takes",
"a",
"chan",
"down",
"which",
"notifications",
"will",
"be",
"sent",
"when",
"routes",
"are",
"added",
"or",
"deleted",
".",
"Close",
"the",
"done",
"chan",
"to",
"stop",
"subscription",
"."
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/route_linux.go#L988-L990 |
25,478 | vishvananda/netlink | route_linux.go | RouteSubscribeWithOptions | func RouteSubscribeWithOptions(ch chan<- RouteUpdate, done <-chan struct{}, options RouteSubscribeOptions) error {
if options.Namespace == nil {
none := netns.None()
options.Namespace = &none
}
return routeSubscribeAt(*options.Namespace, netns.None(), ch, done, options.ErrorCallback, options.ListExisting)
} | go | func RouteSubscribeWithOptions(ch chan<- RouteUpdate, done <-chan struct{}, options RouteSubscribeOptions) error {
if options.Namespace == nil {
none := netns.None()
options.Namespace = &none
}
return routeSubscribeAt(*options.Namespace, netns.None(), ch, done, options.ErrorCallback, options.ListExisting)
} | [
"func",
"RouteSubscribeWithOptions",
"(",
"ch",
"chan",
"<-",
"RouteUpdate",
",",
"done",
"<-",
"chan",
"struct",
"{",
"}",
",",
"options",
"RouteSubscribeOptions",
")",
"error",
"{",
"if",
"options",
".",
"Namespace",
"==",
"nil",
"{",
"none",
":=",
"netns"... | // RouteSubscribeWithOptions work like RouteSubscribe but enable to
// provide additional options to modify the behavior. Currently, the
// namespace can be provided as well as an error callback. | [
"RouteSubscribeWithOptions",
"work",
"like",
"RouteSubscribe",
"but",
"enable",
"to",
"provide",
"additional",
"options",
"to",
"modify",
"the",
"behavior",
".",
"Currently",
"the",
"namespace",
"can",
"be",
"provided",
"as",
"well",
"as",
"an",
"error",
"callback... | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/route_linux.go#L1009-L1015 |
25,479 | vishvananda/netlink | bpf_linux.go | loadSimpleBpf | func loadSimpleBpf(progType BpfProgType, ret uint32) (int, error) {
insns := []uint64{
0x00000000000000b7 | (uint64(ret) << 32),
0x0000000000000095,
}
license := []byte{'A', 'S', 'L', '2', '\x00'}
attr := BPFAttr{
ProgType: uint32(progType),
InsnCnt: uint32(len(insns)),
Insns: uintptr(unsafe.Pointer(&... | go | func loadSimpleBpf(progType BpfProgType, ret uint32) (int, error) {
insns := []uint64{
0x00000000000000b7 | (uint64(ret) << 32),
0x0000000000000095,
}
license := []byte{'A', 'S', 'L', '2', '\x00'}
attr := BPFAttr{
ProgType: uint32(progType),
InsnCnt: uint32(len(insns)),
Insns: uintptr(unsafe.Pointer(&... | [
"func",
"loadSimpleBpf",
"(",
"progType",
"BpfProgType",
",",
"ret",
"uint32",
")",
"(",
"int",
",",
"error",
")",
"{",
"insns",
":=",
"[",
"]",
"uint64",
"{",
"0x00000000000000b7",
"|",
"(",
"uint64",
"(",
"ret",
")",
"<<",
"32",
")",
",",
"0x00000000... | // loadSimpleBpf loads a trivial bpf program for testing purposes. | [
"loadSimpleBpf",
"loads",
"a",
"trivial",
"bpf",
"program",
"for",
"testing",
"purposes",
"."
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/bpf_linux.go#L33-L53 |
25,480 | vishvananda/netlink | rule.go | NewRule | func NewRule() *Rule {
return &Rule{
SuppressIfgroup: -1,
SuppressPrefixlen: -1,
Priority: -1,
Mark: -1,
Mask: -1,
Goto: -1,
Flow: -1,
}
} | go | func NewRule() *Rule {
return &Rule{
SuppressIfgroup: -1,
SuppressPrefixlen: -1,
Priority: -1,
Mark: -1,
Mask: -1,
Goto: -1,
Flow: -1,
}
} | [
"func",
"NewRule",
"(",
")",
"*",
"Rule",
"{",
"return",
"&",
"Rule",
"{",
"SuppressIfgroup",
":",
"-",
"1",
",",
"SuppressPrefixlen",
":",
"-",
"1",
",",
"Priority",
":",
"-",
"1",
",",
"Mark",
":",
"-",
"1",
",",
"Mask",
":",
"-",
"1",
",",
"... | // NewRule return empty rules. | [
"NewRule",
"return",
"empty",
"rules",
"."
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/rule.go#L32-L42 |
25,481 | vishvananda/netlink | qdisc_linux.go | NewNetem | func NewNetem(attrs QdiscAttrs, nattrs NetemQdiscAttrs) *Netem {
var limit uint32 = 1000
var lossCorr, delayCorr, duplicateCorr uint32
var reorderProb, reorderCorr uint32
var corruptProb, corruptCorr uint32
latency := nattrs.Latency
loss := Percentage2u32(nattrs.Loss)
gap := nattrs.Gap
duplicate := Percentage2... | go | func NewNetem(attrs QdiscAttrs, nattrs NetemQdiscAttrs) *Netem {
var limit uint32 = 1000
var lossCorr, delayCorr, duplicateCorr uint32
var reorderProb, reorderCorr uint32
var corruptProb, corruptCorr uint32
latency := nattrs.Latency
loss := Percentage2u32(nattrs.Loss)
gap := nattrs.Gap
duplicate := Percentage2... | [
"func",
"NewNetem",
"(",
"attrs",
"QdiscAttrs",
",",
"nattrs",
"NetemQdiscAttrs",
")",
"*",
"Netem",
"{",
"var",
"limit",
"uint32",
"=",
"1000",
"\n",
"var",
"lossCorr",
",",
"delayCorr",
",",
"duplicateCorr",
"uint32",
"\n",
"var",
"reorderProb",
",",
"reor... | // NOTE function is here because it uses other linux functions | [
"NOTE",
"function",
"is",
"here",
"because",
"it",
"uses",
"other",
"linux",
"functions"
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/qdisc_linux.go#L15-L77 |
25,482 | vishvananda/netlink | handle_linux.go | SupportsNetlinkFamily | func (h *Handle) SupportsNetlinkFamily(nlFamily int) bool {
_, ok := h.sockets[nlFamily]
return ok
} | go | func (h *Handle) SupportsNetlinkFamily(nlFamily int) bool {
_, ok := h.sockets[nlFamily]
return ok
} | [
"func",
"(",
"h",
"*",
"Handle",
")",
"SupportsNetlinkFamily",
"(",
"nlFamily",
"int",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"h",
".",
"sockets",
"[",
"nlFamily",
"]",
"\n",
"return",
"ok",
"\n",
"}"
] | // SupportsNetlinkFamily reports whether the passed netlink family is supported by this Handle | [
"SupportsNetlinkFamily",
"reports",
"whether",
"the",
"passed",
"netlink",
"family",
"is",
"supported",
"by",
"this",
"Handle"
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/handle_linux.go#L25-L28 |
25,483 | vishvananda/netlink | handle_linux.go | NewHandle | func NewHandle(nlFamilies ...int) (*Handle, error) {
return newHandle(netns.None(), netns.None(), nlFamilies...)
} | go | func NewHandle(nlFamilies ...int) (*Handle, error) {
return newHandle(netns.None(), netns.None(), nlFamilies...)
} | [
"func",
"NewHandle",
"(",
"nlFamilies",
"...",
"int",
")",
"(",
"*",
"Handle",
",",
"error",
")",
"{",
"return",
"newHandle",
"(",
"netns",
".",
"None",
"(",
")",
",",
"netns",
".",
"None",
"(",
")",
",",
"nlFamilies",
"...",
")",
"\n",
"}"
] | // NewHandle returns a netlink handle on the current network namespace.
// Caller may specify the netlink families the handle should support.
// If no families are specified, all the families the netlink package
// supports will be automatically added. | [
"NewHandle",
"returns",
"a",
"netlink",
"handle",
"on",
"the",
"current",
"network",
"namespace",
".",
"Caller",
"may",
"specify",
"the",
"netlink",
"families",
"the",
"handle",
"should",
"support",
".",
"If",
"no",
"families",
"are",
"specified",
"all",
"the"... | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/handle_linux.go#L34-L36 |
25,484 | vishvananda/netlink | handle_linux.go | SetSocketTimeout | func (h *Handle) SetSocketTimeout(to time.Duration) error {
if to < time.Microsecond {
return fmt.Errorf("invalid timeout, minimul value is %s", time.Microsecond)
}
tv := unix.NsecToTimeval(to.Nanoseconds())
for _, sh := range h.sockets {
if err := sh.Socket.SetSendTimeout(&tv); err != nil {
return err
}
... | go | func (h *Handle) SetSocketTimeout(to time.Duration) error {
if to < time.Microsecond {
return fmt.Errorf("invalid timeout, minimul value is %s", time.Microsecond)
}
tv := unix.NsecToTimeval(to.Nanoseconds())
for _, sh := range h.sockets {
if err := sh.Socket.SetSendTimeout(&tv); err != nil {
return err
}
... | [
"func",
"(",
"h",
"*",
"Handle",
")",
"SetSocketTimeout",
"(",
"to",
"time",
".",
"Duration",
")",
"error",
"{",
"if",
"to",
"<",
"time",
".",
"Microsecond",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"time",
".",
"Microsecond",
")",
... | // SetSocketTimeout sets the send and receive timeout for each socket in the
// netlink handle. Although the socket timeout has granularity of one
// microsecond, the effective granularity is floored by the kernel timer tick,
// which default value is four milliseconds. | [
"SetSocketTimeout",
"sets",
"the",
"send",
"and",
"receive",
"timeout",
"for",
"each",
"socket",
"in",
"the",
"netlink",
"handle",
".",
"Although",
"the",
"socket",
"timeout",
"has",
"granularity",
"of",
"one",
"microsecond",
"the",
"effective",
"granularity",
"... | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/handle_linux.go#L42-L56 |
25,485 | vishvananda/netlink | handle_linux.go | GetSocketReceiveBufferSize | func (h *Handle) GetSocketReceiveBufferSize() ([]int, error) {
results := make([]int, len(h.sockets))
i := 0
for _, sh := range h.sockets {
fd := sh.Socket.GetFd()
size, err := unix.GetsockoptInt(fd, unix.SOL_SOCKET, unix.SO_RCVBUF)
if err != nil {
return nil, err
}
results[i] = size
i++
}
return re... | go | func (h *Handle) GetSocketReceiveBufferSize() ([]int, error) {
results := make([]int, len(h.sockets))
i := 0
for _, sh := range h.sockets {
fd := sh.Socket.GetFd()
size, err := unix.GetsockoptInt(fd, unix.SOL_SOCKET, unix.SO_RCVBUF)
if err != nil {
return nil, err
}
results[i] = size
i++
}
return re... | [
"func",
"(",
"h",
"*",
"Handle",
")",
"GetSocketReceiveBufferSize",
"(",
")",
"(",
"[",
"]",
"int",
",",
"error",
")",
"{",
"results",
":=",
"make",
"(",
"[",
"]",
"int",
",",
"len",
"(",
"h",
".",
"sockets",
")",
")",
"\n",
"i",
":=",
"0",
"\n... | // GetSocketReceiveBufferSize gets the receiver buffer size for each
// socket in the netlink handle. The retrieved value should be the
// double to the one set for SetSocketReceiveBufferSize. | [
"GetSocketReceiveBufferSize",
"gets",
"the",
"receiver",
"buffer",
"size",
"for",
"each",
"socket",
"in",
"the",
"netlink",
"handle",
".",
"The",
"retrieved",
"value",
"should",
"be",
"the",
"double",
"to",
"the",
"one",
"set",
"for",
"SetSocketReceiveBufferSize",... | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/handle_linux.go#L79-L92 |
25,486 | vishvananda/netlink | handle_linux.go | NewHandleAtFrom | func NewHandleAtFrom(newNs, curNs netns.NsHandle) (*Handle, error) {
return newHandle(newNs, curNs)
} | go | func NewHandleAtFrom(newNs, curNs netns.NsHandle) (*Handle, error) {
return newHandle(newNs, curNs)
} | [
"func",
"NewHandleAtFrom",
"(",
"newNs",
",",
"curNs",
"netns",
".",
"NsHandle",
")",
"(",
"*",
"Handle",
",",
"error",
")",
"{",
"return",
"newHandle",
"(",
"newNs",
",",
"curNs",
")",
"\n",
"}"
] | // NewHandleAtFrom works as NewHandle but allows client to specify the
// new and the origin netns Handle. | [
"NewHandleAtFrom",
"works",
"as",
"NewHandle",
"but",
"allows",
"client",
"to",
"specify",
"the",
"new",
"and",
"the",
"origin",
"netns",
"Handle",
"."
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/handle_linux.go#L103-L105 |
25,487 | vishvananda/netlink | handle_linux.go | Delete | func (h *Handle) Delete() {
for _, sh := range h.sockets {
sh.Close()
}
h.sockets = nil
} | go | func (h *Handle) Delete() {
for _, sh := range h.sockets {
sh.Close()
}
h.sockets = nil
} | [
"func",
"(",
"h",
"*",
"Handle",
")",
"Delete",
"(",
")",
"{",
"for",
"_",
",",
"sh",
":=",
"range",
"h",
".",
"sockets",
"{",
"sh",
".",
"Close",
"(",
")",
"\n",
"}",
"\n",
"h",
".",
"sockets",
"=",
"nil",
"\n",
"}"
] | // Delete releases the resources allocated to this handle | [
"Delete",
"releases",
"the",
"resources",
"allocated",
"to",
"this",
"handle"
] | fd97bf4e47867b5e794234baa6b8a7746135ec10 | https://github.com/vishvananda/netlink/blob/fd97bf4e47867b5e794234baa6b8a7746135ec10/handle_linux.go#L124-L129 |
25,488 | kubernetes-incubator/external-storage | snapshot/pkg/controller/cache/util.go | MakeSnapshotName | func MakeSnapshotName(snapshot *crdv1.VolumeSnapshot) string {
return snapshot.Metadata.Namespace + "/" + snapshot.Metadata.Name + "-" + string(snapshot.Metadata.UID)
} | go | func MakeSnapshotName(snapshot *crdv1.VolumeSnapshot) string {
return snapshot.Metadata.Namespace + "/" + snapshot.Metadata.Name + "-" + string(snapshot.Metadata.UID)
} | [
"func",
"MakeSnapshotName",
"(",
"snapshot",
"*",
"crdv1",
".",
"VolumeSnapshot",
")",
"string",
"{",
"return",
"snapshot",
".",
"Metadata",
".",
"Namespace",
"+",
"\"",
"\"",
"+",
"snapshot",
".",
"Metadata",
".",
"Name",
"+",
"\"",
"\"",
"+",
"string",
... | // MakeSnapshotName makes a full name for a snapshot that includes
// the namespace and the short name | [
"MakeSnapshotName",
"makes",
"a",
"full",
"name",
"for",
"a",
"snapshot",
"that",
"includes",
"the",
"namespace",
"and",
"the",
"short",
"name"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/controller/cache/util.go#L30-L32 |
25,489 | kubernetes-incubator/external-storage | gluster/glusterfs/pkg/volume/config.go | NewProvisionerConfig | func NewProvisionerConfig(pvName string, params map[string]string) (*ProvisionerConfig, error) {
var config ProvisionerConfig
var err error
// Set default volume type
forceCreate := false
volumeType := ""
namespace := "default"
selector := "glusterfs-node==pod"
var brickRootPaths []BrickRootPath
for k, v := ... | go | func NewProvisionerConfig(pvName string, params map[string]string) (*ProvisionerConfig, error) {
var config ProvisionerConfig
var err error
// Set default volume type
forceCreate := false
volumeType := ""
namespace := "default"
selector := "glusterfs-node==pod"
var brickRootPaths []BrickRootPath
for k, v := ... | [
"func",
"NewProvisionerConfig",
"(",
"pvName",
"string",
",",
"params",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"*",
"ProvisionerConfig",
",",
"error",
")",
"{",
"var",
"config",
"ProvisionerConfig",
"\n",
"var",
"err",
"error",
"\n\n",
"// Set default ... | // NewProvisionerConfig create ProvisionerConfig from parameters of StorageClass | [
"NewProvisionerConfig",
"create",
"ProvisionerConfig",
"from",
"parameters",
"of",
"StorageClass"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/gluster/glusterfs/pkg/volume/config.go#L41-L84 |
25,490 | kubernetes-incubator/external-storage | nfs/pkg/volume/export.go | Export | func (e *ganeshaExporter) Export(path string) error {
// Call AddExport using dbus
conn, err := dbus.SystemBus()
if err != nil {
return fmt.Errorf("error getting dbus session bus: %v", err)
}
obj := conn.Object("org.ganesha.nfsd", "/org/ganesha/nfsd/ExportMgr")
call := obj.Call("org.ganesha.nfsd.exportmgr.AddEx... | go | func (e *ganeshaExporter) Export(path string) error {
// Call AddExport using dbus
conn, err := dbus.SystemBus()
if err != nil {
return fmt.Errorf("error getting dbus session bus: %v", err)
}
obj := conn.Object("org.ganesha.nfsd", "/org/ganesha/nfsd/ExportMgr")
call := obj.Call("org.ganesha.nfsd.exportmgr.AddEx... | [
"func",
"(",
"e",
"*",
"ganeshaExporter",
")",
"Export",
"(",
"path",
"string",
")",
"error",
"{",
"// Call AddExport using dbus",
"conn",
",",
"err",
":=",
"dbus",
".",
"SystemBus",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
... | // Export exports the given directory using NFS Ganesha, assuming it is running
// and can be connected to using D-Bus. | [
"Export",
"exports",
"the",
"given",
"directory",
"using",
"NFS",
"Ganesha",
"assuming",
"it",
"is",
"running",
"and",
"can",
"be",
"connected",
"to",
"using",
"D",
"-",
"Bus",
"."
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/nfs/pkg/volume/export.go#L123-L136 |
25,491 | kubernetes-incubator/external-storage | snapshot/pkg/controller/reconciler/reconciler.go | NewReconciler | func NewReconciler(
loopPeriod time.Duration,
syncDuration time.Duration,
disableReconciliationSync bool,
desiredStateOfWorld cache.DesiredStateOfWorld,
actualStateOfWorld cache.ActualStateOfWorld,
snapshotter snapshotter.VolumeSnapshotter) Reconciler {
return &reconciler{
loopPeriod: loopPeriod... | go | func NewReconciler(
loopPeriod time.Duration,
syncDuration time.Duration,
disableReconciliationSync bool,
desiredStateOfWorld cache.DesiredStateOfWorld,
actualStateOfWorld cache.ActualStateOfWorld,
snapshotter snapshotter.VolumeSnapshotter) Reconciler {
return &reconciler{
loopPeriod: loopPeriod... | [
"func",
"NewReconciler",
"(",
"loopPeriod",
"time",
".",
"Duration",
",",
"syncDuration",
"time",
".",
"Duration",
",",
"disableReconciliationSync",
"bool",
",",
"desiredStateOfWorld",
"cache",
".",
"DesiredStateOfWorld",
",",
"actualStateOfWorld",
"cache",
".",
"Actu... | // NewReconciler is the constructor of Reconciler | [
"NewReconciler",
"is",
"the",
"constructor",
"of",
"Reconciler"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/controller/reconciler/reconciler.go#L52-L68 |
25,492 | kubernetes-incubator/external-storage | snapshot/pkg/cloudprovider/providers/aws/retry_handler.go | AfterRetry | func (c *CrossRequestRetryDelay) AfterRetry(r *request.Request) {
if r.Error == nil {
return
}
awsError, ok := r.Error.(awserr.Error)
if !ok {
return
}
if awsError.Code() == "RequestLimitExceeded" {
c.backoff.ReportError()
glog.Warningf("Got RequestLimitExceeded error on AWS request (%s)",
describeRequ... | go | func (c *CrossRequestRetryDelay) AfterRetry(r *request.Request) {
if r.Error == nil {
return
}
awsError, ok := r.Error.(awserr.Error)
if !ok {
return
}
if awsError.Code() == "RequestLimitExceeded" {
c.backoff.ReportError()
glog.Warningf("Got RequestLimitExceeded error on AWS request (%s)",
describeRequ... | [
"func",
"(",
"c",
"*",
"CrossRequestRetryDelay",
")",
"AfterRetry",
"(",
"r",
"*",
"request",
".",
"Request",
")",
"{",
"if",
"r",
".",
"Error",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"awsError",
",",
"ok",
":=",
"r",
".",
"Error",
".",
"(",
... | // AfterRetry is added to the AfterRetry chain; called after any error | [
"AfterRetry",
"is",
"added",
"to",
"the",
"AfterRetry",
"chain",
";",
"called",
"after",
"any",
"error"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/aws/retry_handler.go#L76-L89 |
25,493 | kubernetes-incubator/external-storage | snapshot/pkg/volume/cinder/processor.go | Init | func (c *cinderPlugin) Init(cloud cloudprovider.Interface) {
c.cloud = cloud.(*openstack.OpenStack)
} | go | func (c *cinderPlugin) Init(cloud cloudprovider.Interface) {
c.cloud = cloud.(*openstack.OpenStack)
} | [
"func",
"(",
"c",
"*",
"cinderPlugin",
")",
"Init",
"(",
"cloud",
"cloudprovider",
".",
"Interface",
")",
"{",
"c",
".",
"cloud",
"=",
"cloud",
".",
"(",
"*",
"openstack",
".",
"OpenStack",
")",
"\n",
"}"
] | // Init inits volume plugin | [
"Init",
"inits",
"volume",
"plugin"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/volume/cinder/processor.go#L43-L45 |
25,494 | kubernetes-incubator/external-storage | snapshot/pkg/volume/cinder/processor.go | VolumeDelete | func (c *cinderPlugin) VolumeDelete(pv *v1.PersistentVolume) error {
if pv == nil || pv.Spec.Cinder == nil {
return fmt.Errorf("invalid Cinder PV: %v", pv)
}
volumeID := pv.Spec.Cinder.VolumeID
err := c.cloud.DeleteVolume(volumeID)
if err != nil {
return err
}
return nil
} | go | func (c *cinderPlugin) VolumeDelete(pv *v1.PersistentVolume) error {
if pv == nil || pv.Spec.Cinder == nil {
return fmt.Errorf("invalid Cinder PV: %v", pv)
}
volumeID := pv.Spec.Cinder.VolumeID
err := c.cloud.DeleteVolume(volumeID)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"c",
"*",
"cinderPlugin",
")",
"VolumeDelete",
"(",
"pv",
"*",
"v1",
".",
"PersistentVolume",
")",
"error",
"{",
"if",
"pv",
"==",
"nil",
"||",
"pv",
".",
"Spec",
".",
"Cinder",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\... | // VolumeDelete deletes the specified volume passed on pv | [
"VolumeDelete",
"deletes",
"the",
"specified",
"volume",
"passed",
"on",
"pv"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/volume/cinder/processor.go#L58-L69 |
25,495 | kubernetes-incubator/external-storage | snapshot/pkg/volume/cinder/processor.go | SnapshotCreate | func (c *cinderPlugin) SnapshotCreate(
snapshot *crdv1.VolumeSnapshot,
pv *v1.PersistentVolume,
tags *map[string]string,
) (*crdv1.VolumeSnapshotDataSource, *[]crdv1.VolumeSnapshotCondition, error) {
spec := &pv.Spec
if spec == nil || spec.Cinder == nil {
return nil, nil, fmt.Errorf("invalid PV spec %v", spec)
... | go | func (c *cinderPlugin) SnapshotCreate(
snapshot *crdv1.VolumeSnapshot,
pv *v1.PersistentVolume,
tags *map[string]string,
) (*crdv1.VolumeSnapshotDataSource, *[]crdv1.VolumeSnapshotCondition, error) {
spec := &pv.Spec
if spec == nil || spec.Cinder == nil {
return nil, nil, fmt.Errorf("invalid PV spec %v", spec)
... | [
"func",
"(",
"c",
"*",
"cinderPlugin",
")",
"SnapshotCreate",
"(",
"snapshot",
"*",
"crdv1",
".",
"VolumeSnapshot",
",",
"pv",
"*",
"v1",
".",
"PersistentVolume",
",",
"tags",
"*",
"map",
"[",
"string",
"]",
"string",
",",
")",
"(",
"*",
"crdv1",
".",
... | // SnapshotCreate creates a VolumeSnapshot from a PersistentVolumeSpec | [
"SnapshotCreate",
"creates",
"a",
"VolumeSnapshot",
"from",
"a",
"PersistentVolumeSpec"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/volume/cinder/processor.go#L72-L95 |
25,496 | kubernetes-incubator/external-storage | snapshot/pkg/volume/cinder/processor.go | SnapshotDelete | func (c *cinderPlugin) SnapshotDelete(src *crdv1.VolumeSnapshotDataSource, _ *v1.PersistentVolume) error {
if src == nil || src.CinderSnapshot == nil {
return fmt.Errorf("invalid VolumeSnapshotDataSource: %v", src)
}
snapshotID := src.CinderSnapshot.SnapshotID
err := c.cloud.DeleteSnapshot(snapshotID)
if err != ... | go | func (c *cinderPlugin) SnapshotDelete(src *crdv1.VolumeSnapshotDataSource, _ *v1.PersistentVolume) error {
if src == nil || src.CinderSnapshot == nil {
return fmt.Errorf("invalid VolumeSnapshotDataSource: %v", src)
}
snapshotID := src.CinderSnapshot.SnapshotID
err := c.cloud.DeleteSnapshot(snapshotID)
if err != ... | [
"func",
"(",
"c",
"*",
"cinderPlugin",
")",
"SnapshotDelete",
"(",
"src",
"*",
"crdv1",
".",
"VolumeSnapshotDataSource",
",",
"_",
"*",
"v1",
".",
"PersistentVolume",
")",
"error",
"{",
"if",
"src",
"==",
"nil",
"||",
"src",
".",
"CinderSnapshot",
"==",
... | // SnapshotDelete deletes a VolumeSnapshot
// PersistentVolume is provided for volume types, if any, that need PV Spec to delete snapshot | [
"SnapshotDelete",
"deletes",
"a",
"VolumeSnapshot",
"PersistentVolume",
"is",
"provided",
"for",
"volume",
"types",
"if",
"any",
"that",
"need",
"PV",
"Spec",
"to",
"delete",
"snapshot"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/volume/cinder/processor.go#L99-L109 |
25,497 | kubernetes-incubator/external-storage | snapshot/pkg/volume/cinder/processor.go | SnapshotRestore | func (c *cinderPlugin) SnapshotRestore(snapshotData *crdv1.VolumeSnapshotData, pvc *v1.PersistentVolumeClaim, pvName string, parameters map[string]string) (*v1.PersistentVolumeSource, map[string]string, error) {
var tags = make(map[string]string)
var vType string
var zone string
if snapshotData == nil || snapshotD... | go | func (c *cinderPlugin) SnapshotRestore(snapshotData *crdv1.VolumeSnapshotData, pvc *v1.PersistentVolumeClaim, pvName string, parameters map[string]string) (*v1.PersistentVolumeSource, map[string]string, error) {
var tags = make(map[string]string)
var vType string
var zone string
if snapshotData == nil || snapshotD... | [
"func",
"(",
"c",
"*",
"cinderPlugin",
")",
"SnapshotRestore",
"(",
"snapshotData",
"*",
"crdv1",
".",
"VolumeSnapshotData",
",",
"pvc",
"*",
"v1",
".",
"PersistentVolumeClaim",
",",
"pvName",
"string",
",",
"parameters",
"map",
"[",
"string",
"]",
"string",
... | // SnapshotRestore creates a new Volume using the data on the specified Snapshot | [
"SnapshotRestore",
"creates",
"a",
"new",
"Volume",
"using",
"the",
"data",
"on",
"the",
"specified",
"Snapshot"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/volume/cinder/processor.go#L112-L155 |
25,498 | kubernetes-incubator/external-storage | snapshot/pkg/volume/cinder/processor.go | DescribeSnapshot | func (c *cinderPlugin) DescribeSnapshot(snapshotData *crdv1.VolumeSnapshotData) (*[]crdv1.VolumeSnapshotCondition, bool, error) {
if snapshotData == nil || snapshotData.Spec.CinderSnapshot == nil {
return nil, false, fmt.Errorf("invalid VolumeSnapshotDataSource: %v", snapshotData)
}
snapshotID := snapshotData.Spec... | go | func (c *cinderPlugin) DescribeSnapshot(snapshotData *crdv1.VolumeSnapshotData) (*[]crdv1.VolumeSnapshotCondition, bool, error) {
if snapshotData == nil || snapshotData.Spec.CinderSnapshot == nil {
return nil, false, fmt.Errorf("invalid VolumeSnapshotDataSource: %v", snapshotData)
}
snapshotID := snapshotData.Spec... | [
"func",
"(",
"c",
"*",
"cinderPlugin",
")",
"DescribeSnapshot",
"(",
"snapshotData",
"*",
"crdv1",
".",
"VolumeSnapshotData",
")",
"(",
"*",
"[",
"]",
"crdv1",
".",
"VolumeSnapshotCondition",
",",
"bool",
",",
"error",
")",
"{",
"if",
"snapshotData",
"==",
... | // DescribeSnapshot retrieves info for the specified Snapshot | [
"DescribeSnapshot",
"retrieves",
"info",
"for",
"the",
"specified",
"Snapshot"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/volume/cinder/processor.go#L158-L169 |
25,499 | kubernetes-incubator/external-storage | snapshot/pkg/volume/cinder/processor.go | convertSnapshotStatus | func (c *cinderPlugin) convertSnapshotStatus(status string) *[]crdv1.VolumeSnapshotCondition {
var snapConditions []crdv1.VolumeSnapshotCondition
if status == "available" {
snapConditions = []crdv1.VolumeSnapshotCondition{
{
Type: crdv1.VolumeSnapshotConditionReady,
Status: v1.C... | go | func (c *cinderPlugin) convertSnapshotStatus(status string) *[]crdv1.VolumeSnapshotCondition {
var snapConditions []crdv1.VolumeSnapshotCondition
if status == "available" {
snapConditions = []crdv1.VolumeSnapshotCondition{
{
Type: crdv1.VolumeSnapshotConditionReady,
Status: v1.C... | [
"func",
"(",
"c",
"*",
"cinderPlugin",
")",
"convertSnapshotStatus",
"(",
"status",
"string",
")",
"*",
"[",
"]",
"crdv1",
".",
"VolumeSnapshotCondition",
"{",
"var",
"snapConditions",
"[",
"]",
"crdv1",
".",
"VolumeSnapshotCondition",
"\n",
"if",
"status",
"=... | // convertSnapshotStatus converts Cinder snapshot status to crdv1.VolumeSnapshotCondition | [
"convertSnapshotStatus",
"converts",
"Cinder",
"snapshot",
"status",
"to",
"crdv1",
".",
"VolumeSnapshotCondition"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/volume/cinder/processor.go#L172-L204 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.