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
134,600
DavidBelicza/TextRank
convert/language.go
NewLanguage
func NewLanguage() *LanguageDefault { lang := &LanguageDefault{ "en", make(map[string][]string), } words := getDefaultEnglish() lang.SetWords("en", words) return lang }
go
func NewLanguage() *LanguageDefault { lang := &LanguageDefault{ "en", make(map[string][]string), } words := getDefaultEnglish() lang.SetWords("en", words) return lang }
[ "func", "NewLanguage", "(", ")", "*", "LanguageDefault", "{", "lang", ":=", "&", "LanguageDefault", "{", "\"", "\"", ",", "make", "(", "map", "[", "string", "]", "[", "]", "string", ")", ",", "}", "\n\n", "words", ":=", "getDefaultEnglish", "(", ")", ...
// NewLanguage constructor of the LanguageDefault Retrieves a pointer // LanguageDefault. It has setup to English by default.
[ "NewLanguage", "constructor", "of", "the", "LanguageDefault", "Retrieves", "a", "pointer", "LanguageDefault", ".", "It", "has", "setup", "to", "English", "by", "default", "." ]
79e14bab980af3a1c9f4f5b73672ae1ef18ab732
https://github.com/DavidBelicza/TextRank/blob/79e14bab980af3a1c9f4f5b73672ae1ef18ab732/convert/language.go#L23-L34
134,601
DavidBelicza/TextRank
convert/language.go
IsStopWord
func (lang *LanguageDefault) IsStopWord(word string) bool { if utf8.RuneCountInString(word) <= 2 { return true } if stopWords, ok := lang.languages[lang.defaultLang]; ok { for _, val := range stopWords { if val == word { return true } } } return false }
go
func (lang *LanguageDefault) IsStopWord(word string) bool { if utf8.RuneCountInString(word) <= 2 { return true } if stopWords, ok := lang.languages[lang.defaultLang]; ok { for _, val := range stopWords { if val == word { return true } } } return false }
[ "func", "(", "lang", "*", "LanguageDefault", ")", "IsStopWord", "(", "word", "string", ")", "bool", "{", "if", "utf8", ".", "RuneCountInString", "(", "word", ")", "<=", "2", "{", "return", "true", "\n", "}", "\n\n", "if", "stopWords", ",", "ok", ":=", ...
// IsStopWord method retrieves true when the given word is in the stop word // list or when the word has less character then 2.
[ "IsStopWord", "method", "retrieves", "true", "when", "the", "given", "word", "is", "in", "the", "stop", "word", "list", "or", "when", "the", "word", "has", "less", "character", "then", "2", "." ]
79e14bab980af3a1c9f4f5b73672ae1ef18ab732
https://github.com/DavidBelicza/TextRank/blob/79e14bab980af3a1c9f4f5b73672ae1ef18ab732/convert/language.go#L38-L52
134,602
DavidBelicza/TextRank
convert/language.go
SetWords
func (lang *LanguageDefault) SetWords(code string, words []string) { lang.languages[code] = words }
go
func (lang *LanguageDefault) SetWords(code string, words []string) { lang.languages[code] = words }
[ "func", "(", "lang", "*", "LanguageDefault", ")", "SetWords", "(", "code", "string", ",", "words", "[", "]", "string", ")", "{", "lang", ".", "languages", "[", "code", "]", "=", "words", "\n", "}" ]
// SetWords method set stop words into the LanguageDefault struct by the // language's code.
[ "SetWords", "method", "set", "stop", "words", "into", "the", "LanguageDefault", "struct", "by", "the", "language", "s", "code", "." ]
79e14bab980af3a1c9f4f5b73672ae1ef18ab732
https://github.com/DavidBelicza/TextRank/blob/79e14bab980af3a1c9f4f5b73672ae1ef18ab732/convert/language.go#L69-L71
134,603
DavidBelicza/TextRank
rank/rank.go
NewRank
func NewRank() *Rank { return &Rank{ 0, 0, Relation{ 0, 0, make(map[int]map[int]Score), }, make(map[int]string), make(map[int]*Word), make(map[string]int), } }
go
func NewRank() *Rank { return &Rank{ 0, 0, Relation{ 0, 0, make(map[int]map[int]Score), }, make(map[int]string), make(map[int]*Word), make(map[string]int), } }
[ "func", "NewRank", "(", ")", "*", "Rank", "{", "return", "&", "Rank", "{", "0", ",", "0", ",", "Relation", "{", "0", ",", "0", ",", "make", "(", "map", "[", "int", "]", "map", "[", "int", "]", "Score", ")", ",", "}", ",", "make", "(", "map"...
// NewRank constructor retrieves a Rank pointer.
[ "NewRank", "constructor", "retrieves", "a", "Rank", "pointer", "." ]
79e14bab980af3a1c9f4f5b73672ae1ef18ab732
https://github.com/DavidBelicza/TextRank/blob/79e14bab980af3a1c9f4f5b73672ae1ef18ab732/rank/rank.go#L59-L72
134,604
DavidBelicza/TextRank
rank/rank.go
IsWordExist
func (rank *Rank) IsWordExist(word string) bool { _, find := rank.WordValID[word] return find }
go
func (rank *Rank) IsWordExist(word string) bool { _, find := rank.WordValID[word] return find }
[ "func", "(", "rank", "*", "Rank", ")", "IsWordExist", "(", "word", "string", ")", "bool", "{", "_", ",", "find", ":=", "rank", ".", "WordValID", "[", "word", "]", "\n\n", "return", "find", "\n", "}" ]
// IsWordExist method retrieves true when the given word is already in the rank.
[ "IsWordExist", "method", "retrieves", "true", "when", "the", "given", "word", "is", "already", "in", "the", "rank", "." ]
79e14bab980af3a1c9f4f5b73672ae1ef18ab732
https://github.com/DavidBelicza/TextRank/blob/79e14bab980af3a1c9f4f5b73672ae1ef18ab732/rank/rank.go#L75-L79
134,605
DavidBelicza/TextRank
rank/rank.go
AddNewWord
func (rank *Rank) AddNewWord(word string, prevWordIdx int, sentenceID int) (wordID int) { wordID = len(rank.Words) connectionLeft := make(map[int]int) if prevWordIdx >= 0 { connectionLeft[prevWordIdx] = 1 } newWord := &Word{ ID: wordID, SentenceIDs: []int{sentenceID}, ConnectionLeft: co...
go
func (rank *Rank) AddNewWord(word string, prevWordIdx int, sentenceID int) (wordID int) { wordID = len(rank.Words) connectionLeft := make(map[int]int) if prevWordIdx >= 0 { connectionLeft[prevWordIdx] = 1 } newWord := &Word{ ID: wordID, SentenceIDs: []int{sentenceID}, ConnectionLeft: co...
[ "func", "(", "rank", "*", "Rank", ")", "AddNewWord", "(", "word", "string", ",", "prevWordIdx", "int", ",", "sentenceID", "int", ")", "(", "wordID", "int", ")", "{", "wordID", "=", "len", "(", "rank", ".", "Words", ")", "\n", "connectionLeft", ":=", ...
// AddNewWord method adds a new word to the rank object and it defines its ID.
[ "AddNewWord", "method", "adds", "a", "new", "word", "to", "the", "rank", "object", "and", "it", "defines", "its", "ID", "." ]
79e14bab980af3a1c9f4f5b73672ae1ef18ab732
https://github.com/DavidBelicza/TextRank/blob/79e14bab980af3a1c9f4f5b73672ae1ef18ab732/rank/rank.go#L82-L104
134,606
DavidBelicza/TextRank
rank/rank.go
UpdateWord
func (rank *Rank) UpdateWord(word string, prevWordIdx int, sentenceID int) (wordID int) { wordID = rank.WordValID[word] found := false for _, oldSentenceID := range rank.Words[wordID].SentenceIDs { if sentenceID == oldSentenceID { found = true break } } if !found { rank.Words[wordID].SentenceIDs = a...
go
func (rank *Rank) UpdateWord(word string, prevWordIdx int, sentenceID int) (wordID int) { wordID = rank.WordValID[word] found := false for _, oldSentenceID := range rank.Words[wordID].SentenceIDs { if sentenceID == oldSentenceID { found = true break } } if !found { rank.Words[wordID].SentenceIDs = a...
[ "func", "(", "rank", "*", "Rank", ")", "UpdateWord", "(", "word", "string", ",", "prevWordIdx", "int", ",", "sentenceID", "int", ")", "(", "wordID", "int", ")", "{", "wordID", "=", "rank", ".", "WordValID", "[", "word", "]", "\n\n", "found", ":=", "f...
// UpdateWord method update a word what already exists in the rank object. It // retrieves its ID.
[ "UpdateWord", "method", "update", "a", "word", "what", "already", "exists", "in", "the", "rank", "object", ".", "It", "retrieves", "its", "ID", "." ]
79e14bab980af3a1c9f4f5b73672ae1ef18ab732
https://github.com/DavidBelicza/TextRank/blob/79e14bab980af3a1c9f4f5b73672ae1ef18ab732/rank/rank.go#L108-L134
134,607
DavidBelicza/TextRank
rank/rank.go
UpdateRightConnection
func (rank *Rank) UpdateRightConnection(wordID int, rightWordID int) { if wordID >= 0 { rank.Words[wordID].ConnectionRight[rightWordID]++ } }
go
func (rank *Rank) UpdateRightConnection(wordID int, rightWordID int) { if wordID >= 0 { rank.Words[wordID].ConnectionRight[rightWordID]++ } }
[ "func", "(", "rank", "*", "Rank", ")", "UpdateRightConnection", "(", "wordID", "int", ",", "rightWordID", "int", ")", "{", "if", "wordID", ">=", "0", "{", "rank", ".", "Words", "[", "wordID", "]", ".", "ConnectionRight", "[", "rightWordID", "]", "++", ...
// UpdateRightConnection method adds the right connection to the word. It always // can be used after a word has added and the next word is known.
[ "UpdateRightConnection", "method", "adds", "the", "right", "connection", "to", "the", "word", ".", "It", "always", "can", "be", "used", "after", "a", "word", "has", "added", "and", "the", "next", "word", "is", "known", "." ]
79e14bab980af3a1c9f4f5b73672ae1ef18ab732
https://github.com/DavidBelicza/TextRank/blob/79e14bab980af3a1c9f4f5b73672ae1ef18ab732/rank/rank.go#L138-L142
134,608
FDio/govpp
core/request_handler.go
watchRequests
func (c *Connection) watchRequests(ch *Channel) { for { select { case req, ok := <-ch.reqChan: // new request on the request channel if !ok { // after closing the request channel, release API channel and return c.releaseAPIChannel(ch) return } if err := c.processRequest(ch, req); err != nil...
go
func (c *Connection) watchRequests(ch *Channel) { for { select { case req, ok := <-ch.reqChan: // new request on the request channel if !ok { // after closing the request channel, release API channel and return c.releaseAPIChannel(ch) return } if err := c.processRequest(ch, req); err != nil...
[ "func", "(", "c", "*", "Connection", ")", "watchRequests", "(", "ch", "*", "Channel", ")", "{", "for", "{", "select", "{", "case", "req", ",", "ok", ":=", "<-", "ch", ".", "reqChan", ":", "// new request on the request channel", "if", "!", "ok", "{", "...
// watchRequests watches for requests on the request API channel and forwards them as messages to VPP.
[ "watchRequests", "watches", "for", "requests", "on", "the", "request", "API", "channel", "and", "forwards", "them", "as", "messages", "to", "VPP", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/core/request_handler.go#L34-L49
134,609
FDio/govpp
core/request_handler.go
processRequest
func (c *Connection) processRequest(ch *Channel, req *vppRequest) error { // check whether we are connected to VPP if atomic.LoadUint32(&c.vppConnected) == 0 { err := ErrNotConnected log.Errorf("processing request failed: %v", err) return err } // retrieve message ID msgID, err := c.GetMessageID(req.msg) i...
go
func (c *Connection) processRequest(ch *Channel, req *vppRequest) error { // check whether we are connected to VPP if atomic.LoadUint32(&c.vppConnected) == 0 { err := ErrNotConnected log.Errorf("processing request failed: %v", err) return err } // retrieve message ID msgID, err := c.GetMessageID(req.msg) i...
[ "func", "(", "c", "*", "Connection", ")", "processRequest", "(", "ch", "*", "Channel", ",", "req", "*", "vppRequest", ")", "error", "{", "// check whether we are connected to VPP", "if", "atomic", ".", "LoadUint32", "(", "&", "c", ".", "vppConnected", ")", "...
// processRequest processes a single request received on the request channel.
[ "processRequest", "processes", "a", "single", "request", "received", "on", "the", "request", "channel", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/core/request_handler.go#L52-L133
134,610
FDio/govpp
core/request_handler.go
msgCallback
func (c *Connection) msgCallback(msgID uint16, data []byte) { if c == nil { log.Warn("Already disconnected, ignoring the message.") return } msg, ok := c.msgMap[msgID] if !ok { log.Warnf("Unknown message received, ID: %d", msgID) return } // decode message context to fix for special cases of messages, ...
go
func (c *Connection) msgCallback(msgID uint16, data []byte) { if c == nil { log.Warn("Already disconnected, ignoring the message.") return } msg, ok := c.msgMap[msgID] if !ok { log.Warnf("Unknown message received, ID: %d", msgID) return } // decode message context to fix for special cases of messages, ...
[ "func", "(", "c", "*", "Connection", ")", "msgCallback", "(", "msgID", "uint16", ",", "data", "[", "]", "byte", ")", "{", "if", "c", "==", "nil", "{", "log", ".", "Warn", "(", "\"", "\"", ")", "\n", "return", "\n", "}", "\n\n", "msg", ",", "ok"...
// msgCallback is called whenever any binary API message comes from VPP.
[ "msgCallback", "is", "called", "whenever", "any", "binary", "API", "message", "comes", "from", "VPP", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/core/request_handler.go#L136-L206
134,611
FDio/govpp
core/request_handler.go
sendReply
func sendReply(ch *Channel, reply *vppReply) { select { case ch.replyChan <- reply: // reply sent successfully case <-time.After(ReplyChannelTimeout): // receiver still not ready log.WithFields(logger.Fields{ "channel": ch, "msg_id": reply.msgID, "seq_num": reply.seqNum, }).Warn("Unable to send the...
go
func sendReply(ch *Channel, reply *vppReply) { select { case ch.replyChan <- reply: // reply sent successfully case <-time.After(ReplyChannelTimeout): // receiver still not ready log.WithFields(logger.Fields{ "channel": ch, "msg_id": reply.msgID, "seq_num": reply.seqNum, }).Warn("Unable to send the...
[ "func", "sendReply", "(", "ch", "*", "Channel", ",", "reply", "*", "vppReply", ")", "{", "select", "{", "case", "ch", ".", "replyChan", "<-", "reply", ":", "// reply sent successfully", "case", "<-", "time", ".", "After", "(", "ReplyChannelTimeout", ")", "...
// sendReply sends the reply into the go channel, if it cannot be completed without blocking, otherwise // it logs the error and do not send the message.
[ "sendReply", "sends", "the", "reply", "into", "the", "go", "channel", "if", "it", "cannot", "be", "completed", "without", "blocking", "otherwise", "it", "logs", "the", "error", "and", "do", "not", "send", "the", "message", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/core/request_handler.go#L210-L222
134,612
FDio/govpp
core/request_handler.go
isNotificationMessage
func (c *Connection) isNotificationMessage(msgID uint16) bool { c.subscriptionsLock.RLock() defer c.subscriptionsLock.RUnlock() _, exists := c.subscriptions[msgID] return exists }
go
func (c *Connection) isNotificationMessage(msgID uint16) bool { c.subscriptionsLock.RLock() defer c.subscriptionsLock.RUnlock() _, exists := c.subscriptions[msgID] return exists }
[ "func", "(", "c", "*", "Connection", ")", "isNotificationMessage", "(", "msgID", "uint16", ")", "bool", "{", "c", ".", "subscriptionsLock", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "subscriptionsLock", ".", "RUnlock", "(", ")", "\n\n", "_", ",", ...
// isNotificationMessage returns true if someone has subscribed to provided message ID.
[ "isNotificationMessage", "returns", "true", "if", "someone", "has", "subscribed", "to", "provided", "message", "ID", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/core/request_handler.go#L229-L235
134,613
FDio/govpp
core/request_handler.go
sendNotifications
func (c *Connection) sendNotifications(msgID uint16, data []byte) { c.subscriptionsLock.RLock() defer c.subscriptionsLock.RUnlock() matched := false // send to notification to each subscriber for _, sub := range c.subscriptions[msgID] { log.WithFields(logger.Fields{ "msg_name": sub.event.GetMessageName(), ...
go
func (c *Connection) sendNotifications(msgID uint16, data []byte) { c.subscriptionsLock.RLock() defer c.subscriptionsLock.RUnlock() matched := false // send to notification to each subscriber for _, sub := range c.subscriptions[msgID] { log.WithFields(logger.Fields{ "msg_name": sub.event.GetMessageName(), ...
[ "func", "(", "c", "*", "Connection", ")", "sendNotifications", "(", "msgID", "uint16", ",", "data", "[", "]", "byte", ")", "{", "c", ".", "subscriptionsLock", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "subscriptionsLock", ".", "RUnlock", "(", ")...
// sendNotifications send a notification message to all subscribers subscribed for that message.
[ "sendNotifications", "send", "a", "notification", "message", "to", "all", "subscribers", "subscribed", "for", "that", "message", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/core/request_handler.go#L238-L284
134,614
FDio/govpp
extras/libmemif/packethandle.go
NewPacketHandle
func (memif *Memif) NewPacketHandle(queueId uint8, rxCount uint16) *MemifPacketHandle { if rxCount == 0 { rxCount = 1 } return &MemifPacketHandle{ memif: memif, queueId: queueId, rxCount: rxCount, } }
go
func (memif *Memif) NewPacketHandle(queueId uint8, rxCount uint16) *MemifPacketHandle { if rxCount == 0 { rxCount = 1 } return &MemifPacketHandle{ memif: memif, queueId: queueId, rxCount: rxCount, } }
[ "func", "(", "memif", "*", "Memif", ")", "NewPacketHandle", "(", "queueId", "uint8", ",", "rxCount", "uint16", ")", "*", "MemifPacketHandle", "{", "if", "rxCount", "==", "0", "{", "rxCount", "=", "1", "\n", "}", "\n\n", "return", "&", "MemifPacketHandle", ...
// Create new GoPacket packet handle from libmemif queue. rxCount determines how many packets will be read // at once, minimum value is 1
[ "Create", "new", "GoPacket", "packet", "handle", "from", "libmemif", "queue", ".", "rxCount", "determines", "how", "many", "packets", "will", "be", "read", "at", "once", "minimum", "value", "is", "1" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/extras/libmemif/packethandle.go#L46-L56
134,615
FDio/govpp
extras/libmemif/packethandle.go
ReadPacketData
func (handle *MemifPacketHandle) ReadPacketData() (data []byte, ci gopacket.CaptureInfo, err error) { handle.readMu.Lock() defer handle.readMu.Unlock() if handle.stop { err = io.EOF return } queueLen := len(handle.packetQueue) if queueLen == 0 { packets, burstErr := handle.memif.RxBurst(handle.queueId, h...
go
func (handle *MemifPacketHandle) ReadPacketData() (data []byte, ci gopacket.CaptureInfo, err error) { handle.readMu.Lock() defer handle.readMu.Unlock() if handle.stop { err = io.EOF return } queueLen := len(handle.packetQueue) if queueLen == 0 { packets, burstErr := handle.memif.RxBurst(handle.queueId, h...
[ "func", "(", "handle", "*", "MemifPacketHandle", ")", "ReadPacketData", "(", ")", "(", "data", "[", "]", "byte", ",", "ci", "gopacket", ".", "CaptureInfo", ",", "err", "error", ")", "{", "handle", ".", "readMu", ".", "Lock", "(", ")", "\n", "defer", ...
// Reads packet data from memif in bursts, based on previously configured rxCount parameterer. Then caches the // resulting packets and returns them 1 by 1 from this method until queue is empty then tries to call new rx burst // to read more data. If no data is returned, io.EOF error is thrown and caller should stop re...
[ "Reads", "packet", "data", "from", "memif", "in", "bursts", "based", "on", "previously", "configured", "rxCount", "parameterer", ".", "Then", "caches", "the", "resulting", "packets", "and", "returns", "them", "1", "by", "1", "from", "this", "method", "until", ...
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/extras/libmemif/packethandle.go#L61-L108
134,616
FDio/govpp
extras/libmemif/packethandle.go
WritePacketData
func (handle *MemifPacketHandle) WritePacketData(data []byte) (err error) { handle.writeMu.Lock() defer handle.writeMu.Unlock() if handle.stop { err = io.EOF return } count, err := handle.memif.TxBurst(handle.queueId, []RawPacketData{data}) if err != nil { return } if count == 0 { err = io.EOF } ...
go
func (handle *MemifPacketHandle) WritePacketData(data []byte) (err error) { handle.writeMu.Lock() defer handle.writeMu.Unlock() if handle.stop { err = io.EOF return } count, err := handle.memif.TxBurst(handle.queueId, []RawPacketData{data}) if err != nil { return } if count == 0 { err = io.EOF } ...
[ "func", "(", "handle", "*", "MemifPacketHandle", ")", "WritePacketData", "(", "data", "[", "]", "byte", ")", "(", "err", "error", ")", "{", "handle", ".", "writeMu", ".", "Lock", "(", ")", "\n", "defer", "handle", ".", "writeMu", ".", "Unlock", "(", ...
// Writes packet data to memif in burst of 1 packet. In case no packet is sent, this method throws io.EOF error and // called should stop trying to write packets.
[ "Writes", "packet", "data", "to", "memif", "in", "burst", "of", "1", "packet", ".", "In", "case", "no", "packet", "is", "sent", "this", "method", "throws", "io", ".", "EOF", "error", "and", "called", "should", "stop", "trying", "to", "write", "packets", ...
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/extras/libmemif/packethandle.go#L112-L132
134,617
FDio/govpp
extras/libmemif/packethandle.go
Close
func (handle *MemifPacketHandle) Close() { handle.closeMu.Lock() defer handle.closeMu.Unlock() // wait for packet reader to stop handle.readMu.Lock() defer handle.readMu.Unlock() // wait for packet writer to stop handle.writeMu.Lock() defer handle.writeMu.Unlock() // stop reading and writing handle.stop = ...
go
func (handle *MemifPacketHandle) Close() { handle.closeMu.Lock() defer handle.closeMu.Unlock() // wait for packet reader to stop handle.readMu.Lock() defer handle.readMu.Unlock() // wait for packet writer to stop handle.writeMu.Lock() defer handle.writeMu.Unlock() // stop reading and writing handle.stop = ...
[ "func", "(", "handle", "*", "MemifPacketHandle", ")", "Close", "(", ")", "{", "handle", ".", "closeMu", ".", "Lock", "(", ")", "\n", "defer", "handle", ".", "closeMu", ".", "Unlock", "(", ")", "\n\n", "// wait for packet reader to stop", "handle", ".", "re...
// Waits for all read and write operations to finish and then prevents more from occurring. Handle can be closed only // once and then can never be opened again.
[ "Waits", "for", "all", "read", "and", "write", "operations", "to", "finish", "and", "then", "prevents", "more", "from", "occurring", ".", "Handle", "can", "be", "closed", "only", "once", "and", "then", "can", "never", "be", "opened", "again", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/extras/libmemif/packethandle.go#L136-L150
134,618
FDio/govpp
api/binapi.go
RegisterMessage
func RegisterMessage(x Message, name string) { name = x.GetMessageName() + "_" + x.GetCrcString() /*if _, ok := registeredMessages[name]; ok { panic(fmt.Errorf("govpp: duplicate message registered: %s (%s)", name, x.GetCrcString())) }*/ registeredMessages[name] = x }
go
func RegisterMessage(x Message, name string) { name = x.GetMessageName() + "_" + x.GetCrcString() /*if _, ok := registeredMessages[name]; ok { panic(fmt.Errorf("govpp: duplicate message registered: %s (%s)", name, x.GetCrcString())) }*/ registeredMessages[name] = x }
[ "func", "RegisterMessage", "(", "x", "Message", ",", "name", "string", ")", "{", "name", "=", "x", ".", "GetMessageName", "(", ")", "+", "\"", "\"", "+", "x", ".", "GetCrcString", "(", ")", "\n", "/*if _, ok := registeredMessages[name]; ok {\n\t\tpanic(fmt.Error...
// RegisterMessage is called from generated code to register message.
[ "RegisterMessage", "is", "called", "from", "generated", "code", "to", "register", "message", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/api/binapi.go#L124-L130
134,619
FDio/govpp
core/stats.go
ConnectStats
func ConnectStats(stats adapter.StatsAPI) (*StatsConnection, error) { c := newStatsConnection(stats) if err := c.connectClient(); err != nil { return nil, err } return c, nil }
go
func ConnectStats(stats adapter.StatsAPI) (*StatsConnection, error) { c := newStatsConnection(stats) if err := c.connectClient(); err != nil { return nil, err } return c, nil }
[ "func", "ConnectStats", "(", "stats", "adapter", ".", "StatsAPI", ")", "(", "*", "StatsConnection", ",", "error", ")", "{", "c", ":=", "newStatsConnection", "(", "stats", ")", "\n\n", "if", "err", ":=", "c", ".", "connectClient", "(", ")", ";", "err", ...
// Connect connects to Stats API using specified adapter and returns a connection handle. // This call blocks until it is either connected, or an error occurs. // Only one connection attempt will be performed.
[ "Connect", "connects", "to", "Stats", "API", "using", "specified", "adapter", "and", "returns", "a", "connection", "handle", ".", "This", "call", "blocks", "until", "it", "is", "either", "connected", "or", "an", "error", "occurs", ".", "Only", "one", "connec...
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/core/stats.go#L78-L86
134,620
FDio/govpp
core/stats.go
Disconnect
func (c *StatsConnection) Disconnect() { if c == nil { return } if c.statsClient != nil { c.disconnectClient() } }
go
func (c *StatsConnection) Disconnect() { if c == nil { return } if c.statsClient != nil { c.disconnectClient() } }
[ "func", "(", "c", "*", "StatsConnection", ")", "Disconnect", "(", ")", "{", "if", "c", "==", "nil", "{", "return", "\n", "}", "\n\n", "if", "c", ".", "statsClient", "!=", "nil", "{", "c", ".", "disconnectClient", "(", ")", "\n", "}", "\n", "}" ]
// Disconnect disconnects from Stats API and releases all connection-related resources.
[ "Disconnect", "disconnects", "from", "Stats", "API", "and", "releases", "all", "connection", "-", "related", "resources", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/core/stats.go#L104-L112
134,621
FDio/govpp
core/stats.go
GetSystemStats
func (c *StatsConnection) GetSystemStats() (*api.SystemStats, error) { stats, err := c.statsClient.DumpStats(SystemStatsPrefix) if err != nil { return nil, err } sysStats := &api.SystemStats{} for _, stat := range stats { switch stat.Name { case SystemStats_VectorRate: sysStats.VectorRate = scalarStatTo...
go
func (c *StatsConnection) GetSystemStats() (*api.SystemStats, error) { stats, err := c.statsClient.DumpStats(SystemStatsPrefix) if err != nil { return nil, err } sysStats := &api.SystemStats{} for _, stat := range stats { switch stat.Name { case SystemStats_VectorRate: sysStats.VectorRate = scalarStatTo...
[ "func", "(", "c", "*", "StatsConnection", ")", "GetSystemStats", "(", ")", "(", "*", "api", ".", "SystemStats", ",", "error", ")", "{", "stats", ",", "err", ":=", "c", ".", "statsClient", ".", "DumpStats", "(", "SystemStatsPrefix", ")", "\n", "if", "er...
// GetSystemStats retrieves VPP system stats.
[ "GetSystemStats", "retrieves", "VPP", "system", "stats", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/core/stats.go#L121-L145
134,622
FDio/govpp
core/stats.go
GetErrorStats
func (c *StatsConnection) GetErrorStats(names ...string) (*api.ErrorStats, error) { var patterns []string if len(names) > 0 { patterns = make([]string, len(names)) for i, name := range names { patterns[i] = CounterStatsPrefix + name } } else { // retrieve all error counters by default patterns = []strin...
go
func (c *StatsConnection) GetErrorStats(names ...string) (*api.ErrorStats, error) { var patterns []string if len(names) > 0 { patterns = make([]string, len(names)) for i, name := range names { patterns[i] = CounterStatsPrefix + name } } else { // retrieve all error counters by default patterns = []strin...
[ "func", "(", "c", "*", "StatsConnection", ")", "GetErrorStats", "(", "names", "...", "string", ")", "(", "*", "api", ".", "ErrorStats", ",", "error", ")", "{", "var", "patterns", "[", "]", "string", "\n", "if", "len", "(", "names", ")", ">", "0", "...
// GetErrorStats retrieves VPP error stats.
[ "GetErrorStats", "retrieves", "VPP", "error", "stats", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/core/stats.go#L148-L188
134,623
FDio/govpp
core/stats.go
GetNodeStats
func (c *StatsConnection) GetNodeStats() (*api.NodeStats, error) { stats, err := c.statsClient.DumpStats(NodeStatsPrefix) if err != nil { return nil, err } nodeStats := &api.NodeStats{} var setPerNode = func(perNode []uint64, fn func(c *api.NodeCounters, v uint64)) { if nodeStats.Nodes == nil { nodeStats....
go
func (c *StatsConnection) GetNodeStats() (*api.NodeStats, error) { stats, err := c.statsClient.DumpStats(NodeStatsPrefix) if err != nil { return nil, err } nodeStats := &api.NodeStats{} var setPerNode = func(perNode []uint64, fn func(c *api.NodeCounters, v uint64)) { if nodeStats.Nodes == nil { nodeStats....
[ "func", "(", "c", "*", "StatsConnection", ")", "GetNodeStats", "(", ")", "(", "*", "api", ".", "NodeStats", ",", "error", ")", "{", "stats", ",", "err", ":=", "c", ".", "statsClient", ".", "DumpStats", "(", "NodeStatsPrefix", ")", "\n", "if", "err", ...
// GetNodeStats retrieves VPP per node stats.
[ "GetNodeStats", "retrieves", "VPP", "per", "node", "stats", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/core/stats.go#L191-L252
134,624
FDio/govpp
core/stats.go
GetBufferStats
func (c *StatsConnection) GetBufferStats() (*api.BufferStats, error) { stats, err := c.statsClient.DumpStats(BufferStatsPrefix) if err != nil { return nil, err } bufStats := &api.BufferStats{ Buffer: map[string]api.BufferPool{}, } for _, stat := range stats { d, f := path.Split(stat.Name) d = strings.Tr...
go
func (c *StatsConnection) GetBufferStats() (*api.BufferStats, error) { stats, err := c.statsClient.DumpStats(BufferStatsPrefix) if err != nil { return nil, err } bufStats := &api.BufferStats{ Buffer: map[string]api.BufferPool{}, } for _, stat := range stats { d, f := path.Split(stat.Name) d = strings.Tr...
[ "func", "(", "c", "*", "StatsConnection", ")", "GetBufferStats", "(", ")", "(", "*", "api", ".", "BufferStats", ",", "error", ")", "{", "stats", ",", "err", ":=", "c", ".", "statsClient", ".", "DumpStats", "(", "BufferStatsPrefix", ")", "\n", "if", "er...
// GetBufferStats retrieves VPP buffer pools stats.
[ "GetBufferStats", "retrieves", "VPP", "buffer", "pools", "stats", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/core/stats.go#L399-L432
134,625
FDio/govpp
codec/msg_codec.go
EncodeMsg
func (*MsgCodec) EncodeMsg(msg api.Message, msgID uint16) (data []byte, err error) { if msg == nil { return nil, errors.New("nil message passed in") } // try to recover panic which might possibly occur in struc.Pack call defer func() { if r := recover(); r != nil { var ok bool if err, ok = r.(error); !ok...
go
func (*MsgCodec) EncodeMsg(msg api.Message, msgID uint16) (data []byte, err error) { if msg == nil { return nil, errors.New("nil message passed in") } // try to recover panic which might possibly occur in struc.Pack call defer func() { if r := recover(); r != nil { var ok bool if err, ok = r.(error); !ok...
[ "func", "(", "*", "MsgCodec", ")", "EncodeMsg", "(", "msg", "api", ".", "Message", ",", "msgID", "uint16", ")", "(", "data", "[", "]", "byte", ",", "err", "error", ")", "{", "if", "msg", "==", "nil", "{", "return", "nil", ",", "errors", ".", "New...
// EncodeMsg encodes provided `Message` structure into its binary-encoded data representation.
[ "EncodeMsg", "encodes", "provided", "Message", "structure", "into", "its", "binary", "-", "encoded", "data", "representation", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/codec/msg_codec.go#L56-L101
134,626
FDio/govpp
codec/msg_codec.go
DecodeMsg
func (*MsgCodec) DecodeMsg(data []byte, msg api.Message) error { if msg == nil { return errors.New("nil message passed in") } var header interface{} // check which header is expected switch msg.GetMessageType() { case api.RequestMessage: header = new(VppRequestHeader) case api.ReplyMessage: header = new(...
go
func (*MsgCodec) DecodeMsg(data []byte, msg api.Message) error { if msg == nil { return errors.New("nil message passed in") } var header interface{} // check which header is expected switch msg.GetMessageType() { case api.RequestMessage: header = new(VppRequestHeader) case api.ReplyMessage: header = new(...
[ "func", "(", "*", "MsgCodec", ")", "DecodeMsg", "(", "data", "[", "]", "byte", ",", "msg", "api", ".", "Message", ")", "error", "{", "if", "msg", "==", "nil", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "var", ...
// DecodeMsg decodes binary-encoded data of a message into provided `Message` structure.
[ "DecodeMsg", "decodes", "binary", "-", "encoded", "data", "of", "a", "message", "into", "provided", "Message", "structure", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/codec/msg_codec.go#L104-L136
134,627
FDio/govpp
adapter/mock/binapi/binapi_reflect.go
findFieldOfType
func findFieldOfType(reply reflect.Type, fieldName string) (reflect.StructField, bool) { for reply.Kind() == reflect.Ptr { reply = reply.Elem() } if reply.Kind() == reflect.Struct { field, found := reply.FieldByName(fieldName) return field, found } return reflect.StructField{}, false }
go
func findFieldOfType(reply reflect.Type, fieldName string) (reflect.StructField, bool) { for reply.Kind() == reflect.Ptr { reply = reply.Elem() } if reply.Kind() == reflect.Struct { field, found := reply.FieldByName(fieldName) return field, found } return reflect.StructField{}, false }
[ "func", "findFieldOfType", "(", "reply", "reflect", ".", "Type", ",", "fieldName", "string", ")", "(", "reflect", ".", "StructField", ",", "bool", ")", "{", "for", "reply", ".", "Kind", "(", ")", "==", "reflect", ".", "Ptr", "{", "reply", "=", "reply",...
// findFieldOfType finds the field specified by its name in provided message defined as reflect.Type data type.
[ "findFieldOfType", "finds", "the", "field", "specified", "by", "its", "name", "in", "provided", "message", "defined", "as", "reflect", ".", "Type", "data", "type", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/adapter/mock/binapi/binapi_reflect.go#L28-L37
134,628
FDio/govpp
adapter/mock/binapi/binapi_reflect.go
findFieldOfValue
func findFieldOfValue(reply reflect.Value, fieldName string) (reflect.Value, bool) { if reply.Kind() == reflect.Struct { field := reply.FieldByName(fieldName) return field, field.IsValid() } else if reply.Kind() == reflect.Ptr && reply.Elem().Kind() == reflect.Struct { field := reply.Elem().FieldByName(fieldNam...
go
func findFieldOfValue(reply reflect.Value, fieldName string) (reflect.Value, bool) { if reply.Kind() == reflect.Struct { field := reply.FieldByName(fieldName) return field, field.IsValid() } else if reply.Kind() == reflect.Ptr && reply.Elem().Kind() == reflect.Struct { field := reply.Elem().FieldByName(fieldNam...
[ "func", "findFieldOfValue", "(", "reply", "reflect", ".", "Value", ",", "fieldName", "string", ")", "(", "reflect", ".", "Value", ",", "bool", ")", "{", "if", "reply", ".", "Kind", "(", ")", "==", "reflect", ".", "Struct", "{", "field", ":=", "reply", ...
// findFieldOfValue finds the field specified by its name in provided message defined as reflect.Value data type.
[ "findFieldOfValue", "finds", "the", "field", "specified", "by", "its", "name", "in", "provided", "message", "defined", "as", "reflect", ".", "Value", "data", "type", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/adapter/mock/binapi/binapi_reflect.go#L40-L49
134,629
FDio/govpp
adapter/mock/binapi/binapi_reflect.go
HasSwIfIdx
func HasSwIfIdx(msg reflect.Type) bool { _, found := findFieldOfType(msg, swIfIndexName) return found }
go
func HasSwIfIdx(msg reflect.Type) bool { _, found := findFieldOfType(msg, swIfIndexName) return found }
[ "func", "HasSwIfIdx", "(", "msg", "reflect", ".", "Type", ")", "bool", "{", "_", ",", "found", ":=", "findFieldOfType", "(", "msg", ",", "swIfIndexName", ")", "\n", "return", "found", "\n", "}" ]
// HasSwIfIdx checks whether provided message has the swIfIndex field.
[ "HasSwIfIdx", "checks", "whether", "provided", "message", "has", "the", "swIfIndex", "field", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/adapter/mock/binapi/binapi_reflect.go#L52-L55
134,630
FDio/govpp
adapter/mock/binapi/binapi_reflect.go
SetSwIfIdx
func SetSwIfIdx(msg reflect.Value, swIfIndex uint32) { if field, found := findFieldOfValue(msg, swIfIndexName); found { field.Set(reflect.ValueOf(swIfIndex)) } }
go
func SetSwIfIdx(msg reflect.Value, swIfIndex uint32) { if field, found := findFieldOfValue(msg, swIfIndexName); found { field.Set(reflect.ValueOf(swIfIndex)) } }
[ "func", "SetSwIfIdx", "(", "msg", "reflect", ".", "Value", ",", "swIfIndex", "uint32", ")", "{", "if", "field", ",", "found", ":=", "findFieldOfValue", "(", "msg", ",", "swIfIndexName", ")", ";", "found", "{", "field", ".", "Set", "(", "reflect", ".", ...
// SetSwIfIdx sets the swIfIndex field of provided message to provided value.
[ "SetSwIfIdx", "sets", "the", "swIfIndex", "field", "of", "provided", "message", "to", "provided", "value", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/adapter/mock/binapi/binapi_reflect.go#L58-L62
134,631
FDio/govpp
adapter/mock/binapi/binapi_reflect.go
SetRetval
func SetRetval(msg reflect.Value, retVal int32) { if field, found := findFieldOfValue(msg, retvalName); found { field.Set(reflect.ValueOf(retVal)) } }
go
func SetRetval(msg reflect.Value, retVal int32) { if field, found := findFieldOfValue(msg, retvalName); found { field.Set(reflect.ValueOf(retVal)) } }
[ "func", "SetRetval", "(", "msg", "reflect", ".", "Value", ",", "retVal", "int32", ")", "{", "if", "field", ",", "found", ":=", "findFieldOfValue", "(", "msg", ",", "retvalName", ")", ";", "found", "{", "field", ".", "Set", "(", "reflect", ".", "ValueOf...
// SetRetval sets the retval field of provided message to provided value.
[ "SetRetval", "sets", "the", "retval", "field", "of", "provided", "message", "to", "provided", "value", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/adapter/mock/binapi/binapi_reflect.go#L65-L69
134,632
FDio/govpp
cmd/binapi-generator/generate.go
getContext
func getContext(inputFile, outputDir string) (*context, error) { if !strings.HasSuffix(inputFile, inputFileExt) { return nil, fmt.Errorf("invalid input file name: %q", inputFile) } ctx := &context{ inputFile: inputFile, } // package name inputFileName := filepath.Base(inputFile) ctx.moduleName = inputFileN...
go
func getContext(inputFile, outputDir string) (*context, error) { if !strings.HasSuffix(inputFile, inputFileExt) { return nil, fmt.Errorf("invalid input file name: %q", inputFile) } ctx := &context{ inputFile: inputFile, } // package name inputFileName := filepath.Base(inputFile) ctx.moduleName = inputFileN...
[ "func", "getContext", "(", "inputFile", ",", "outputDir", "string", ")", "(", "*", "context", ",", "error", ")", "{", "if", "!", "strings", ".", "HasSuffix", "(", "inputFile", ",", "inputFileExt", ")", "{", "return", "nil", ",", "fmt", ".", "Errorf", "...
// getContext returns context details of the code generation task
[ "getContext", "returns", "context", "details", "of", "the", "code", "generation", "task" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/cmd/binapi-generator/generate.go#L52-L81
134,633
FDio/govpp
cmd/binapi-generator/generate.go
generatePackage
func generatePackage(ctx *context, w *bufio.Writer) error { logf("generating package %q", ctx.packageName) // generate file header generateHeader(ctx, w) generateImports(ctx, w) if ctx.includeAPIVersionCrc { fmt.Fprintf(w, "// %s defines API version CRC of the VPP binary API module.\n", constAPIVersionCrc) f...
go
func generatePackage(ctx *context, w *bufio.Writer) error { logf("generating package %q", ctx.packageName) // generate file header generateHeader(ctx, w) generateImports(ctx, w) if ctx.includeAPIVersionCrc { fmt.Fprintf(w, "// %s defines API version CRC of the VPP binary API module.\n", constAPIVersionCrc) f...
[ "func", "generatePackage", "(", "ctx", "*", "context", ",", "w", "*", "bufio", ".", "Writer", ")", "error", "{", "logf", "(", "\"", "\"", ",", "ctx", ".", "packageName", ")", "\n\n", "// generate file header", "generateHeader", "(", "ctx", ",", "w", ")",...
// generatePackage generates code for the parsed package data and writes it into w
[ "generatePackage", "generates", "code", "for", "the", "parsed", "package", "data", "and", "writes", "it", "into", "w" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/cmd/binapi-generator/generate.go#L84-L171
134,634
FDio/govpp
cmd/binapi-generator/generate.go
generateHeader
func generateHeader(ctx *context, w io.Writer) { fmt.Fprintln(w, "// Code generated by GoVPP binapi-generator. DO NOT EDIT.") fmt.Fprintf(w, "// source: %s\n", ctx.inputFile) fmt.Fprintln(w) fmt.Fprintln(w, "/*") fmt.Fprintf(w, " Package %s is a generated from VPP binary API module '%s'.\n", ctx.packageName, ctx...
go
func generateHeader(ctx *context, w io.Writer) { fmt.Fprintln(w, "// Code generated by GoVPP binapi-generator. DO NOT EDIT.") fmt.Fprintf(w, "// source: %s\n", ctx.inputFile) fmt.Fprintln(w) fmt.Fprintln(w, "/*") fmt.Fprintf(w, " Package %s is a generated from VPP binary API module '%s'.\n", ctx.packageName, ctx...
[ "func", "generateHeader", "(", "ctx", "*", "context", ",", "w", "io", ".", "Writer", ")", "{", "fmt", ".", "Fprintln", "(", "w", ",", "\"", "\"", ")", "\n", "fmt", ".", "Fprintf", "(", "w", ",", "\"", "\\n", "\"", ",", "ctx", ".", "inputFile", ...
// generateHeader writes generated package header into w
[ "generateHeader", "writes", "generated", "package", "header", "into", "w" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/cmd/binapi-generator/generate.go#L174-L205
134,635
FDio/govpp
cmd/binapi-generator/generate.go
generateImports
func generateImports(ctx *context, w io.Writer) { fmt.Fprintf(w, "import api \"%s\"\n", govppApiImportPath) fmt.Fprintf(w, "import struc \"%s\"\n", "github.com/lunixbochs/struc") fmt.Fprintf(w, "import bytes \"%s\"\n", "bytes") fmt.Fprintln(w) fmt.Fprintf(w, "// Reference imports to suppress errors if they are no...
go
func generateImports(ctx *context, w io.Writer) { fmt.Fprintf(w, "import api \"%s\"\n", govppApiImportPath) fmt.Fprintf(w, "import struc \"%s\"\n", "github.com/lunixbochs/struc") fmt.Fprintf(w, "import bytes \"%s\"\n", "bytes") fmt.Fprintln(w) fmt.Fprintf(w, "// Reference imports to suppress errors if they are no...
[ "func", "generateImports", "(", "ctx", "*", "context", ",", "w", "io", ".", "Writer", ")", "{", "fmt", ".", "Fprintf", "(", "w", ",", "\"", "\\\"", "\\\"", "\\n", "\"", ",", "govppApiImportPath", ")", "\n", "fmt", ".", "Fprintf", "(", "w", ",", "\"...
// generateImports writes generated package imports into w
[ "generateImports", "writes", "generated", "package", "imports", "into", "w" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/cmd/binapi-generator/generate.go#L208-L226
134,636
FDio/govpp
cmd/binapi-generator/generate.go
generateComment
func generateComment(ctx *context, w io.Writer, goName string, vppName string, objKind string) { if objKind == "service" { fmt.Fprintf(w, "// %s represents VPP binary API services:\n", goName) } else { fmt.Fprintf(w, "// %s represents VPP binary API %s '%s':\n", goName, objKind, vppName) } if !ctx.includeComme...
go
func generateComment(ctx *context, w io.Writer, goName string, vppName string, objKind string) { if objKind == "service" { fmt.Fprintf(w, "// %s represents VPP binary API services:\n", goName) } else { fmt.Fprintf(w, "// %s represents VPP binary API %s '%s':\n", goName, objKind, vppName) } if !ctx.includeComme...
[ "func", "generateComment", "(", "ctx", "*", "context", ",", "w", "io", ".", "Writer", ",", "goName", "string", ",", "vppName", "string", ",", "objKind", "string", ")", "{", "if", "objKind", "==", "\"", "\"", "{", "fmt", ".", "Fprintf", "(", "w", ",",...
// generateComment writes generated comment for the object into w
[ "generateComment", "writes", "generated", "comment", "for", "the", "object", "into", "w" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/cmd/binapi-generator/generate.go#L229-L288
134,637
FDio/govpp
cmd/binapi-generator/generate.go
generateServices
func generateServices(ctx *context, w *bufio.Writer, services []Service) { // generate services comment generateComment(ctx, w, "Services", "services", "service") // generate interface fmt.Fprintf(w, "type %s interface {\n", "Services") for _, svc := range services { generateService(ctx, w, &svc) } fmt.Fprint...
go
func generateServices(ctx *context, w *bufio.Writer, services []Service) { // generate services comment generateComment(ctx, w, "Services", "services", "service") // generate interface fmt.Fprintf(w, "type %s interface {\n", "Services") for _, svc := range services { generateService(ctx, w, &svc) } fmt.Fprint...
[ "func", "generateServices", "(", "ctx", "*", "context", ",", "w", "*", "bufio", ".", "Writer", ",", "services", "[", "]", "Service", ")", "{", "// generate services comment", "generateComment", "(", "ctx", ",", "w", ",", "\"", "\"", ",", "\"", "\"", ",",...
// generateServices writes generated code for the Services interface into w
[ "generateServices", "writes", "generated", "code", "for", "the", "Services", "interface", "into", "w" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/cmd/binapi-generator/generate.go#L291-L303
134,638
FDio/govpp
cmd/binapi-generator/generate.go
generateService
func generateService(ctx *context, w io.Writer, svc *Service) { reqTyp := camelCaseName(svc.RequestType) // method name is same as parameter type name by default method := reqTyp if svc.Stream { // use Dump as prefix instead of suffix for stream services if m := strings.TrimSuffix(method, "Dump"); method != m ...
go
func generateService(ctx *context, w io.Writer, svc *Service) { reqTyp := camelCaseName(svc.RequestType) // method name is same as parameter type name by default method := reqTyp if svc.Stream { // use Dump as prefix instead of suffix for stream services if m := strings.TrimSuffix(method, "Dump"); method != m ...
[ "func", "generateService", "(", "ctx", "*", "context", ",", "w", "io", ".", "Writer", ",", "svc", "*", "Service", ")", "{", "reqTyp", ":=", "camelCaseName", "(", "svc", ".", "RequestType", ")", "\n\n", "// method name is same as parameter type name by default", ...
// generateService writes generated code for the service into w
[ "generateService", "writes", "generated", "code", "for", "the", "service", "into", "w" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/cmd/binapi-generator/generate.go#L306-L329
134,639
FDio/govpp
cmd/binapi-generator/generate.go
generateEnum
func generateEnum(ctx *context, w io.Writer, enum *Enum) { name := camelCaseName(enum.Name) typ := binapiTypes[enum.Type] logf(" writing enum %q (%s) with %d entries", enum.Name, name, len(enum.Entries)) // generate enum comment generateComment(ctx, w, name, enum.Name, "enum") // generate enum definition fmt....
go
func generateEnum(ctx *context, w io.Writer, enum *Enum) { name := camelCaseName(enum.Name) typ := binapiTypes[enum.Type] logf(" writing enum %q (%s) with %d entries", enum.Name, name, len(enum.Entries)) // generate enum comment generateComment(ctx, w, name, enum.Name, "enum") // generate enum definition fmt....
[ "func", "generateEnum", "(", "ctx", "*", "context", ",", "w", "io", ".", "Writer", ",", "enum", "*", "Enum", ")", "{", "name", ":=", "camelCaseName", "(", "enum", ".", "Name", ")", "\n", "typ", ":=", "binapiTypes", "[", "enum", ".", "Type", "]", "\...
// generateEnum writes generated code for the enum into w
[ "generateEnum", "writes", "generated", "code", "for", "the", "enum", "into", "w" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/cmd/binapi-generator/generate.go#L332-L355
134,640
FDio/govpp
cmd/binapi-generator/generate.go
generateAlias
func generateAlias(ctx *context, w io.Writer, alias *Alias) { name := camelCaseName(alias.Name) logf(" writing type %q (%s), length: %d", alias.Name, name, alias.Length) // generate struct comment generateComment(ctx, w, name, alias.Name, "alias") // generate struct definition fmt.Fprintf(w, "type %s ", name) ...
go
func generateAlias(ctx *context, w io.Writer, alias *Alias) { name := camelCaseName(alias.Name) logf(" writing type %q (%s), length: %d", alias.Name, name, alias.Length) // generate struct comment generateComment(ctx, w, name, alias.Name, "alias") // generate struct definition fmt.Fprintf(w, "type %s ", name) ...
[ "func", "generateAlias", "(", "ctx", "*", "context", ",", "w", "io", ".", "Writer", ",", "alias", "*", "Alias", ")", "{", "name", ":=", "camelCaseName", "(", "alias", ".", "Name", ")", "\n\n", "logf", "(", "\"", "\"", ",", "alias", ".", "Name", ","...
// generateAlias writes generated code for the alias into w
[ "generateAlias", "writes", "generated", "code", "for", "the", "alias", "into", "w" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/cmd/binapi-generator/generate.go#L358-L377
134,641
FDio/govpp
cmd/binapi-generator/generate.go
generateUnion
func generateUnion(ctx *context, w io.Writer, union *Union) { name := camelCaseName(union.Name) logf(" writing union %q (%s) with %d fields", union.Name, name, len(union.Fields)) // generate struct comment generateComment(ctx, w, name, union.Name, "union") // generate struct definition fmt.Fprintln(w, "type", ...
go
func generateUnion(ctx *context, w io.Writer, union *Union) { name := camelCaseName(union.Name) logf(" writing union %q (%s) with %d fields", union.Name, name, len(union.Fields)) // generate struct comment generateComment(ctx, w, name, union.Name, "union") // generate struct definition fmt.Fprintln(w, "type", ...
[ "func", "generateUnion", "(", "ctx", "*", "context", ",", "w", "io", ".", "Writer", ",", "union", "*", "Union", ")", "{", "name", ":=", "camelCaseName", "(", "union", ".", "Name", ")", "\n\n", "logf", "(", "\"", "\"", ",", "union", ".", "Name", ","...
// generateUnion writes generated code for the union into w
[ "generateUnion", "writes", "generated", "code", "for", "the", "union", "into", "w" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/cmd/binapi-generator/generate.go#L380-L418
134,642
FDio/govpp
cmd/binapi-generator/generate.go
generateType
func generateType(ctx *context, w io.Writer, typ *Type) { name := camelCaseName(typ.Name) logf(" writing type %q (%s) with %d fields", typ.Name, name, len(typ.Fields)) // generate struct comment generateComment(ctx, w, name, typ.Name, "type") // generate struct definition fmt.Fprintf(w, "type %s struct {\n", n...
go
func generateType(ctx *context, w io.Writer, typ *Type) { name := camelCaseName(typ.Name) logf(" writing type %q (%s) with %d fields", typ.Name, name, len(typ.Fields)) // generate struct comment generateComment(ctx, w, name, typ.Name, "type") // generate struct definition fmt.Fprintf(w, "type %s struct {\n", n...
[ "func", "generateType", "(", "ctx", "*", "context", ",", "w", "io", ".", "Writer", ",", "typ", "*", "Type", ")", "{", "name", ":=", "camelCaseName", "(", "typ", ".", "Name", ")", "\n\n", "logf", "(", "\"", "\"", ",", "typ", ".", "Name", ",", "nam...
// generateType writes generated code for the type into w
[ "generateType", "writes", "generated", "code", "for", "the", "type", "into", "w" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/cmd/binapi-generator/generate.go#L468-L500
134,643
FDio/govpp
cmd/binapi-generator/generate.go
generateMessage
func generateMessage(ctx *context, w io.Writer, msg *Message) { name := camelCaseName(msg.Name) logf(" writing message %q (%s) with %d fields", msg.Name, name, len(msg.Fields)) // generate struct comment generateComment(ctx, w, name, msg.Name, "message") // generate struct definition fmt.Fprintf(w, "type %s st...
go
func generateMessage(ctx *context, w io.Writer, msg *Message) { name := camelCaseName(msg.Name) logf(" writing message %q (%s) with %d fields", msg.Name, name, len(msg.Fields)) // generate struct comment generateComment(ctx, w, name, msg.Name, "message") // generate struct definition fmt.Fprintf(w, "type %s st...
[ "func", "generateMessage", "(", "ctx", "*", "context", ",", "w", "io", ".", "Writer", ",", "msg", "*", "Message", ")", "{", "name", ":=", "camelCaseName", "(", "msg", ".", "Name", ")", "\n\n", "logf", "(", "\"", "\"", ",", "msg", ".", "Name", ",", ...
// generateMessage writes generated code for the message into w
[ "generateMessage", "writes", "generated", "code", "for", "the", "message", "into", "w" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/cmd/binapi-generator/generate.go#L503-L568
134,644
FDio/govpp
cmd/binapi-generator/generate.go
generateField
func generateField(ctx *context, w io.Writer, fields []Field, i int) { field := fields[i] fieldName := strings.TrimPrefix(field.Name, "_") fieldName = camelCaseName(fieldName) // generate length field for strings if field.Type == "string" { fmt.Fprintf(w, "\tXXX_%sLen uint32 `struc:\"sizeof=%s\"`\n", fieldName...
go
func generateField(ctx *context, w io.Writer, fields []Field, i int) { field := fields[i] fieldName := strings.TrimPrefix(field.Name, "_") fieldName = camelCaseName(fieldName) // generate length field for strings if field.Type == "string" { fmt.Fprintf(w, "\tXXX_%sLen uint32 `struc:\"sizeof=%s\"`\n", fieldName...
[ "func", "generateField", "(", "ctx", "*", "context", ",", "w", "io", ".", "Writer", ",", "fields", "[", "]", "Field", ",", "i", "int", ")", "{", "field", ":=", "fields", "[", "i", "]", "\n\n", "fieldName", ":=", "strings", ".", "TrimPrefix", "(", "...
// generateField writes generated code for the field into w
[ "generateField", "writes", "generated", "code", "for", "the", "field", "into", "w" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/cmd/binapi-generator/generate.go#L571-L608
134,645
FDio/govpp
cmd/binapi-generator/generate.go
generateTypeNameGetter
func generateTypeNameGetter(w io.Writer, structName, msgName string) { fmt.Fprintf(w, `func (*%s) GetTypeName() string { return %q } `, structName, msgName) }
go
func generateTypeNameGetter(w io.Writer, structName, msgName string) { fmt.Fprintf(w, `func (*%s) GetTypeName() string { return %q } `, structName, msgName) }
[ "func", "generateTypeNameGetter", "(", "w", "io", ".", "Writer", ",", "structName", ",", "msgName", "string", ")", "{", "fmt", ".", "Fprintf", "(", "w", ",", "`func (*%s) GetTypeName() string {\n\treturn %q\n}\n`", ",", "structName", ",", "msgName", ")", "\n", "...
// generateTypeNameGetter generates getter for original VPP type name into the provider writer
[ "generateTypeNameGetter", "generates", "getter", "for", "original", "VPP", "type", "name", "into", "the", "provider", "writer" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/cmd/binapi-generator/generate.go#L619-L624
134,646
FDio/govpp
cmd/binapi-generator/generate.go
generateCrcGetter
func generateCrcGetter(w io.Writer, structName, crc string) { crc = strings.TrimPrefix(crc, "0x") fmt.Fprintf(w, `func (*%s) GetCrcString() string { return %q } `, structName, crc) }
go
func generateCrcGetter(w io.Writer, structName, crc string) { crc = strings.TrimPrefix(crc, "0x") fmt.Fprintf(w, `func (*%s) GetCrcString() string { return %q } `, structName, crc) }
[ "func", "generateCrcGetter", "(", "w", "io", ".", "Writer", ",", "structName", ",", "crc", "string", ")", "{", "crc", "=", "strings", ".", "TrimPrefix", "(", "crc", ",", "\"", "\"", ")", "\n", "fmt", ".", "Fprintf", "(", "w", ",", "`func (*%s) GetCrcSt...
// generateCrcGetter generates getter for CRC checksum of the message definition into the provider writer
[ "generateCrcGetter", "generates", "getter", "for", "CRC", "checksum", "of", "the", "message", "definition", "into", "the", "provider", "writer" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/cmd/binapi-generator/generate.go#L627-L633
134,647
FDio/govpp
cmd/binapi-generator/generate.go
generateMessageTypeGetter
func generateMessageTypeGetter(w io.Writer, structName string, msgType MessageType) { fmt.Fprintln(w, "func (*"+structName+") GetMessageType() api.MessageType {") if msgType == requestMessage { fmt.Fprintln(w, "\treturn api.RequestMessage") } else if msgType == replyMessage { fmt.Fprintln(w, "\treturn api.ReplyM...
go
func generateMessageTypeGetter(w io.Writer, structName string, msgType MessageType) { fmt.Fprintln(w, "func (*"+structName+") GetMessageType() api.MessageType {") if msgType == requestMessage { fmt.Fprintln(w, "\treturn api.RequestMessage") } else if msgType == replyMessage { fmt.Fprintln(w, "\treturn api.ReplyM...
[ "func", "generateMessageTypeGetter", "(", "w", "io", ".", "Writer", ",", "structName", "string", ",", "msgType", "MessageType", ")", "{", "fmt", ".", "Fprintln", "(", "w", ",", "\"", "\"", "+", "structName", "+", "\"", "\"", ")", "\n", "if", "msgType", ...
// generateMessageTypeGetter generates message factory for the generated message into the provider writer
[ "generateMessageTypeGetter", "generates", "message", "factory", "for", "the", "generated", "message", "into", "the", "provider", "writer" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/cmd/binapi-generator/generate.go#L636-L648
134,648
FDio/govpp
extras/libmemif/examples/raw-data/raw-data.go
SendPackets
func SendPackets(memif *libmemif.Memif, queueID uint8) { defer wg.Done() counter := 0 for { select { case <-time.After(3 * time.Second): counter++ // Prepare fake packets. packets := []libmemif.RawPacketData{ libmemif.RawPacketData("Packet #1 in burst number " + strconv.Itoa(counter)), libmemif...
go
func SendPackets(memif *libmemif.Memif, queueID uint8) { defer wg.Done() counter := 0 for { select { case <-time.After(3 * time.Second): counter++ // Prepare fake packets. packets := []libmemif.RawPacketData{ libmemif.RawPacketData("Packet #1 in burst number " + strconv.Itoa(counter)), libmemif...
[ "func", "SendPackets", "(", "memif", "*", "libmemif", ".", "Memif", ",", "queueID", "uint8", ")", "{", "defer", "wg", ".", "Done", "(", ")", "\n\n", "counter", ":=", "0", "\n", "for", "{", "select", "{", "case", "<-", "time", ".", "After", "(", "3"...
// SendPackets keeps sending bursts of 3 raw-data packets every 3 seconds into // the selected queue.
[ "SendPackets", "keeps", "sending", "bursts", "of", "3", "raw", "-", "data", "packets", "every", "3", "seconds", "into", "the", "selected", "queue", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/extras/libmemif/examples/raw-data/raw-data.go#L139-L173
134,649
FDio/govpp
adapter/vppapiclient/vppapiclient.go
NewVppClientWithInputQueueSize
func NewVppClientWithInputQueueSize(shmPrefix string, inputQueueSize uint16) adapter.VppAPI { return &vppClient{ shmPrefix: shmPrefix, inputQueueSize: inputQueueSize, } }
go
func NewVppClientWithInputQueueSize(shmPrefix string, inputQueueSize uint16) adapter.VppAPI { return &vppClient{ shmPrefix: shmPrefix, inputQueueSize: inputQueueSize, } }
[ "func", "NewVppClientWithInputQueueSize", "(", "shmPrefix", "string", ",", "inputQueueSize", "uint16", ")", "adapter", ".", "VppAPI", "{", "return", "&", "vppClient", "{", "shmPrefix", ":", "shmPrefix", ",", "inputQueueSize", ":", "inputQueueSize", ",", "}", "\n",...
// NewVppClientWithInputQueueSize returns a new VPP binary API client with a custom input queue size.
[ "NewVppClientWithInputQueueSize", "returns", "a", "new", "VPP", "binary", "API", "client", "with", "a", "custom", "input", "queue", "size", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/adapter/vppapiclient/vppapiclient.go#L118-L123
134,650
FDio/govpp
adapter/vppapiclient/vppapiclient.go
Connect
func (a *vppClient) Connect() error { if globalVppClient != nil { return fmt.Errorf("already connected to binary API, disconnect first") } rxQlen := C.int(a.inputQueueSize) var rc C.int if a.shmPrefix == "" { rc = C.govpp_connect(nil, rxQlen) } else { shm := C.CString(a.shmPrefix) rc = C.govpp_connect(sh...
go
func (a *vppClient) Connect() error { if globalVppClient != nil { return fmt.Errorf("already connected to binary API, disconnect first") } rxQlen := C.int(a.inputQueueSize) var rc C.int if a.shmPrefix == "" { rc = C.govpp_connect(nil, rxQlen) } else { shm := C.CString(a.shmPrefix) rc = C.govpp_connect(sh...
[ "func", "(", "a", "*", "vppClient", ")", "Connect", "(", ")", "error", "{", "if", "globalVppClient", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "rxQlen", ":=", "C", ".", "int", "(", "a", ".", "input...
// Connect connects the process to VPP.
[ "Connect", "connects", "the", "process", "to", "VPP", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/adapter/vppapiclient/vppapiclient.go#L126-L145
134,651
FDio/govpp
adapter/vppapiclient/vppapiclient.go
Disconnect
func (a *vppClient) Disconnect() error { globalVppClient = nil rc := C.govpp_disconnect() if rc != 0 { return fmt.Errorf("disconnecting from VPP binary API failed (rc=%v)", rc) } return nil }
go
func (a *vppClient) Disconnect() error { globalVppClient = nil rc := C.govpp_disconnect() if rc != 0 { return fmt.Errorf("disconnecting from VPP binary API failed (rc=%v)", rc) } return nil }
[ "func", "(", "a", "*", "vppClient", ")", "Disconnect", "(", ")", "error", "{", "globalVppClient", "=", "nil", "\n\n", "rc", ":=", "C", ".", "govpp_disconnect", "(", ")", "\n", "if", "rc", "!=", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"", "...
// Disconnect disconnects the process from VPP.
[ "Disconnect", "disconnects", "the", "process", "from", "VPP", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/adapter/vppapiclient/vppapiclient.go#L148-L157
134,652
FDio/govpp
adapter/vppapiclient/vppapiclient.go
GetMsgID
func (a *vppClient) GetMsgID(msgName string, msgCrc string) (uint16, error) { nameAndCrc := C.CString(msgName + "_" + msgCrc) defer C.free(unsafe.Pointer(nameAndCrc)) msgID := uint16(C.govpp_get_msg_index(nameAndCrc)) if msgID == ^uint16(0) { // VPP does not know this message return msgID, fmt.Errorf("unknown ...
go
func (a *vppClient) GetMsgID(msgName string, msgCrc string) (uint16, error) { nameAndCrc := C.CString(msgName + "_" + msgCrc) defer C.free(unsafe.Pointer(nameAndCrc)) msgID := uint16(C.govpp_get_msg_index(nameAndCrc)) if msgID == ^uint16(0) { // VPP does not know this message return msgID, fmt.Errorf("unknown ...
[ "func", "(", "a", "*", "vppClient", ")", "GetMsgID", "(", "msgName", "string", ",", "msgCrc", "string", ")", "(", "uint16", ",", "error", ")", "{", "nameAndCrc", ":=", "C", ".", "CString", "(", "msgName", "+", "\"", "\"", "+", "msgCrc", ")", "\n", ...
// GetMsgID returns a runtime message ID for the given message name and CRC.
[ "GetMsgID", "returns", "a", "runtime", "message", "ID", "for", "the", "given", "message", "name", "and", "CRC", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/adapter/vppapiclient/vppapiclient.go#L160-L171
134,653
FDio/govpp
adapter/vppapiclient/vppapiclient.go
SendMsg
func (a *vppClient) SendMsg(context uint32, data []byte) error { rc := C.govpp_send(C.uint32_t(context), unsafe.Pointer(&data[0]), C.size_t(len(data))) if rc != 0 { return fmt.Errorf("unable to send the message (rc=%v)", rc) } return nil }
go
func (a *vppClient) SendMsg(context uint32, data []byte) error { rc := C.govpp_send(C.uint32_t(context), unsafe.Pointer(&data[0]), C.size_t(len(data))) if rc != 0 { return fmt.Errorf("unable to send the message (rc=%v)", rc) } return nil }
[ "func", "(", "a", "*", "vppClient", ")", "SendMsg", "(", "context", "uint32", ",", "data", "[", "]", "byte", ")", "error", "{", "rc", ":=", "C", ".", "govpp_send", "(", "C", ".", "uint32_t", "(", "context", ")", ",", "unsafe", ".", "Pointer", "(", ...
// SendMsg sends a binary-encoded message to VPP.
[ "SendMsg", "sends", "a", "binary", "-", "encoded", "message", "to", "VPP", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/adapter/vppapiclient/vppapiclient.go#L174-L180
134,654
FDio/govpp
adapter/vppapiclient/vppapiclient.go
WaitReady
func (a *vppClient) WaitReady() error { // join the path to the shared memory segment var path string if a.shmPrefix == "" { path = filepath.Join(shmDir, vppShmFile) } else { path = filepath.Join(shmDir, a.shmPrefix+"-"+vppShmFile) } // check if file at the path already exists if _, err := os.Stat(path); er...
go
func (a *vppClient) WaitReady() error { // join the path to the shared memory segment var path string if a.shmPrefix == "" { path = filepath.Join(shmDir, vppShmFile) } else { path = filepath.Join(shmDir, a.shmPrefix+"-"+vppShmFile) } // check if file at the path already exists if _, err := os.Stat(path); er...
[ "func", "(", "a", "*", "vppClient", ")", "WaitReady", "(", ")", "error", "{", "// join the path to the shared memory segment", "var", "path", "string", "\n", "if", "a", ".", "shmPrefix", "==", "\"", "\"", "{", "path", "=", "filepath", ".", "Join", "(", "sh...
// WaitReady blocks until shared memory for sending // binary api calls is present on the file system.
[ "WaitReady", "blocks", "until", "shared", "memory", "for", "sending", "binary", "api", "calls", "is", "present", "on", "the", "file", "system", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/adapter/vppapiclient/vppapiclient.go#L190-L234
134,655
FDio/govpp
extras/libmemif/error.go
newMemifError
func newMemifError(code int, desc ...string) *MemifError { var err *MemifError if len(desc) > 0 { err = &MemifError{code: code, description: "libmemif: " + desc[0]} } else { err = &MemifError{code: code, description: "libmemif: " + C.GoString(C.memif_strerror(C.int(code)))} } errorRegistry[code] = err return ...
go
func newMemifError(code int, desc ...string) *MemifError { var err *MemifError if len(desc) > 0 { err = &MemifError{code: code, description: "libmemif: " + desc[0]} } else { err = &MemifError{code: code, description: "libmemif: " + C.GoString(C.memif_strerror(C.int(code)))} } errorRegistry[code] = err return ...
[ "func", "newMemifError", "(", "code", "int", ",", "desc", "...", "string", ")", "*", "MemifError", "{", "var", "err", "*", "MemifError", "\n", "if", "len", "(", "desc", ")", ">", "0", "{", "err", "=", "&", "MemifError", "{", "code", ":", "code", ",...
// newMemifError builds and registers a new MemifError.
[ "newMemifError", "builds", "and", "registers", "a", "new", "MemifError", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/extras/libmemif/error.go#L102-L111
134,656
FDio/govpp
extras/libmemif/error.go
getMemifError
func getMemifError(code int) error { if code == 0 { return nil /* success */ } err, known := errorRegistry[code] if !known { return ErrUnknown } return err }
go
func getMemifError(code int) error { if code == 0 { return nil /* success */ } err, known := errorRegistry[code] if !known { return ErrUnknown } return err }
[ "func", "getMemifError", "(", "code", "int", ")", "error", "{", "if", "code", "==", "0", "{", "return", "nil", "/* success */", "\n", "}", "\n", "err", ",", "known", ":=", "errorRegistry", "[", "code", "]", "\n", "if", "!", "known", "{", "return", "E...
// getMemifError returns the MemifError associated with the given C-libmemif // error code.
[ "getMemifError", "returns", "the", "MemifError", "associated", "with", "the", "given", "C", "-", "libmemif", "error", "code", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/extras/libmemif/error.go#L115-L124
134,657
FDio/govpp
extras/libmemif/adapter.go
Cleanup
func Cleanup() error { context.lock.Lock() defer context.lock.Unlock() if !context.initialized { return ErrNotInit } log.Debug("Closing libmemif library") // Delete all active interfaces. for _, memif := range context.memifs { memif.Close() } // Stop the event loop (if supported by C-libmemif). errCod...
go
func Cleanup() error { context.lock.Lock() defer context.lock.Unlock() if !context.initialized { return ErrNotInit } log.Debug("Closing libmemif library") // Delete all active interfaces. for _, memif := range context.memifs { memif.Close() } // Stop the event loop (if supported by C-libmemif). errCod...
[ "func", "Cleanup", "(", ")", "error", "{", "context", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "context", ".", "lock", ".", "Unlock", "(", ")", "\n\n", "if", "!", "context", ".", "initialized", "{", "return", "ErrNotInit", "\n", "}", "\n\n"...
// Cleanup cleans up all the resources allocated by libmemif.
[ "Cleanup", "cleans", "up", "all", "the", "resources", "allocated", "by", "libmemif", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/extras/libmemif/adapter.go#L505-L538
134,658
FDio/govpp
extras/libmemif/adapter.go
SetRxMode
func (memif *Memif) SetRxMode(queueID uint8, rxMode RxMode) (err error) { var cRxMode C.memif_rx_mode_t switch rxMode { case RxModeInterrupt: cRxMode = C.MEMIF_RX_MODE_INTERRUPT case RxModePolling: cRxMode = C.MEMIF_RX_MODE_POLLING default: cRxMode = C.MEMIF_RX_MODE_INTERRUPT } errCode := C.memif_set_rx_mo...
go
func (memif *Memif) SetRxMode(queueID uint8, rxMode RxMode) (err error) { var cRxMode C.memif_rx_mode_t switch rxMode { case RxModeInterrupt: cRxMode = C.MEMIF_RX_MODE_INTERRUPT case RxModePolling: cRxMode = C.MEMIF_RX_MODE_POLLING default: cRxMode = C.MEMIF_RX_MODE_INTERRUPT } errCode := C.memif_set_rx_mo...
[ "func", "(", "memif", "*", "Memif", ")", "SetRxMode", "(", "queueID", "uint8", ",", "rxMode", "RxMode", ")", "(", "err", "error", ")", "{", "var", "cRxMode", "C", ".", "memif_rx_mode_t", "\n", "switch", "rxMode", "{", "case", "RxModeInterrupt", ":", "cRx...
// SetRxMode allows to switch between the interrupt and the polling mode for Rx. // The method is thread-safe.
[ "SetRxMode", "allows", "to", "switch", "between", "the", "interrupt", "and", "the", "polling", "mode", "for", "Rx", ".", "The", "method", "is", "thread", "-", "safe", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/extras/libmemif/adapter.go#L680-L692
134,659
FDio/govpp
extras/libmemif/adapter.go
GetDetails
func (memif *Memif) GetDetails() (details *MemifDetails, err error) { cDetails := C.govpp_memif_details_t{} var buf *C.char // Get memif details from C-libmemif. errCode := C.govpp_memif_get_details(memif.cHandle, &cDetails, &buf) err = getMemifError(int(errCode)) if err != nil { return nil, err } defer C.fr...
go
func (memif *Memif) GetDetails() (details *MemifDetails, err error) { cDetails := C.govpp_memif_details_t{} var buf *C.char // Get memif details from C-libmemif. errCode := C.govpp_memif_get_details(memif.cHandle, &cDetails, &buf) err = getMemifError(int(errCode)) if err != nil { return nil, err } defer C.fr...
[ "func", "(", "memif", "*", "Memif", ")", "GetDetails", "(", ")", "(", "details", "*", "MemifDetails", ",", "err", "error", ")", "{", "cDetails", ":=", "C", ".", "govpp_memif_details_t", "{", "}", "\n", "var", "buf", "*", "C", ".", "char", "\n\n", "//...
// GetDetails returns a detailed runtime information about this memif. // The method is thread-safe.
[ "GetDetails", "returns", "a", "detailed", "runtime", "information", "about", "this", "memif", ".", "The", "method", "is", "thread", "-", "safe", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/extras/libmemif/adapter.go#L696-L756
134,660
FDio/govpp
extras/libmemif/adapter.go
Close
func (memif *Memif) Close() error { log.WithField("ifName", memif.IfName).Debug("Closing the memif interface") // Delete memif from C-libmemif. err := getMemifError(int(C.memif_delete(&memif.cHandle))) if err != nil { // Close memif-global interrupt channel. close(memif.intCh) // Close file descriptor stopQ...
go
func (memif *Memif) Close() error { log.WithField("ifName", memif.IfName).Debug("Closing the memif interface") // Delete memif from C-libmemif. err := getMemifError(int(C.memif_delete(&memif.cHandle))) if err != nil { // Close memif-global interrupt channel. close(memif.intCh) // Close file descriptor stopQ...
[ "func", "(", "memif", "*", "Memif", ")", "Close", "(", ")", "error", "{", "log", ".", "WithField", "(", "\"", "\"", ",", "memif", ".", "IfName", ")", ".", "Debug", "(", "\"", "\"", ")", "\n\n", "// Delete memif from C-libmemif.", "err", ":=", "getMemif...
// Close removes the memif interface. If the memif is in the connected state, // the connection is first properly closed. // Do not access memif after it is closed, let garbage collector to remove it.
[ "Close", "removes", "the", "memif", "interface", ".", "If", "the", "memif", "is", "in", "the", "connected", "state", "the", "connection", "is", "first", "properly", "closed", ".", "Do", "not", "access", "memif", "after", "it", "is", "closed", "let", "garba...
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/extras/libmemif/adapter.go#L1005-L1025
134,661
FDio/govpp
extras/libmemif/adapter.go
pollEvents
func pollEvents() { defer context.wg.Done() for { errCode := C.memif_poll_event(C.int(-1)) err := getMemifError(int(errCode)) if err == ErrPollCanceled { return } } }
go
func pollEvents() { defer context.wg.Done() for { errCode := C.memif_poll_event(C.int(-1)) err := getMemifError(int(errCode)) if err == ErrPollCanceled { return } } }
[ "func", "pollEvents", "(", ")", "{", "defer", "context", ".", "wg", ".", "Done", "(", ")", "\n", "for", "{", "errCode", ":=", "C", ".", "memif_poll_event", "(", "C", ".", "int", "(", "-", "1", ")", ")", "\n", "err", ":=", "getMemifError", "(", "i...
// pollEvents repeatedly polls for a libmemif event.
[ "pollEvents", "repeatedly", "polls", "for", "a", "libmemif", "event", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/extras/libmemif/adapter.go#L1092-L1101
134,662
FDio/govpp
extras/libmemif/adapter.go
pollRxQueue
func pollRxQueue(memif *Memif, queueID uint8) { defer memif.wg.Done() log.WithFields(logger.Fields{ "ifName": memif.IfName, "queue-ID": queueID, }).Debug("Started queue interrupt polling.") var qfd C.int errCode := C.memif_get_queue_efd(memif.cHandle, C.uint16_t(queueID), &qfd) err := getMemifError(int(er...
go
func pollRxQueue(memif *Memif, queueID uint8) { defer memif.wg.Done() log.WithFields(logger.Fields{ "ifName": memif.IfName, "queue-ID": queueID, }).Debug("Started queue interrupt polling.") var qfd C.int errCode := C.memif_get_queue_efd(memif.cHandle, C.uint16_t(queueID), &qfd) err := getMemifError(int(er...
[ "func", "pollRxQueue", "(", "memif", "*", "Memif", ",", "queueID", "uint8", ")", "{", "defer", "memif", ".", "wg", ".", "Done", "(", ")", "\n\n", "log", ".", "WithFields", "(", "logger", ".", "Fields", "{", "\"", "\"", ":", "memif", ".", "IfName", ...
// pollRxQueue repeatedly polls an Rx queue for interrupts.
[ "pollRxQueue", "repeatedly", "polls", "an", "Rx", "queue", "for", "interrupts", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/extras/libmemif/adapter.go#L1104-L1188
134,663
FDio/govpp
extras/libmemif/examples/icmp-responder/icmp-responder.go
IcmpResponder
func IcmpResponder(memif *libmemif.Memif, queueID uint8) { defer wg.Done() // Get channel which fires every time there are packets to read on the queue. interruptCh, err := memif.GetQueueInterruptChan(queueID) if err != nil { // Example of libmemif error handling code: switch err { case libmemif.ErrQueueID: ...
go
func IcmpResponder(memif *libmemif.Memif, queueID uint8) { defer wg.Done() // Get channel which fires every time there are packets to read on the queue. interruptCh, err := memif.GetQueueInterruptChan(queueID) if err != nil { // Example of libmemif error handling code: switch err { case libmemif.ErrQueueID: ...
[ "func", "IcmpResponder", "(", "memif", "*", "libmemif", ".", "Memif", ",", "queueID", "uint8", ")", "{", "defer", "wg", ".", "Done", "(", ")", "\n\n", "// Get channel which fires every time there are packets to read on the queue.", "interruptCh", ",", "err", ":=", "...
// IcmpResponder answers to ICMP pings with ICMP pongs.
[ "IcmpResponder", "answers", "to", "ICMP", "pings", "with", "ICMP", "pongs", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/extras/libmemif/examples/icmp-responder/icmp-responder.go#L120-L193
134,664
FDio/govpp
extras/libmemif/examples/icmp-responder/icmp-responder.go
DumpPacket
func DumpPacket(packetData libmemif.RawPacketData) { packet := gopacket.NewPacket(packetData, layers.LayerTypeEthernet, gopacket.Default) fmt.Println(packet.Dump()) }
go
func DumpPacket(packetData libmemif.RawPacketData) { packet := gopacket.NewPacket(packetData, layers.LayerTypeEthernet, gopacket.Default) fmt.Println(packet.Dump()) }
[ "func", "DumpPacket", "(", "packetData", "libmemif", ".", "RawPacketData", ")", "{", "packet", ":=", "gopacket", ".", "NewPacket", "(", "packetData", ",", "layers", ".", "LayerTypeEthernet", ",", "gopacket", ".", "Default", ")", "\n", "fmt", ".", "Println", ...
// DumpPacket prints a human-readable description of the packet.
[ "DumpPacket", "prints", "a", "human", "-", "readable", "description", "of", "the", "packet", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/extras/libmemif/examples/icmp-responder/icmp-responder.go#L196-L199
134,665
FDio/govpp
core/channel.go
receiveReplyInternal
func (ch *Channel) receiveReplyInternal(msg api.Message, expSeqNum uint16) (lastReplyReceived bool, err error) { if msg == nil { return false, errors.New("nil message passed in") } var ignore bool if vppReply := ch.delayedReply; vppReply != nil { // try the delayed reply ch.delayedReply = nil ignore, last...
go
func (ch *Channel) receiveReplyInternal(msg api.Message, expSeqNum uint16) (lastReplyReceived bool, err error) { if msg == nil { return false, errors.New("nil message passed in") } var ignore bool if vppReply := ch.delayedReply; vppReply != nil { // try the delayed reply ch.delayedReply = nil ignore, last...
[ "func", "(", "ch", "*", "Channel", ")", "receiveReplyInternal", "(", "msg", "api", ".", "Message", ",", "expSeqNum", "uint16", ")", "(", "lastReplyReceived", "bool", ",", "err", "error", ")", "{", "if", "msg", "==", "nil", "{", "return", "false", ",", ...
// receiveReplyInternal receives a reply from the reply channel into the provided msg structure.
[ "receiveReplyInternal", "receives", "a", "reply", "from", "the", "reply", "channel", "into", "the", "provided", "msg", "structure", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/core/channel.go#L235-L269
134,666
FDio/govpp
adapter/mock/mock_stats_adapter.go
ListStats
func (a *StatsAdapter) ListStats(patterns ...string) ([]string, error) { var statNames []string for _, stat := range a.entries { statNames = append(statNames, stat.Name) } return statNames, nil }
go
func (a *StatsAdapter) ListStats(patterns ...string) ([]string, error) { var statNames []string for _, stat := range a.entries { statNames = append(statNames, stat.Name) } return statNames, nil }
[ "func", "(", "a", "*", "StatsAdapter", ")", "ListStats", "(", "patterns", "...", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "var", "statNames", "[", "]", "string", "\n", "for", "_", ",", "stat", ":=", "range", "a", ".", "entrie...
// ListStats mocks name listing for all stats.
[ "ListStats", "mocks", "name", "listing", "for", "all", "stats", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/adapter/mock/mock_stats_adapter.go#L45-L51
134,667
FDio/govpp
adapter/mock/mock_stats_adapter.go
DumpStats
func (a *StatsAdapter) DumpStats(patterns ...string) ([]*adapter.StatEntry, error) { return a.entries, nil }
go
func (a *StatsAdapter) DumpStats(patterns ...string) ([]*adapter.StatEntry, error) { return a.entries, nil }
[ "func", "(", "a", "*", "StatsAdapter", ")", "DumpStats", "(", "patterns", "...", "string", ")", "(", "[", "]", "*", "adapter", ".", "StatEntry", ",", "error", ")", "{", "return", "a", ".", "entries", ",", "nil", "\n", "}" ]
// DumpStats mocks all stat entries dump.
[ "DumpStats", "mocks", "all", "stat", "entries", "dump", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/adapter/mock/mock_stats_adapter.go#L54-L56
134,668
FDio/govpp
cmd/binapi-generator/types.go
convertToGoType
func convertToGoType(ctx *context, binapiType string) (typ string) { if t, ok := binapiTypes[binapiType]; ok { // basic types typ = t } else if r, ok := ctx.packageData.RefMap[binapiType]; ok { // specific types (enums/types/unions) typ = camelCaseName(r) } else { switch binapiType { case "bool", "string...
go
func convertToGoType(ctx *context, binapiType string) (typ string) { if t, ok := binapiTypes[binapiType]; ok { // basic types typ = t } else if r, ok := ctx.packageData.RefMap[binapiType]; ok { // specific types (enums/types/unions) typ = camelCaseName(r) } else { switch binapiType { case "bool", "string...
[ "func", "convertToGoType", "(", "ctx", "*", "context", ",", "binapiType", "string", ")", "(", "typ", "string", ")", "{", "if", "t", ",", "ok", ":=", "binapiTypes", "[", "binapiType", "]", ";", "ok", "{", "// basic types", "typ", "=", "t", "\n", "}", ...
// convertToGoType translates the VPP binary API type into Go type
[ "convertToGoType", "translates", "the", "VPP", "binary", "API", "type", "into", "Go", "type" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/cmd/binapi-generator/types.go#L52-L70
134,669
FDio/govpp
cmd/binapi-generator/parse.go
printPackage
func printPackage(pkg *Package) { if len(pkg.Enums) > 0 { logf("loaded %d enums:", len(pkg.Enums)) for k, enum := range pkg.Enums { logf(" - enum #%d\t%+v", k, enum) } } if len(pkg.Unions) > 0 { logf("loaded %d unions:", len(pkg.Unions)) for k, union := range pkg.Unions { logf(" - union #%d\t%+v", k,...
go
func printPackage(pkg *Package) { if len(pkg.Enums) > 0 { logf("loaded %d enums:", len(pkg.Enums)) for k, enum := range pkg.Enums { logf(" - enum #%d\t%+v", k, enum) } } if len(pkg.Unions) > 0 { logf("loaded %d unions:", len(pkg.Unions)) for k, union := range pkg.Unions { logf(" - union #%d\t%+v", k,...
[ "func", "printPackage", "(", "pkg", "*", "Package", ")", "{", "if", "len", "(", "pkg", ".", "Enums", ")", ">", "0", "{", "logf", "(", "\"", "\"", ",", "len", "(", "pkg", ".", "Enums", ")", ")", "\n", "for", "k", ",", "enum", ":=", "range", "p...
// printPackage prints all loaded objects for package
[ "printPackage", "prints", "all", "loaded", "objects", "for", "package" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/cmd/binapi-generator/parse.go#L200-L237
134,670
FDio/govpp
cmd/binapi-generator/parse.go
parseEnum
func parseEnum(ctx *context, enumNode *jsongo.JSONNode) (*Enum, error) { if enumNode.Len() == 0 || enumNode.At(0).GetType() != jsongo.TypeValue { return nil, errors.New("invalid JSON for enum specified") } enumName, ok := enumNode.At(0).Get().(string) if !ok { return nil, fmt.Errorf("enum name is %T, not a str...
go
func parseEnum(ctx *context, enumNode *jsongo.JSONNode) (*Enum, error) { if enumNode.Len() == 0 || enumNode.At(0).GetType() != jsongo.TypeValue { return nil, errors.New("invalid JSON for enum specified") } enumName, ok := enumNode.At(0).Get().(string) if !ok { return nil, fmt.Errorf("enum name is %T, not a str...
[ "func", "parseEnum", "(", "ctx", "*", "context", ",", "enumNode", "*", "jsongo", ".", "JSONNode", ")", "(", "*", "Enum", ",", "error", ")", "{", "if", "enumNode", ".", "Len", "(", ")", "==", "0", "||", "enumNode", ".", "At", "(", "0", ")", ".", ...
// parseEnum parses VPP binary API enum object from JSON node
[ "parseEnum", "parses", "VPP", "binary", "API", "enum", "object", "from", "JSON", "node" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/cmd/binapi-generator/parse.go#L240-L282
134,671
FDio/govpp
cmd/binapi-generator/parse.go
parseUnion
func parseUnion(ctx *context, unionNode *jsongo.JSONNode) (*Union, error) { if unionNode.Len() == 0 || unionNode.At(0).GetType() != jsongo.TypeValue { return nil, errors.New("invalid JSON for union specified") } unionName, ok := unionNode.At(0).Get().(string) if !ok { return nil, fmt.Errorf("union name is %T, ...
go
func parseUnion(ctx *context, unionNode *jsongo.JSONNode) (*Union, error) { if unionNode.Len() == 0 || unionNode.At(0).GetType() != jsongo.TypeValue { return nil, errors.New("invalid JSON for union specified") } unionName, ok := unionNode.At(0).Get().(string) if !ok { return nil, fmt.Errorf("union name is %T, ...
[ "func", "parseUnion", "(", "ctx", "*", "context", ",", "unionNode", "*", "jsongo", ".", "JSONNode", ")", "(", "*", "Union", ",", "error", ")", "{", "if", "unionNode", ".", "Len", "(", ")", "==", "0", "||", "unionNode", ".", "At", "(", "0", ")", "...
// parseUnion parses VPP binary API union object from JSON node
[ "parseUnion", "parses", "VPP", "binary", "API", "union", "object", "from", "JSON", "node" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/cmd/binapi-generator/parse.go#L285-L319
134,672
FDio/govpp
cmd/binapi-generator/parse.go
parseType
func parseType(ctx *context, typeNode *jsongo.JSONNode) (*Type, error) { if typeNode.Len() == 0 || typeNode.At(0).GetType() != jsongo.TypeValue { return nil, errors.New("invalid JSON for type specified") } typeName, ok := typeNode.At(0).Get().(string) if !ok { return nil, fmt.Errorf("type name is %T, not a str...
go
func parseType(ctx *context, typeNode *jsongo.JSONNode) (*Type, error) { if typeNode.Len() == 0 || typeNode.At(0).GetType() != jsongo.TypeValue { return nil, errors.New("invalid JSON for type specified") } typeName, ok := typeNode.At(0).Get().(string) if !ok { return nil, fmt.Errorf("type name is %T, not a str...
[ "func", "parseType", "(", "ctx", "*", "context", ",", "typeNode", "*", "jsongo", ".", "JSONNode", ")", "(", "*", "Type", ",", "error", ")", "{", "if", "typeNode", ".", "Len", "(", ")", "==", "0", "||", "typeNode", ".", "At", "(", "0", ")", ".", ...
// parseType parses VPP binary API type object from JSON node
[ "parseType", "parses", "VPP", "binary", "API", "type", "object", "from", "JSON", "node" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/cmd/binapi-generator/parse.go#L322-L356
134,673
FDio/govpp
cmd/binapi-generator/parse.go
parseAlias
func parseAlias(ctx *context, aliasName string, aliasNode *jsongo.JSONNode) (*Alias, error) { if aliasNode.Len() == 0 || aliasNode.At(aliasTypeField).GetType() != jsongo.TypeValue { return nil, errors.New("invalid JSON for alias specified") } alias := Alias{ Name: aliasName, } if typeNode := aliasNode.At(ali...
go
func parseAlias(ctx *context, aliasName string, aliasNode *jsongo.JSONNode) (*Alias, error) { if aliasNode.Len() == 0 || aliasNode.At(aliasTypeField).GetType() != jsongo.TypeValue { return nil, errors.New("invalid JSON for alias specified") } alias := Alias{ Name: aliasName, } if typeNode := aliasNode.At(ali...
[ "func", "parseAlias", "(", "ctx", "*", "context", ",", "aliasName", "string", ",", "aliasNode", "*", "jsongo", ".", "JSONNode", ")", "(", "*", "Alias", ",", "error", ")", "{", "if", "aliasNode", ".", "Len", "(", ")", "==", "0", "||", "aliasNode", "."...
// parseAlias parses VPP binary API alias object from JSON node
[ "parseAlias", "parses", "VPP", "binary", "API", "alias", "object", "from", "JSON", "node" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/cmd/binapi-generator/parse.go#L359-L387
134,674
FDio/govpp
cmd/binapi-generator/parse.go
parseMessage
func parseMessage(ctx *context, msgNode *jsongo.JSONNode) (*Message, error) { if msgNode.Len() == 0 || msgNode.At(0).GetType() != jsongo.TypeValue { return nil, errors.New("invalid JSON for message specified") } msgName, ok := msgNode.At(0).Get().(string) if !ok { return nil, fmt.Errorf("message name is %T, no...
go
func parseMessage(ctx *context, msgNode *jsongo.JSONNode) (*Message, error) { if msgNode.Len() == 0 || msgNode.At(0).GetType() != jsongo.TypeValue { return nil, errors.New("invalid JSON for message specified") } msgName, ok := msgNode.At(0).Get().(string) if !ok { return nil, fmt.Errorf("message name is %T, no...
[ "func", "parseMessage", "(", "ctx", "*", "context", ",", "msgNode", "*", "jsongo", ".", "JSONNode", ")", "(", "*", "Message", ",", "error", ")", "{", "if", "msgNode", ".", "Len", "(", ")", "==", "0", "||", "msgNode", ".", "At", "(", "0", ")", "."...
// parseMessage parses VPP binary API message object from JSON node
[ "parseMessage", "parses", "VPP", "binary", "API", "message", "object", "from", "JSON", "node" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/cmd/binapi-generator/parse.go#L390-L425
134,675
FDio/govpp
cmd/binapi-generator/parse.go
parseField
func parseField(ctx *context, field *jsongo.JSONNode) (*Field, error) { if field.Len() < 2 || field.At(0).GetType() != jsongo.TypeValue || field.At(1).GetType() != jsongo.TypeValue { return nil, errors.New("invalid JSON for field specified") } fieldType, ok := field.At(0).Get().(string) if !ok { return nil, fm...
go
func parseField(ctx *context, field *jsongo.JSONNode) (*Field, error) { if field.Len() < 2 || field.At(0).GetType() != jsongo.TypeValue || field.At(1).GetType() != jsongo.TypeValue { return nil, errors.New("invalid JSON for field specified") } fieldType, ok := field.At(0).Get().(string) if !ok { return nil, fm...
[ "func", "parseField", "(", "ctx", "*", "context", ",", "field", "*", "jsongo", ".", "JSONNode", ")", "(", "*", "Field", ",", "error", ")", "{", "if", "field", ".", "Len", "(", ")", "<", "2", "||", "field", ".", "At", "(", "0", ")", ".", "GetTyp...
// parseField parses VPP binary API object field from JSON node
[ "parseField", "parses", "VPP", "binary", "API", "object", "field", "from", "JSON", "node" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/cmd/binapi-generator/parse.go#L428-L462
134,676
FDio/govpp
cmd/binapi-generator/parse.go
parseService
func parseService(ctx *context, svcName string, svcNode *jsongo.JSONNode) (*Service, error) { if svcNode.Len() == 0 || svcNode.At(replyField).GetType() != jsongo.TypeValue { return nil, errors.New("invalid JSON for service specified") } svc := Service{ Name: ctx.moduleName + "." + svcName, RequestType:...
go
func parseService(ctx *context, svcName string, svcNode *jsongo.JSONNode) (*Service, error) { if svcNode.Len() == 0 || svcNode.At(replyField).GetType() != jsongo.TypeValue { return nil, errors.New("invalid JSON for service specified") } svc := Service{ Name: ctx.moduleName + "." + svcName, RequestType:...
[ "func", "parseService", "(", "ctx", "*", "context", ",", "svcName", "string", ",", "svcNode", "*", "jsongo", ".", "JSONNode", ")", "(", "*", "Service", ",", "error", ")", "{", "if", "svcNode", ".", "Len", "(", ")", "==", "0", "||", "svcNode", ".", ...
// parseService parses VPP binary API service object from JSON node
[ "parseService", "parses", "VPP", "binary", "API", "service", "object", "from", "JSON", "node" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/cmd/binapi-generator/parse.go#L465-L529
134,677
FDio/govpp
adapter/socketclient/socketclient.go
WaitReady
func (c *vppClient) WaitReady() error { // check if file at the path already exists if _, err := os.Stat(c.sockAddr); err == nil { return nil } else if os.IsExist(err) { return err } // if not, watch for it watcher, err := fsnotify.NewWatcher() if err != nil { return err } defer func() { if err := wat...
go
func (c *vppClient) WaitReady() error { // check if file at the path already exists if _, err := os.Stat(c.sockAddr); err == nil { return nil } else if os.IsExist(err) { return err } // if not, watch for it watcher, err := fsnotify.NewWatcher() if err != nil { return err } defer func() { if err := wat...
[ "func", "(", "c", "*", "vppClient", ")", "WaitReady", "(", ")", "error", "{", "// check if file at the path already exists", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "c", ".", "sockAddr", ")", ";", "err", "==", "nil", "{", "return", "nil", ...
// WaitReady checks socket file existence and waits for it if necessary
[ "WaitReady", "checks", "socket", "file", "existence", "and", "waits", "for", "it", "if", "necessary" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/adapter/socketclient/socketclient.go#L102-L142
134,678
FDio/govpp
examples/simple-client/simple_client.go
aclVersion
func aclVersion(ch api.Channel) { fmt.Println("ACL getting version") req := &acl.ACLPluginGetVersion{} reply := &acl.ACLPluginGetVersionReply{} if err := ch.SendRequest(req).ReceiveReply(reply); err != nil { fmt.Println("ERROR:", err) } else { fmt.Printf("ACL version reply: %+v\n", reply) } }
go
func aclVersion(ch api.Channel) { fmt.Println("ACL getting version") req := &acl.ACLPluginGetVersion{} reply := &acl.ACLPluginGetVersionReply{} if err := ch.SendRequest(req).ReceiveReply(reply); err != nil { fmt.Println("ERROR:", err) } else { fmt.Printf("ACL version reply: %+v\n", reply) } }
[ "func", "aclVersion", "(", "ch", "api", ".", "Channel", ")", "{", "fmt", ".", "Println", "(", "\"", "\"", ")", "\n\n", "req", ":=", "&", "acl", ".", "ACLPluginGetVersion", "{", "}", "\n", "reply", ":=", "&", "acl", ".", "ACLPluginGetVersionReply", "{",...
// aclVersion is the simplest API example - one empty request message and one reply message.
[ "aclVersion", "is", "the", "simplest", "API", "example", "-", "one", "empty", "request", "message", "and", "one", "reply", "message", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/examples/simple-client/simple_client.go#L73-L84
134,679
FDio/govpp
examples/simple-client/simple_client.go
aclConfig
func aclConfig(ch api.Channel) { fmt.Println("ACL adding replace") req := &acl.ACLAddReplace{ ACLIndex: ^uint32(0), Tag: []byte("access list 1"), R: []acl.ACLRule{ { IsPermit: 1, SrcIPAddr: net.ParseIP("10.0.0.0").To4(), SrcIPPrefixLen: 8, DstIPAddr: net.ParseIP("192.168...
go
func aclConfig(ch api.Channel) { fmt.Println("ACL adding replace") req := &acl.ACLAddReplace{ ACLIndex: ^uint32(0), Tag: []byte("access list 1"), R: []acl.ACLRule{ { IsPermit: 1, SrcIPAddr: net.ParseIP("10.0.0.0").To4(), SrcIPPrefixLen: 8, DstIPAddr: net.ParseIP("192.168...
[ "func", "aclConfig", "(", "ch", "api", ".", "Channel", ")", "{", "fmt", ".", "Println", "(", "\"", "\"", ")", "\n\n", "req", ":=", "&", "acl", ".", "ACLAddReplace", "{", "ACLIndex", ":", "^", "uint32", "(", "0", ")", ",", "Tag", ":", "[", "]", ...
// aclConfig is another simple API example - in this case, the request contains structured data.
[ "aclConfig", "is", "another", "simple", "API", "example", "-", "in", "this", "case", "the", "request", "contains", "structured", "data", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/examples/simple-client/simple_client.go#L87-L125
134,680
FDio/govpp
examples/simple-client/simple_client.go
interfaceNotifications
func interfaceNotifications(ch api.Channel) { fmt.Println("Subscribing to notificaiton events") notifChan := make(chan api.Message, 100) // subscribe for specific notification message sub, err := ch.SubscribeNotification(notifChan, &interfaces.SwInterfaceEvent{}) if err != nil { panic(err) } // enable inter...
go
func interfaceNotifications(ch api.Channel) { fmt.Println("Subscribing to notificaiton events") notifChan := make(chan api.Message, 100) // subscribe for specific notification message sub, err := ch.SubscribeNotification(notifChan, &interfaces.SwInterfaceEvent{}) if err != nil { panic(err) } // enable inter...
[ "func", "interfaceNotifications", "(", "ch", "api", ".", "Channel", ")", "{", "fmt", ".", "Println", "(", "\"", "\"", ")", "\n\n", "notifChan", ":=", "make", "(", "chan", "api", ".", "Message", ",", "100", ")", "\n\n", "// subscribe for specific notification...
// interfaceNotifications shows the usage of notification API. Note that for notifications, // you are supposed to create your own Go channel with your preferred buffer size. If the channel's // buffer is full, the notifications will not be delivered into it.
[ "interfaceNotifications", "shows", "the", "usage", "of", "notification", "API", ".", "Note", "that", "for", "notifications", "you", "are", "supposed", "to", "create", "your", "own", "Go", "channel", "with", "your", "preferred", "buffer", "size", ".", "If", "th...
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/examples/simple-client/simple_client.go#L225-L279
134,681
FDio/govpp
cmd/binapi-generator/main.go
getInputFiles
func getInputFiles(inputDir string) (res []string, err error) { files, err := ioutil.ReadDir(inputDir) if err != nil { return nil, fmt.Errorf("reading directory %s failed: %v", inputDir, err) } for _, f := range files { if strings.HasSuffix(f.Name(), inputFileExt) { res = append(res, filepath.Join(inputDir, ...
go
func getInputFiles(inputDir string) (res []string, err error) { files, err := ioutil.ReadDir(inputDir) if err != nil { return nil, fmt.Errorf("reading directory %s failed: %v", inputDir, err) } for _, f := range files { if strings.HasSuffix(f.Name(), inputFileExt) { res = append(res, filepath.Join(inputDir, ...
[ "func", "getInputFiles", "(", "inputDir", "string", ")", "(", "res", "[", "]", "string", ",", "err", "error", ")", "{", "files", ",", "err", ":=", "ioutil", ".", "ReadDir", "(", "inputDir", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ...
// getInputFiles returns all input files located in specified directory
[ "getInputFiles", "returns", "all", "input", "files", "located", "in", "specified", "directory" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/cmd/binapi-generator/main.go#L85-L96
134,682
FDio/govpp
cmd/binapi-generator/main.go
generateFromFile
func generateFromFile(inputFile, outputDir string) error { logf("generating from file: %q", inputFile) defer logf("--------------------------------------") ctx, err := getContext(inputFile, outputDir) if err != nil { return err } ctx.includeAPIVersionCrc = *includeAPIVer ctx.includeComments = *includeComment...
go
func generateFromFile(inputFile, outputDir string) error { logf("generating from file: %q", inputFile) defer logf("--------------------------------------") ctx, err := getContext(inputFile, outputDir) if err != nil { return err } ctx.includeAPIVersionCrc = *includeAPIVer ctx.includeComments = *includeComment...
[ "func", "generateFromFile", "(", "inputFile", ",", "outputDir", "string", ")", "error", "{", "logf", "(", "\"", "\"", ",", "inputFile", ")", "\n", "defer", "logf", "(", "\"", "\"", ")", "\n\n", "ctx", ",", "err", ":=", "getContext", "(", "inputFile", "...
// generateFromFile generates Go package from one input JSON file
[ "generateFromFile", "generates", "Go", "package", "from", "one", "input", "JSON", "file" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/cmd/binapi-generator/main.go#L99-L159
134,683
FDio/govpp
cmd/binapi-generator/main.go
readFile
func readFile(inputFile string) ([]byte, error) { inputData, err := ioutil.ReadFile(inputFile) if err != nil { return nil, fmt.Errorf("reading data from file failed: %v", err) } return inputData, nil }
go
func readFile(inputFile string) ([]byte, error) { inputData, err := ioutil.ReadFile(inputFile) if err != nil { return nil, fmt.Errorf("reading data from file failed: %v", err) } return inputData, nil }
[ "func", "readFile", "(", "inputFile", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "inputData", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "inputFile", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", "...
// readFile reads content of a file into memory
[ "readFile", "reads", "content", "of", "a", "file", "into", "memory" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/cmd/binapi-generator/main.go#L162-L169
134,684
FDio/govpp
cmd/binapi-generator/main.go
parseJSON
func parseJSON(inputData []byte) (*jsongo.JSONNode, error) { root := jsongo.JSONNode{} if err := json.Unmarshal(inputData, &root); err != nil { return nil, fmt.Errorf("unmarshalling JSON failed: %v", err) } return &root, nil }
go
func parseJSON(inputData []byte) (*jsongo.JSONNode, error) { root := jsongo.JSONNode{} if err := json.Unmarshal(inputData, &root); err != nil { return nil, fmt.Errorf("unmarshalling JSON failed: %v", err) } return &root, nil }
[ "func", "parseJSON", "(", "inputData", "[", "]", "byte", ")", "(", "*", "jsongo", ".", "JSONNode", ",", "error", ")", "{", "root", ":=", "jsongo", ".", "JSONNode", "{", "}", "\n\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "inputData", ",", ...
// parseJSON parses a JSON data into an in-memory tree
[ "parseJSON", "parses", "a", "JSON", "data", "into", "an", "in", "-", "memory", "tree" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/cmd/binapi-generator/main.go#L172-L180
134,685
FDio/govpp
adapter/mock/mock_vpp_adapter.go
NewVppAdapter
func NewVppAdapter() *VppAdapter { a := &VppAdapter{ msgIDSeq: 1000, msgIDsToName: make(map[uint16]string), msgNameToIds: make(map[string]uint16), binAPITypes: make(map[string]reflect.Type), } a.registerBinAPITypes() return a }
go
func NewVppAdapter() *VppAdapter { a := &VppAdapter{ msgIDSeq: 1000, msgIDsToName: make(map[uint16]string), msgNameToIds: make(map[string]uint16), binAPITypes: make(map[string]reflect.Type), } a.registerBinAPITypes() return a }
[ "func", "NewVppAdapter", "(", ")", "*", "VppAdapter", "{", "a", ":=", "&", "VppAdapter", "{", "msgIDSeq", ":", "1000", ",", "msgIDsToName", ":", "make", "(", "map", "[", "uint16", "]", "string", ")", ",", "msgNameToIds", ":", "make", "(", "map", "[", ...
// NewVppAdapter returns a new mock adapter.
[ "NewVppAdapter", "returns", "a", "new", "mock", "adapter", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/adapter/mock/mock_vpp_adapter.go#L93-L102
134,686
FDio/govpp
adapter/mock/mock_vpp_adapter.go
GetMsgNameByID
func (a *VppAdapter) GetMsgNameByID(msgID uint16) (string, bool) { switch msgID { case 100: return "control_ping", true case 101: return "control_ping_reply", true case 200: return "sw_interface_dump", true case 201: return "sw_interface_details", true } a.access.Lock() defer a.access.Unlock() msgName...
go
func (a *VppAdapter) GetMsgNameByID(msgID uint16) (string, bool) { switch msgID { case 100: return "control_ping", true case 101: return "control_ping_reply", true case 200: return "sw_interface_dump", true case 201: return "sw_interface_details", true } a.access.Lock() defer a.access.Unlock() msgName...
[ "func", "(", "a", "*", "VppAdapter", ")", "GetMsgNameByID", "(", "msgID", "uint16", ")", "(", "string", ",", "bool", ")", "{", "switch", "msgID", "{", "case", "100", ":", "return", "\"", "\"", ",", "true", "\n", "case", "101", ":", "return", "\"", ...
// GetMsgNameByID returns message name for specified message ID.
[ "GetMsgNameByID", "returns", "message", "name", "for", "specified", "message", "ID", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/adapter/mock/mock_vpp_adapter.go#L115-L132
134,687
FDio/govpp
adapter/mock/mock_vpp_adapter.go
ReplyTypeFor
func (a *VppAdapter) ReplyTypeFor(requestMsgName string) (reflect.Type, uint16, bool) { replyName, foundName := binapi.ReplyNameFor(requestMsgName) if foundName { if reply, found := a.binAPITypes[replyName]; found { msgID, err := a.GetMsgID(replyName, "") if err == nil { return reply, msgID, found } ...
go
func (a *VppAdapter) ReplyTypeFor(requestMsgName string) (reflect.Type, uint16, bool) { replyName, foundName := binapi.ReplyNameFor(requestMsgName) if foundName { if reply, found := a.binAPITypes[replyName]; found { msgID, err := a.GetMsgID(replyName, "") if err == nil { return reply, msgID, found } ...
[ "func", "(", "a", "*", "VppAdapter", ")", "ReplyTypeFor", "(", "requestMsgName", "string", ")", "(", "reflect", ".", "Type", ",", "uint16", ",", "bool", ")", "{", "replyName", ",", "foundName", ":=", "binapi", ".", "ReplyNameFor", "(", "requestMsgName", ")...
// ReplyTypeFor returns reply message type for given request message name.
[ "ReplyTypeFor", "returns", "reply", "message", "type", "for", "given", "request", "message", "name", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/adapter/mock/mock_vpp_adapter.go#L143-L155
134,688
FDio/govpp
adapter/mock/mock_vpp_adapter.go
ReplyFor
func (a *VppAdapter) ReplyFor(requestMsgName string) (api.Message, uint16, bool) { replType, msgID, foundReplType := a.ReplyTypeFor(requestMsgName) if foundReplType { msgVal := reflect.New(replType) if msg, ok := msgVal.Interface().(api.Message); ok { log.Println("FFF ", replType, msgID, foundReplType) retu...
go
func (a *VppAdapter) ReplyFor(requestMsgName string) (api.Message, uint16, bool) { replType, msgID, foundReplType := a.ReplyTypeFor(requestMsgName) if foundReplType { msgVal := reflect.New(replType) if msg, ok := msgVal.Interface().(api.Message); ok { log.Println("FFF ", replType, msgID, foundReplType) retu...
[ "func", "(", "a", "*", "VppAdapter", ")", "ReplyFor", "(", "requestMsgName", "string", ")", "(", "api", ".", "Message", ",", "uint16", ",", "bool", ")", "{", "replType", ",", "msgID", ",", "foundReplType", ":=", "a", ".", "ReplyTypeFor", "(", "requestMsg...
// ReplyFor returns reply message for given request message name.
[ "ReplyFor", "returns", "reply", "message", "for", "given", "request", "message", "name", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/adapter/mock/mock_vpp_adapter.go#L158-L169
134,689
FDio/govpp
adapter/mock/mock_vpp_adapter.go
ReplyBytes
func (a *VppAdapter) ReplyBytes(request MessageDTO, reply api.Message) ([]byte, error) { replyMsgID, err := a.GetMsgID(reply.GetMessageName(), reply.GetCrcString()) if err != nil { log.Println("ReplyBytesE ", replyMsgID, " ", reply.GetMessageName(), " clientId: ", request.ClientID, " ", err) return nil, err }...
go
func (a *VppAdapter) ReplyBytes(request MessageDTO, reply api.Message) ([]byte, error) { replyMsgID, err := a.GetMsgID(reply.GetMessageName(), reply.GetCrcString()) if err != nil { log.Println("ReplyBytesE ", replyMsgID, " ", reply.GetMessageName(), " clientId: ", request.ClientID, " ", err) return nil, err }...
[ "func", "(", "a", "*", "VppAdapter", ")", "ReplyBytes", "(", "request", "MessageDTO", ",", "reply", "api", ".", "Message", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "replyMsgID", ",", "err", ":=", "a", ".", "GetMsgID", "(", "reply", ".", ...
// ReplyBytes encodes the mocked reply into binary format.
[ "ReplyBytes", "encodes", "the", "mocked", "reply", "into", "binary", "format", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/adapter/mock/mock_vpp_adapter.go#L172-L194
134,690
FDio/govpp
adapter/mock/mock_vpp_adapter.go
GetMsgID
func (a *VppAdapter) GetMsgID(msgName string, msgCrc string) (uint16, error) { switch msgName { case "control_ping": return 100, nil case "control_ping_reply": return 101, nil case "sw_interface_dump": return 200, nil case "sw_interface_details": return 201, nil } a.access.Lock() defer a.access.Unlock(...
go
func (a *VppAdapter) GetMsgID(msgName string, msgCrc string) (uint16, error) { switch msgName { case "control_ping": return 100, nil case "control_ping_reply": return 101, nil case "sw_interface_dump": return 200, nil case "sw_interface_details": return 201, nil } a.access.Lock() defer a.access.Unlock(...
[ "func", "(", "a", "*", "VppAdapter", ")", "GetMsgID", "(", "msgName", "string", ",", "msgCrc", "string", ")", "(", "uint16", ",", "error", ")", "{", "switch", "msgName", "{", "case", "\"", "\"", ":", "return", "100", ",", "nil", "\n", "case", "\"", ...
// GetMsgID returns mocked message ID for the given message name and CRC.
[ "GetMsgID", "returns", "mocked", "message", "ID", "for", "the", "given", "message", "name", "and", "CRC", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/adapter/mock/mock_vpp_adapter.go#L197-L223
134,691
FDio/govpp
adapter/mock/mock_vpp_adapter.go
MockReplyHandler
func (a *VppAdapter) MockReplyHandler(replyHandler ReplyHandler) { a.repliesLock.Lock() defer a.repliesLock.Unlock() a.replyHandlers = append(a.replyHandlers, replyHandler) a.mode = useReplyHandlers }
go
func (a *VppAdapter) MockReplyHandler(replyHandler ReplyHandler) { a.repliesLock.Lock() defer a.repliesLock.Unlock() a.replyHandlers = append(a.replyHandlers, replyHandler) a.mode = useReplyHandlers }
[ "func", "(", "a", "*", "VppAdapter", ")", "MockReplyHandler", "(", "replyHandler", "ReplyHandler", ")", "{", "a", ".", "repliesLock", ".", "Lock", "(", ")", "\n", "defer", "a", ".", "repliesLock", ".", "Unlock", "(", ")", "\n\n", "a", ".", "replyHandlers...
// MockReplyHandler registers a handler function that is supposed to generate mock responses to incoming requests. // Using of this method automatically switches the mock into th useReplyHandlers mode.
[ "MockReplyHandler", "registers", "a", "handler", "function", "that", "is", "supposed", "to", "generate", "mock", "responses", "to", "incoming", "requests", ".", "Using", "of", "this", "method", "automatically", "switches", "the", "mock", "into", "th", "useReplyHan...
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/adapter/mock/mock_vpp_adapter.go#L367-L373
134,692
FDio/govpp
extras/libmemif/examples/gopacket/gopacket.go
OnInterrupt
func OnInterrupt(handle *libmemif.MemifPacketHandle) { source := gopacket.NewPacketSource(handle, layers.LayerTypeEthernet) var responses []gopacket.Packet // Process ICMP pings for packet := range source.Packets() { fmt.Println("Received new packet:") fmt.Println(packet.Dump()) response, err := GeneratePac...
go
func OnInterrupt(handle *libmemif.MemifPacketHandle) { source := gopacket.NewPacketSource(handle, layers.LayerTypeEthernet) var responses []gopacket.Packet // Process ICMP pings for packet := range source.Packets() { fmt.Println("Received new packet:") fmt.Println(packet.Dump()) response, err := GeneratePac...
[ "func", "OnInterrupt", "(", "handle", "*", "libmemif", ".", "MemifPacketHandle", ")", "{", "source", ":=", "gopacket", ".", "NewPacketSource", "(", "handle", ",", "layers", ".", "LayerTypeEthernet", ")", "\n", "var", "responses", "[", "]", "gopacket", ".", "...
// OnInterrupt is called when interrupted
[ "OnInterrupt", "is", "called", "when", "interrupted" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/extras/libmemif/examples/gopacket/gopacket.go#L107-L140
134,693
FDio/govpp
extras/libmemif/examples/gopacket/gopacket.go
CreateInterruptCallback
func CreateInterruptCallback(handle *libmemif.MemifPacketHandle, interruptCh <-chan struct{}, callback func(handle *libmemif.MemifPacketHandle)) { for { select { case <-interruptCh: callback(handle) case <-stopCh: handle.Close() return } } }
go
func CreateInterruptCallback(handle *libmemif.MemifPacketHandle, interruptCh <-chan struct{}, callback func(handle *libmemif.MemifPacketHandle)) { for { select { case <-interruptCh: callback(handle) case <-stopCh: handle.Close() return } } }
[ "func", "CreateInterruptCallback", "(", "handle", "*", "libmemif", ".", "MemifPacketHandle", ",", "interruptCh", "<-", "chan", "struct", "{", "}", ",", "callback", "func", "(", "handle", "*", "libmemif", ".", "MemifPacketHandle", ")", ")", "{", "for", "{", "...
// Creates user-friendly memif interrupt callback
[ "Creates", "user", "-", "friendly", "memif", "interrupt", "callback" ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/extras/libmemif/examples/gopacket/gopacket.go#L143-L153
134,694
FDio/govpp
core/connection.go
Connect
func Connect(binapi adapter.VppAPI) (*Connection, error) { // create new connection handle c := newConnection(binapi, DefaultMaxReconnectAttempts, DefaultReconnectInterval) // blocking attempt to connect to VPP if err := c.connectVPP(); err != nil { return nil, err } return c, nil }
go
func Connect(binapi adapter.VppAPI) (*Connection, error) { // create new connection handle c := newConnection(binapi, DefaultMaxReconnectAttempts, DefaultReconnectInterval) // blocking attempt to connect to VPP if err := c.connectVPP(); err != nil { return nil, err } return c, nil }
[ "func", "Connect", "(", "binapi", "adapter", ".", "VppAPI", ")", "(", "*", "Connection", ",", "error", ")", "{", "// create new connection handle", "c", ":=", "newConnection", "(", "binapi", ",", "DefaultMaxReconnectAttempts", ",", "DefaultReconnectInterval", ")", ...
// Connect connects to VPP API using specified adapter and returns a connection handle. // This call blocks until it is either connected, or an error occurs. // Only one connection attempt will be performed.
[ "Connect", "connects", "to", "VPP", "API", "using", "specified", "adapter", "and", "returns", "a", "connection", "handle", ".", "This", "call", "blocks", "until", "it", "is", "either", "connected", "or", "an", "error", "occurs", ".", "Only", "one", "connecti...
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/core/connection.go#L142-L152
134,695
FDio/govpp
core/connection.go
connectVPP
func (c *Connection) connectVPP() error { log.Debug("Connecting to VPP..") // blocking connect if err := c.vppClient.Connect(); err != nil { return err } log.Debugf("Connected to VPP.") if err := c.retrieveMessageIDs(); err != nil { c.vppClient.Disconnect() return fmt.Errorf("VPP is incompatible: %v", er...
go
func (c *Connection) connectVPP() error { log.Debug("Connecting to VPP..") // blocking connect if err := c.vppClient.Connect(); err != nil { return err } log.Debugf("Connected to VPP.") if err := c.retrieveMessageIDs(); err != nil { c.vppClient.Disconnect() return fmt.Errorf("VPP is incompatible: %v", er...
[ "func", "(", "c", "*", "Connection", ")", "connectVPP", "(", ")", "error", "{", "log", ".", "Debug", "(", "\"", "\"", ")", "\n\n", "// blocking connect", "if", "err", ":=", "c", ".", "vppClient", ".", "Connect", "(", ")", ";", "err", "!=", "nil", "...
// connectVPP performs blocking attempt to connect to VPP.
[ "connectVPP", "performs", "blocking", "attempt", "to", "connect", "to", "VPP", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/core/connection.go#L170-L189
134,696
FDio/govpp
core/connection.go
Disconnect
func (c *Connection) Disconnect() { if c == nil { return } if c.vppClient != nil { c.disconnectVPP() } }
go
func (c *Connection) Disconnect() { if c == nil { return } if c.vppClient != nil { c.disconnectVPP() } }
[ "func", "(", "c", "*", "Connection", ")", "Disconnect", "(", ")", "{", "if", "c", "==", "nil", "{", "return", "\n", "}", "\n\n", "if", "c", ".", "vppClient", "!=", "nil", "{", "c", ".", "disconnectVPP", "(", ")", "\n", "}", "\n", "}" ]
// Disconnect disconnects from VPP API and releases all connection-related resources.
[ "Disconnect", "disconnects", "from", "VPP", "API", "and", "releases", "all", "connection", "-", "related", "resources", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/core/connection.go#L192-L200
134,697
FDio/govpp
core/connection.go
disconnectVPP
func (c *Connection) disconnectVPP() { if atomic.CompareAndSwapUint32(&c.vppConnected, 1, 0) { c.vppClient.Disconnect() } }
go
func (c *Connection) disconnectVPP() { if atomic.CompareAndSwapUint32(&c.vppConnected, 1, 0) { c.vppClient.Disconnect() } }
[ "func", "(", "c", "*", "Connection", ")", "disconnectVPP", "(", ")", "{", "if", "atomic", ".", "CompareAndSwapUint32", "(", "&", "c", ".", "vppConnected", ",", "1", ",", "0", ")", "{", "c", ".", "vppClient", ".", "Disconnect", "(", ")", "\n", "}", ...
// disconnectVPP disconnects from VPP in case it is connected.
[ "disconnectVPP", "disconnects", "from", "VPP", "in", "case", "it", "is", "connected", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/core/connection.go#L203-L207
134,698
FDio/govpp
core/connection.go
newAPIChannel
func (c *Connection) newAPIChannel(reqChanBufSize, replyChanBufSize int) (*Channel, error) { if c == nil { return nil, errors.New("nil connection passed in") } // create new channel chID := uint16(atomic.AddUint32(&c.maxChannelID, 1) & 0x7fff) channel := newChannel(chID, c, c.codec, c, reqChanBufSize, replyChan...
go
func (c *Connection) newAPIChannel(reqChanBufSize, replyChanBufSize int) (*Channel, error) { if c == nil { return nil, errors.New("nil connection passed in") } // create new channel chID := uint16(atomic.AddUint32(&c.maxChannelID, 1) & 0x7fff) channel := newChannel(chID, c, c.codec, c, reqChanBufSize, replyChan...
[ "func", "(", "c", "*", "Connection", ")", "newAPIChannel", "(", "reqChanBufSize", ",", "replyChanBufSize", "int", ")", "(", "*", "Channel", ",", "error", ")", "{", "if", "c", "==", "nil", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\...
// NewAPIChannelBuffered returns a new API channel for communication with VPP via govpp core. // It allows to specify custom buffer sizes for the request and reply Go channels.
[ "NewAPIChannelBuffered", "returns", "a", "new", "API", "channel", "for", "communication", "with", "VPP", "via", "govpp", "core", ".", "It", "allows", "to", "specify", "custom", "buffer", "sizes", "for", "the", "request", "and", "reply", "Go", "channels", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/core/connection.go#L219-L237
134,699
FDio/govpp
core/connection.go
releaseAPIChannel
func (c *Connection) releaseAPIChannel(ch *Channel) { log.WithFields(logger.Fields{ "channel": ch.id, }).Debug("API channel released") // delete the channel from channels map c.channelsLock.Lock() delete(c.channels, ch.id) c.channelsLock.Unlock() }
go
func (c *Connection) releaseAPIChannel(ch *Channel) { log.WithFields(logger.Fields{ "channel": ch.id, }).Debug("API channel released") // delete the channel from channels map c.channelsLock.Lock() delete(c.channels, ch.id) c.channelsLock.Unlock() }
[ "func", "(", "c", "*", "Connection", ")", "releaseAPIChannel", "(", "ch", "*", "Channel", ")", "{", "log", ".", "WithFields", "(", "logger", ".", "Fields", "{", "\"", "\"", ":", "ch", ".", "id", ",", "}", ")", ".", "Debug", "(", "\"", "\"", ")", ...
// releaseAPIChannel releases API channel that needs to be closed.
[ "releaseAPIChannel", "releases", "API", "channel", "that", "needs", "to", "be", "closed", "." ]
f614a0af720702c8db959b6641b4faea5f98c339
https://github.com/FDio/govpp/blob/f614a0af720702c8db959b6641b4faea5f98c339/core/connection.go#L240-L249