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
144,200
libopenstorage/openstorage
pkg/storageops/gce/gce.go
IsDevMode
func IsDevMode() bool { var i = new(instance) err := gceInfoFromEnv(i) return err == nil }
go
func IsDevMode() bool { var i = new(instance) err := gceInfoFromEnv(i) return err == nil }
[ "func", "IsDevMode", "(", ")", "bool", "{", "var", "i", "=", "new", "(", "instance", ")", "\n", "err", ":=", "gceInfoFromEnv", "(", "i", ")", "\n", "return", "err", "==", "nil", "\n", "}" ]
// IsDevMode checks if the pkg is invoked in developer mode where GCE credentials // are set as env variables
[ "IsDevMode", "checks", "if", "the", "pkg", "is", "invoked", "in", "developer", "mode", "where", "GCE", "credentials", "are", "set", "as", "env", "variables" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/storageops/gce/gce.go#L50-L54
144,201
libopenstorage/openstorage
pkg/storageops/gce/gce.go
NewClient
func NewClient() (storageops.Ops, error) { var i = new(instance) var err error if metadata.OnGCE() { err = gceInfo(i) } else if ok := IsDevMode(); ok { err = gceInfoFromEnv(i) } else { return nil, fmt.Errorf("instance is not running on GCE") } if err != nil { return nil, fmt.Errorf("error fetching insta...
go
func NewClient() (storageops.Ops, error) { var i = new(instance) var err error if metadata.OnGCE() { err = gceInfo(i) } else if ok := IsDevMode(); ok { err = gceInfoFromEnv(i) } else { return nil, fmt.Errorf("instance is not running on GCE") } if err != nil { return nil, fmt.Errorf("error fetching insta...
[ "func", "NewClient", "(", ")", "(", "storageops", ".", "Ops", ",", "error", ")", "{", "var", "i", "=", "new", "(", "instance", ")", "\n", "var", "err", "error", "\n", "if", "metadata", ".", "OnGCE", "(", ")", "{", "err", "=", "gceInfo", "(", "i",...
// NewClient creates a new GCE operations client
[ "NewClient", "creates", "a", "new", "GCE", "operations", "client" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/storageops/gce/gce.go#L57-L86
144,202
libopenstorage/openstorage
pkg/storageops/gce/gce.go
gceInfo
func gceInfo(inst *instance) error { var err error inst.zone, err = metadata.Zone() if err != nil { return err } inst.name, err = metadata.InstanceName() if err != nil { return err } inst.hostname, err = metadata.Hostname() if err != nil { return err } inst.project, err = metadata.ProjectID() if er...
go
func gceInfo(inst *instance) error { var err error inst.zone, err = metadata.Zone() if err != nil { return err } inst.name, err = metadata.InstanceName() if err != nil { return err } inst.hostname, err = metadata.Hostname() if err != nil { return err } inst.project, err = metadata.ProjectID() if er...
[ "func", "gceInfo", "(", "inst", "*", "instance", ")", "error", "{", "var", "err", "error", "\n", "inst", ".", "zone", ",", "err", "=", "metadata", ".", "Zone", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "in...
// gceInfo fetches the GCE instance metadata from the metadata server
[ "gceInfo", "fetches", "the", "GCE", "instance", "metadata", "from", "the", "metadata", "server" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/storageops/gce/gce.go#L531-L554
144,203
libopenstorage/openstorage
pkg/storageops/gce/gce.go
waitForDetach
func (s *gceOps) waitForDetach( diskURL string, timeout time.Duration, ) error { _, err := task.DoRetryWithTimeout( func() (interface{}, bool, error) { inst, err := s.describeinstance() if err != nil { return nil, true, err } for _, d := range inst.Disks { if d.Source == diskURL { return...
go
func (s *gceOps) waitForDetach( diskURL string, timeout time.Duration, ) error { _, err := task.DoRetryWithTimeout( func() (interface{}, bool, error) { inst, err := s.describeinstance() if err != nil { return nil, true, err } for _, d := range inst.Disks { if d.Source == diskURL { return...
[ "func", "(", "s", "*", "gceOps", ")", "waitForDetach", "(", "diskURL", "string", ",", "timeout", "time", ".", "Duration", ",", ")", "error", "{", "_", ",", "err", ":=", "task", ".", "DoRetryWithTimeout", "(", "func", "(", ")", "(", "interface", "{", ...
// waitForDetach checks if given disk is detached from the local instance
[ "waitForDetach", "checks", "if", "given", "disk", "is", "detached", "from", "the", "local", "instance" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/storageops/gce/gce.go#L586-L613
144,204
libopenstorage/openstorage
pkg/storageops/gce/gce.go
waitForAttach
func (s *gceOps) waitForAttach( disk *compute.Disk, timeout time.Duration, ) (string, error) { devicePath, err := task.DoRetryWithTimeout( func() (interface{}, bool, error) { devicePath, err := s.DevicePath(disk.Name) if se, ok := err.(*storageops.StorageError); ok && se.Code == storageops.ErrVolAttached...
go
func (s *gceOps) waitForAttach( disk *compute.Disk, timeout time.Duration, ) (string, error) { devicePath, err := task.DoRetryWithTimeout( func() (interface{}, bool, error) { devicePath, err := s.DevicePath(disk.Name) if se, ok := err.(*storageops.StorageError); ok && se.Code == storageops.ErrVolAttached...
[ "func", "(", "s", "*", "gceOps", ")", "waitForAttach", "(", "disk", "*", "compute", ".", "Disk", ",", "timeout", "time", ".", "Duration", ",", ")", "(", "string", ",", "error", ")", "{", "devicePath", ",", "err", ":=", "task", ".", "DoRetryWithTimeout"...
// waitForAttach checks if given disk is attached to the local instance
[ "waitForAttach", "checks", "if", "given", "disk", "is", "attached", "to", "the", "local", "instance" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/storageops/gce/gce.go#L616-L639
144,205
libopenstorage/openstorage
pkg/grpcserver/grpcserver.go
New
func New(config *GrpcServerConfig) (*GrpcServer, error) { if nil == config { return nil, fmt.Errorf("Configuration must be provided") } if len(config.Name) == 0 { return nil, fmt.Errorf("Name of server must be provided") } if len(config.Address) == 0 { return nil, fmt.Errorf("Address must be provided") } i...
go
func New(config *GrpcServerConfig) (*GrpcServer, error) { if nil == config { return nil, fmt.Errorf("Configuration must be provided") } if len(config.Name) == 0 { return nil, fmt.Errorf("Name of server must be provided") } if len(config.Address) == 0 { return nil, fmt.Errorf("Address must be provided") } i...
[ "func", "New", "(", "config", "*", "GrpcServerConfig", ")", "(", "*", "GrpcServer", ",", "error", ")", "{", "if", "nil", "==", "config", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "len", "(", "co...
// New creates a gRPC server on the specified port and transport.
[ "New", "creates", "a", "gRPC", "server", "on", "the", "specified", "port", "and", "transport", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/grpcserver/grpcserver.go#L48-L71
144,206
libopenstorage/openstorage
pkg/grpcserver/grpcserver.go
Start
func (s *GrpcServer) Start(register func(grpcServer *grpc.Server)) error { s.lock.Lock() defer s.lock.Unlock() if s.running { return fmt.Errorf("Server already running") } s.server = grpc.NewServer() register(s.server) // Start listening for requests s.startGrpcService() return nil }
go
func (s *GrpcServer) Start(register func(grpcServer *grpc.Server)) error { s.lock.Lock() defer s.lock.Unlock() if s.running { return fmt.Errorf("Server already running") } s.server = grpc.NewServer() register(s.server) // Start listening for requests s.startGrpcService() return nil }
[ "func", "(", "s", "*", "GrpcServer", ")", "Start", "(", "register", "func", "(", "grpcServer", "*", "grpc", ".", "Server", ")", ")", "error", "{", "s", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "lock", ".", "Unlock", "(", ")", ...
// Start is used to start the server. // It will return an error if the server is already runnig.
[ "Start", "is", "used", "to", "start", "the", "server", ".", "It", "will", "return", "an", "error", "if", "the", "server", "is", "already", "runnig", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/grpcserver/grpcserver.go#L75-L89
144,207
libopenstorage/openstorage
pkg/grpcserver/grpcserver.go
StartWithServer
func (s *GrpcServer) StartWithServer(server func() *grpc.Server) error { s.lock.Lock() defer s.lock.Unlock() if server == nil { return fmt.Errorf("Server function has not been defined") } if s.running { return fmt.Errorf("Server already running") } s.server = server() // Start listening for requests s....
go
func (s *GrpcServer) StartWithServer(server func() *grpc.Server) error { s.lock.Lock() defer s.lock.Unlock() if server == nil { return fmt.Errorf("Server function has not been defined") } if s.running { return fmt.Errorf("Server already running") } s.server = server() // Start listening for requests s....
[ "func", "(", "s", "*", "GrpcServer", ")", "StartWithServer", "(", "server", "func", "(", ")", "*", "grpc", ".", "Server", ")", "error", "{", "s", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "lock", ".", "Unlock", "(", ")", "\n\n"...
// StartWithServer is used to start the server. // It will return an error if the server is already runnig.
[ "StartWithServer", "is", "used", "to", "start", "the", "server", ".", "It", "will", "return", "an", "error", "if", "the", "server", "is", "already", "runnig", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/grpcserver/grpcserver.go#L93-L110
144,208
libopenstorage/openstorage
pkg/grpcserver/grpcserver.go
startGrpcService
func (s *GrpcServer) startGrpcService() { // Start listening for requests reflection.Register(s.server) logrus.Infof("%s gRPC Server ready on %s", s.name, s.Address()) waitForServer := make(chan bool) s.goServe(waitForServer) <-waitForServer s.running = true }
go
func (s *GrpcServer) startGrpcService() { // Start listening for requests reflection.Register(s.server) logrus.Infof("%s gRPC Server ready on %s", s.name, s.Address()) waitForServer := make(chan bool) s.goServe(waitForServer) <-waitForServer s.running = true }
[ "func", "(", "s", "*", "GrpcServer", ")", "startGrpcService", "(", ")", "{", "// Start listening for requests", "reflection", ".", "Register", "(", "s", ".", "server", ")", "\n", "logrus", ".", "Infof", "(", "\"", "\"", ",", "s", ".", "name", ",", "s", ...
// Lock must have been taken
[ "Lock", "must", "have", "been", "taken" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/grpcserver/grpcserver.go#L113-L121
144,209
libopenstorage/openstorage
pkg/grpcserver/grpcserver.go
Stop
func (s *GrpcServer) Stop() { s.lock.Lock() defer s.lock.Unlock() if !s.running { return } s.server.Stop() s.wg.Wait() s.running = false }
go
func (s *GrpcServer) Stop() { s.lock.Lock() defer s.lock.Unlock() if !s.running { return } s.server.Stop() s.wg.Wait() s.running = false }
[ "func", "(", "s", "*", "GrpcServer", ")", "Stop", "(", ")", "{", "s", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "lock", ".", "Unlock", "(", ")", "\n\n", "if", "!", "s", ".", "running", "{", "return", "\n", "}", "\n\n", "s",...
// Stop is used to stop the gRPC server. // It can be called multiple times. It does nothing if the server // has already been stopped.
[ "Stop", "is", "used", "to", "stop", "the", "gRPC", "server", ".", "It", "can", "be", "called", "multiple", "times", ".", "It", "does", "nothing", "if", "the", "server", "has", "already", "been", "stopped", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/grpcserver/grpcserver.go#L126-L137
144,210
libopenstorage/openstorage
pkg/grpcserver/grpcserver.go
IsRunning
func (s *GrpcServer) IsRunning() bool { s.lock.Lock() defer s.lock.Unlock() return s.running }
go
func (s *GrpcServer) IsRunning() bool { s.lock.Lock() defer s.lock.Unlock() return s.running }
[ "func", "(", "s", "*", "GrpcServer", ")", "IsRunning", "(", ")", "bool", "{", "s", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "lock", ".", "Unlock", "(", ")", "\n\n", "return", "s", ".", "running", "\n", "}" ]
// IsRunning returns true if the server is currently running
[ "IsRunning", "returns", "true", "if", "the", "server", "is", "currently", "running" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/grpcserver/grpcserver.go#L146-L151
144,211
libopenstorage/openstorage
osdconfig/api.go
GetClusterConf
func (manager *configManager) GetClusterConf() (*ClusterConfig, error) { // get json from kvdb and unmarshal into config kvPair, err := manager.kv.Get(filepath.Join(baseKey, clusterKey)) if err != nil { return nil, err } config := new(ClusterConfig) if err := json.Unmarshal(kvPair.Value, config); err != nil { ...
go
func (manager *configManager) GetClusterConf() (*ClusterConfig, error) { // get json from kvdb and unmarshal into config kvPair, err := manager.kv.Get(filepath.Join(baseKey, clusterKey)) if err != nil { return nil, err } config := new(ClusterConfig) if err := json.Unmarshal(kvPair.Value, config); err != nil { ...
[ "func", "(", "manager", "*", "configManager", ")", "GetClusterConf", "(", ")", "(", "*", "ClusterConfig", ",", "error", ")", "{", "// get json from kvdb and unmarshal into config", "kvPair", ",", "err", ":=", "manager", ".", "kv", ".", "Get", "(", "filepath", ...
// GetClusterConf retrieves cluster level data from kvdb
[ "GetClusterConf", "retrieves", "cluster", "level", "data", "from", "kvdb" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/osdconfig/api.go#L10-L23
144,212
libopenstorage/openstorage
osdconfig/api.go
SetClusterConf
func (manager *configManager) SetClusterConf(config *ClusterConfig) error { if config == nil { return fmt.Errorf("input cannot be nil") } manager.Lock() defer manager.Unlock() // push into kvdb if _, err := manager.kv.Put(filepath.Join(baseKey, clusterKey), config, 0); err != nil { return err } return ni...
go
func (manager *configManager) SetClusterConf(config *ClusterConfig) error { if config == nil { return fmt.Errorf("input cannot be nil") } manager.Lock() defer manager.Unlock() // push into kvdb if _, err := manager.kv.Put(filepath.Join(baseKey, clusterKey), config, 0); err != nil { return err } return ni...
[ "func", "(", "manager", "*", "configManager", ")", "SetClusterConf", "(", "config", "*", "ClusterConfig", ")", "error", "{", "if", "config", "==", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "manager", ".", "Loc...
// SetClusterConf sets cluster config in kvdb
[ "SetClusterConf", "sets", "cluster", "config", "in", "kvdb" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/osdconfig/api.go#L26-L40
144,213
libopenstorage/openstorage
osdconfig/api.go
GetNodeConf
func (manager *configManager) GetNodeConf(nodeID string) (*NodeConfig, error) { if len(nodeID) == 0 { return nil, fmt.Errorf("input cannot be nil") } // get json from kvdb and unmarshal into config kvPair, err := manager.kv.Get(getNodeKeyFromNodeID(nodeID)) if err != nil { return nil, err } config := new(N...
go
func (manager *configManager) GetNodeConf(nodeID string) (*NodeConfig, error) { if len(nodeID) == 0 { return nil, fmt.Errorf("input cannot be nil") } // get json from kvdb and unmarshal into config kvPair, err := manager.kv.Get(getNodeKeyFromNodeID(nodeID)) if err != nil { return nil, err } config := new(N...
[ "func", "(", "manager", "*", "configManager", ")", "GetNodeConf", "(", "nodeID", "string", ")", "(", "*", "NodeConfig", ",", "error", ")", "{", "if", "len", "(", "nodeID", ")", "==", "0", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", ...
// GetNodeConf retrieves node config data using nodeID
[ "GetNodeConf", "retrieves", "node", "config", "data", "using", "nodeID" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/osdconfig/api.go#L43-L60
144,214
libopenstorage/openstorage
osdconfig/api.go
SetNodeConf
func (manager *configManager) SetNodeConf(config *NodeConfig) error { if config == nil { return fmt.Errorf("input cannot be nil") } if len(config.NodeId) == 0 { return fmt.Errorf("node id cannot be nil") } manager.Lock() defer manager.Unlock() // push node data into kvdb if _, err := manager.kv.Put(getNo...
go
func (manager *configManager) SetNodeConf(config *NodeConfig) error { if config == nil { return fmt.Errorf("input cannot be nil") } if len(config.NodeId) == 0 { return fmt.Errorf("node id cannot be nil") } manager.Lock() defer manager.Unlock() // push node data into kvdb if _, err := manager.kv.Put(getNo...
[ "func", "(", "manager", "*", "configManager", ")", "SetNodeConf", "(", "config", "*", "NodeConfig", ")", "error", "{", "if", "config", "==", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "len", "(", "confi...
// SetNodeConf sets node config data in kvdb
[ "SetNodeConf", "sets", "node", "config", "data", "in", "kvdb" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/osdconfig/api.go#L63-L81
144,215
libopenstorage/openstorage
osdconfig/api.go
DeleteNodeConf
func (manager *configManager) DeleteNodeConf(nodeID string) error { if len(nodeID) == 0 { return fmt.Errorf("node id cannot be nil") } manager.Lock() defer manager.Unlock() // remove dode data from kvdb if _, err := manager.kv.Delete(getNodeKeyFromNodeID(nodeID)); err != nil { return err } return nil }
go
func (manager *configManager) DeleteNodeConf(nodeID string) error { if len(nodeID) == 0 { return fmt.Errorf("node id cannot be nil") } manager.Lock() defer manager.Unlock() // remove dode data from kvdb if _, err := manager.kv.Delete(getNodeKeyFromNodeID(nodeID)); err != nil { return err } return nil }
[ "func", "(", "manager", "*", "configManager", ")", "DeleteNodeConf", "(", "nodeID", "string", ")", "error", "{", "if", "len", "(", "nodeID", ")", "==", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "manager", ".",...
// DeleteNodeConf deletes node config data in kvdb
[ "DeleteNodeConf", "deletes", "node", "config", "data", "in", "kvdb" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/osdconfig/api.go#L84-L98
144,216
libopenstorage/openstorage
osdconfig/api.go
EnumerateNodeConf
func (manager *configManager) EnumerateNodeConf() (*NodesConfig, error) { keys, err := manager.kv.Keys(filepath.Join(baseKey, nodeKey), "/") if err != nil { return nil, fmt.Errorf("kvdb.Keys() returned error: " + err.Error()) } nodesConfig := new(NodesConfig) *nodesConfig = make([]*NodeConfig, len(keys)) for i...
go
func (manager *configManager) EnumerateNodeConf() (*NodesConfig, error) { keys, err := manager.kv.Keys(filepath.Join(baseKey, nodeKey), "/") if err != nil { return nil, fmt.Errorf("kvdb.Keys() returned error: " + err.Error()) } nodesConfig := new(NodesConfig) *nodesConfig = make([]*NodeConfig, len(keys)) for i...
[ "func", "(", "manager", "*", "configManager", ")", "EnumerateNodeConf", "(", ")", "(", "*", "NodesConfig", ",", "error", ")", "{", "keys", ",", "err", ":=", "manager", ".", "kv", ".", "Keys", "(", "filepath", ".", "Join", "(", "baseKey", ",", "nodeKey"...
// EnumerateNodeConf fetches data for all nodes
[ "EnumerateNodeConf", "fetches", "data", "for", "all", "nodes" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/osdconfig/api.go#L101-L119
144,217
libopenstorage/openstorage
osdconfig/api.go
WatchCluster
func (manager *configManager) WatchCluster(name string, cb func(config *ClusterConfig) error) error { manager.Lock() defer manager.Unlock() if _, present := manager.cbCluster[name]; present { return fmt.Errorf("%s already present", name) } manager.cbCluster[name] = cb return nil }
go
func (manager *configManager) WatchCluster(name string, cb func(config *ClusterConfig) error) error { manager.Lock() defer manager.Unlock() if _, present := manager.cbCluster[name]; present { return fmt.Errorf("%s already present", name) } manager.cbCluster[name] = cb return nil }
[ "func", "(", "manager", "*", "configManager", ")", "WatchCluster", "(", "name", "string", ",", "cb", "func", "(", "config", "*", "ClusterConfig", ")", "error", ")", "error", "{", "manager", ".", "Lock", "(", ")", "\n", "defer", "manager", ".", "Unlock", ...
// WatchCluster registers user defined function as callback and sets a watch for changes // to cluster configuration
[ "WatchCluster", "registers", "user", "defined", "function", "as", "callback", "and", "sets", "a", "watch", "for", "changes", "to", "cluster", "configuration" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/osdconfig/api.go#L123-L132
144,218
libopenstorage/openstorage
osdconfig/api.go
WatchNode
func (manager *configManager) WatchNode(name string, cb func(config *NodeConfig) error) error { manager.Lock() defer manager.Unlock() if _, present := manager.cbNode[name]; present { return fmt.Errorf("%s already present", name) } manager.cbNode[name] = cb return nil }
go
func (manager *configManager) WatchNode(name string, cb func(config *NodeConfig) error) error { manager.Lock() defer manager.Unlock() if _, present := manager.cbNode[name]; present { return fmt.Errorf("%s already present", name) } manager.cbNode[name] = cb return nil }
[ "func", "(", "manager", "*", "configManager", ")", "WatchNode", "(", "name", "string", ",", "cb", "func", "(", "config", "*", "NodeConfig", ")", "error", ")", "error", "{", "manager", ".", "Lock", "(", ")", "\n", "defer", "manager", ".", "Unlock", "(",...
// WatchNode registers user defined function as callback and sets a watch for changes // to node configuration
[ "WatchNode", "registers", "user", "defined", "function", "as", "callback", "and", "sets", "a", "watch", "for", "changes", "to", "node", "configuration" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/osdconfig/api.go#L136-L145
144,219
libopenstorage/openstorage
pkg/mount/mount.go
Mount
func (m *DefaultMounter) Mount( source string, target string, fstype string, flags uintptr, data string, timeout int, ) error { return syscall.Mount(source, target, fstype, flags, data) }
go
func (m *DefaultMounter) Mount( source string, target string, fstype string, flags uintptr, data string, timeout int, ) error { return syscall.Mount(source, target, fstype, flags, data) }
[ "func", "(", "m", "*", "DefaultMounter", ")", "Mount", "(", "source", "string", ",", "target", "string", ",", "fstype", "string", ",", "flags", "uintptr", ",", "data", "string", ",", "timeout", "int", ",", ")", "error", "{", "return", "syscall", ".", "...
// Mount default mount implementation is syscall.
[ "Mount", "default", "mount", "implementation", "is", "syscall", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/mount.go#L157-L166
144,220
libopenstorage/openstorage
pkg/mount/mount.go
Unmount
func (m *DefaultMounter) Unmount(target string, flags int, timeout int) error { return syscall.Unmount(target, flags) }
go
func (m *DefaultMounter) Unmount(target string, flags int, timeout int) error { return syscall.Unmount(target, flags) }
[ "func", "(", "m", "*", "DefaultMounter", ")", "Unmount", "(", "target", "string", ",", "flags", "int", ",", "timeout", "int", ")", "error", "{", "return", "syscall", ".", "Unmount", "(", "target", ",", "flags", ")", "\n", "}" ]
// Unmount default unmount implementation is syscall.
[ "Unmount", "default", "unmount", "implementation", "is", "syscall", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/mount.go#L169-L171
144,221
libopenstorage/openstorage
pkg/mount/mount.go
String
func (m *Mounter) String() string { s := struct { mounts DeviceMap paths PathMap allowedDirs []string trashLocation string }{ mounts: m.mounts, paths: m.paths, allowedDirs: m.allowedDirs, trashLocation: m.trashLocation, } return fmt.Sprintf("%#v", s) }
go
func (m *Mounter) String() string { s := struct { mounts DeviceMap paths PathMap allowedDirs []string trashLocation string }{ mounts: m.mounts, paths: m.paths, allowedDirs: m.allowedDirs, trashLocation: m.trashLocation, } return fmt.Sprintf("%#v", s) }
[ "func", "(", "m", "*", "Mounter", ")", "String", "(", ")", "string", "{", "s", ":=", "struct", "{", "mounts", "DeviceMap", "\n", "paths", "PathMap", "\n", "allowedDirs", "[", "]", "string", "\n", "trashLocation", "string", "\n", "}", "{", "mounts", ":"...
// String representation of Mounter
[ "String", "representation", "of", "Mounter" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/mount.go#L174-L188
144,222
libopenstorage/openstorage
pkg/mount/mount.go
Inspect
func (m *Mounter) Inspect(sourcePath string) []*PathInfo { m.Lock() defer m.Unlock() v, ok := m.mounts[sourcePath] if !ok { return nil } return v.Mountpoint }
go
func (m *Mounter) Inspect(sourcePath string) []*PathInfo { m.Lock() defer m.Unlock() v, ok := m.mounts[sourcePath] if !ok { return nil } return v.Mountpoint }
[ "func", "(", "m", "*", "Mounter", ")", "Inspect", "(", "sourcePath", "string", ")", "[", "]", "*", "PathInfo", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n\n", "v", ",", "ok", ":=", "m", ".", "mounts", "[", ...
// Inspect mount table for device
[ "Inspect", "mount", "table", "for", "device" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/mount.go#L191-L200
144,223
libopenstorage/openstorage
pkg/mount/mount.go
Mounts
func (m *Mounter) Mounts(sourcePath string) []string { m.Lock() defer m.Unlock() v, ok := m.mounts[sourcePath] if !ok { return nil } mounts := make([]string, len(v.Mountpoint)) for i, v := range v.Mountpoint { mounts[i] = v.Path } return mounts }
go
func (m *Mounter) Mounts(sourcePath string) []string { m.Lock() defer m.Unlock() v, ok := m.mounts[sourcePath] if !ok { return nil } mounts := make([]string, len(v.Mountpoint)) for i, v := range v.Mountpoint { mounts[i] = v.Path } return mounts }
[ "func", "(", "m", "*", "Mounter", ")", "Mounts", "(", "sourcePath", "string", ")", "[", "]", "string", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n\n", "v", ",", "ok", ":=", "m", ".", "mounts", "[", "sourceP...
// Mounts returns mount table for device
[ "Mounts", "returns", "mount", "table", "for", "device" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/mount.go#L203-L218
144,224
libopenstorage/openstorage
pkg/mount/mount.go
GetSourcePaths
func (m *Mounter) GetSourcePaths() []string { m.Lock() defer m.Unlock() sourcePaths := make([]string, len(m.mounts)) i := 0 for path := range m.mounts { sourcePaths[i] = path i++ } return sourcePaths }
go
func (m *Mounter) GetSourcePaths() []string { m.Lock() defer m.Unlock() sourcePaths := make([]string, len(m.mounts)) i := 0 for path := range m.mounts { sourcePaths[i] = path i++ } return sourcePaths }
[ "func", "(", "m", "*", "Mounter", ")", "GetSourcePaths", "(", ")", "[", "]", "string", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n\n", "sourcePaths", ":=", "make", "(", "[", "]", "string", ",", "len", "(", ...
// GetSourcePaths returns all source paths from the mount table
[ "GetSourcePaths", "returns", "all", "source", "paths", "from", "the", "mount", "table" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/mount.go#L221-L232
144,225
libopenstorage/openstorage
pkg/mount/mount.go
HasMounts
func (m *Mounter) HasMounts(sourcePath string) int { m.Lock() defer m.Unlock() v, ok := m.mounts[sourcePath] if !ok { return 0 } return len(v.Mountpoint) }
go
func (m *Mounter) HasMounts(sourcePath string) int { m.Lock() defer m.Unlock() v, ok := m.mounts[sourcePath] if !ok { return 0 } return len(v.Mountpoint) }
[ "func", "(", "m", "*", "Mounter", ")", "HasMounts", "(", "sourcePath", "string", ")", "int", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n\n", "v", ",", "ok", ":=", "m", ".", "mounts", "[", "sourcePath", "]", ...
// HasMounts determines returns the number of mounts for the device.
[ "HasMounts", "determines", "returns", "the", "number", "of", "mounts", "for", "the", "device", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/mount.go#L235-L244
144,226
libopenstorage/openstorage
pkg/mount/mount.go
Exists
func (m *Mounter) Exists(sourcePath string, path string) (bool, error) { m.Lock() defer m.Unlock() v, ok := m.mounts[sourcePath] if !ok { return false, ErrEnoent } for _, p := range v.Mountpoint { if p.Path == path { return true, nil } } return false, nil }
go
func (m *Mounter) Exists(sourcePath string, path string) (bool, error) { m.Lock() defer m.Unlock() v, ok := m.mounts[sourcePath] if !ok { return false, ErrEnoent } for _, p := range v.Mountpoint { if p.Path == path { return true, nil } } return false, nil }
[ "func", "(", "m", "*", "Mounter", ")", "Exists", "(", "sourcePath", "string", ",", "path", "string", ")", "(", "bool", ",", "error", ")", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n\n", "v", ",", "ok", ":="...
// Exists scans mountpaths for specified device and returns true if path is one of the // mountpaths. ErrEnoent may be retuned if the device is not found
[ "Exists", "scans", "mountpaths", "for", "specified", "device", "and", "returns", "true", "if", "path", "is", "one", "of", "the", "mountpaths", ".", "ErrEnoent", "may", "be", "retuned", "if", "the", "device", "is", "not", "found" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/mount.go#L263-L277
144,227
libopenstorage/openstorage
pkg/mount/mount.go
GetRootPath
func (m *Mounter) GetRootPath(mountPath string) (string, error) { m.Lock() defer m.Unlock() for _, v := range m.mounts { for _, p := range v.Mountpoint { if p.Path == mountPath { return p.Root, nil } } } return "", ErrEnoent }
go
func (m *Mounter) GetRootPath(mountPath string) (string, error) { m.Lock() defer m.Unlock() for _, v := range m.mounts { for _, p := range v.Mountpoint { if p.Path == mountPath { return p.Root, nil } } } return "", ErrEnoent }
[ "func", "(", "m", "*", "Mounter", ")", "GetRootPath", "(", "mountPath", "string", ")", "(", "string", ",", "error", ")", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n\n", "for", "_", ",", "v", ":=", "range", ...
// GetRootPath scans mounts for a specified mountPath and return the // rootPath if found or returns an ErrEnoent
[ "GetRootPath", "scans", "mounts", "for", "a", "specified", "mountPath", "and", "return", "the", "rootPath", "if", "found", "or", "returns", "an", "ErrEnoent" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/mount.go#L281-L293
144,228
libopenstorage/openstorage
pkg/mount/mount.go
GetSourcePath
func (m *Mounter) GetSourcePath(mountPath string) (string, error) { m.Lock() defer m.Unlock() for k, v := range m.mounts { for _, p := range v.Mountpoint { if p.Path == mountPath { return k, nil } } } return "", ErrEnoent }
go
func (m *Mounter) GetSourcePath(mountPath string) (string, error) { m.Lock() defer m.Unlock() for k, v := range m.mounts { for _, p := range v.Mountpoint { if p.Path == mountPath { return k, nil } } } return "", ErrEnoent }
[ "func", "(", "m", "*", "Mounter", ")", "GetSourcePath", "(", "mountPath", "string", ")", "(", "string", ",", "error", ")", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n\n", "for", "k", ",", "v", ":=", "range", ...
// GetSourcePath scans mount for a specified mountPath and returns the sourcePath // if found or returnes an ErrEnoent
[ "GetSourcePath", "scans", "mount", "for", "a", "specified", "mountPath", "and", "returns", "the", "sourcePath", "if", "found", "or", "returnes", "an", "ErrEnoent" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/mount.go#L297-L309
144,229
libopenstorage/openstorage
pkg/mount/mount.go
reload
func (m *Mounter) reload(device string, newM *Info) error { m.Lock() defer m.Unlock() // New mountable has no mounts, delete old mounts. if newM == nil { delete(m.mounts, device) return nil } // Old mountable had no mounts, copy over new mounts. oldM, ok := m.mounts[device] if !ok { m.mounts[device] = n...
go
func (m *Mounter) reload(device string, newM *Info) error { m.Lock() defer m.Unlock() // New mountable has no mounts, delete old mounts. if newM == nil { delete(m.mounts, device) return nil } // Old mountable had no mounts, copy over new mounts. oldM, ok := m.mounts[device] if !ok { m.mounts[device] = n...
[ "func", "(", "m", "*", "Mounter", ")", "reload", "(", "device", "string", ",", "newM", "*", "Info", ")", "error", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n\n", "// New mountable has no mounts, delete old mounts.", ...
// reload from newM
[ "reload", "from", "newM" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/mount.go#L330-L360
144,230
libopenstorage/openstorage
pkg/mount/mount.go
Unmount
func (m *Mounter) Unmount( devPath string, path string, flags int, timeout int, opts map[string]string, ) error { m.Lock() // device gets overwritten if opts specifies fuse mount with // options.OptionsDeviceFuseMount. device := devPath path = normalizeMountPath(path) if value, ok := opts[options.OptionsDevi...
go
func (m *Mounter) Unmount( devPath string, path string, flags int, timeout int, opts map[string]string, ) error { m.Lock() // device gets overwritten if opts specifies fuse mount with // options.OptionsDeviceFuseMount. device := devPath path = normalizeMountPath(path) if value, ok := opts[options.OptionsDevi...
[ "func", "(", "m", "*", "Mounter", ")", "Unmount", "(", "devPath", "string", ",", "path", "string", ",", "flags", "int", ",", "timeout", "int", ",", "opts", "map", "[", "string", "]", "string", ",", ")", "error", "{", "m", ".", "Lock", "(", ")", "...
// Unmount device at mountpoint and from the matrix. // ErrEnoent is returned if the device or mountpoint for the device is not found.
[ "Unmount", "device", "at", "mountpoint", "and", "from", "the", "matrix", ".", "ErrEnoent", "is", "returned", "if", "the", "device", "or", "mountpoint", "for", "the", "device", "is", "not", "found", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/mount.go#L589-L635
144,231
libopenstorage/openstorage
pkg/mount/mount.go
RemoveMountPath
func (m *Mounter) RemoveMountPath(mountPath string, opts map[string]string) error { if _, err := os.Stat(mountPath); err == nil { if options.IsBoolOptionSet(opts, options.OptionsWaitBeforeDelete) { hasher := md5.New() hasher.Write([]byte(mountPath)) symlinkName := hex.EncodeToString(hasher.Sum(nil)) syml...
go
func (m *Mounter) RemoveMountPath(mountPath string, opts map[string]string) error { if _, err := os.Stat(mountPath); err == nil { if options.IsBoolOptionSet(opts, options.OptionsWaitBeforeDelete) { hasher := md5.New() hasher.Write([]byte(mountPath)) symlinkName := hex.EncodeToString(hasher.Sum(nil)) syml...
[ "func", "(", "m", "*", "Mounter", ")", "RemoveMountPath", "(", "mountPath", "string", ",", "opts", "map", "[", "string", "]", "string", ")", "error", "{", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "mountPath", ")", ";", "err", "==", "nil...
// RemoveMountPath makes the path writeable and removes it after a fixed delay
[ "RemoveMountPath", "makes", "the", "path", "writeable", "and", "removes", "it", "after", "a", "fixed", "delay" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/mount.go#L685-L721
144,232
libopenstorage/openstorage
pkg/mount/mount.go
New
func New( mounterType MountType, mountImpl MountImpl, identifiers []string, customMounter CustomMounter, allowedDirs []string, trashLocation string, ) (Manager, error) { if mountImpl == nil { mountImpl = &DefaultMounter{} } switch mounterType { case DeviceMount: return NewDeviceMounter(identifiers, moun...
go
func New( mounterType MountType, mountImpl MountImpl, identifiers []string, customMounter CustomMounter, allowedDirs []string, trashLocation string, ) (Manager, error) { if mountImpl == nil { mountImpl = &DefaultMounter{} } switch mounterType { case DeviceMount: return NewDeviceMounter(identifiers, moun...
[ "func", "New", "(", "mounterType", "MountType", ",", "mountImpl", "MountImpl", ",", "identifiers", "[", "]", "string", ",", "customMounter", "CustomMounter", ",", "allowedDirs", "[", "]", "string", ",", "trashLocation", "string", ",", ")", "(", "Manager", ",",...
// New returns a new Mount Manager
[ "New", "returns", "a", "new", "Mount", "Manager" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/mount.go#L785-L809
144,233
libopenstorage/openstorage
graph/drivers/chainfs/unsupported.go
Init
func Init(home string, options []string, uidMaps, gidMaps []idtools.IDMap) (graphdriver.Driver, error) { return nil, errUnsupported }
go
func Init(home string, options []string, uidMaps, gidMaps []idtools.IDMap) (graphdriver.Driver, error) { return nil, errUnsupported }
[ "func", "Init", "(", "home", "string", ",", "options", "[", "]", "string", ",", "uidMaps", ",", "gidMaps", "[", "]", "idtools", ".", "IDMap", ")", "(", "graphdriver", ".", "Driver", ",", "error", ")", "{", "return", "nil", ",", "errUnsupported", "\n", ...
// Init initializes the graphdriver
[ "Init", "initializes", "the", "graphdriver" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/graph/drivers/chainfs/unsupported.go#L25-L27
144,234
libopenstorage/openstorage
api/status.go
StatusSimpleValueOf
func StatusSimpleValueOf(s string) (Status, error) { obj, err := simpleValueOf("status", Status_value, s) return Status(obj), err }
go
func StatusSimpleValueOf(s string) (Status, error) { obj, err := simpleValueOf("status", Status_value, s) return Status(obj), err }
[ "func", "StatusSimpleValueOf", "(", "s", "string", ")", "(", "Status", ",", "error", ")", "{", "obj", ",", "err", ":=", "simpleValueOf", "(", "\"", "\"", ",", "Status_value", ",", "s", ")", "\n", "return", "Status", "(", "obj", ")", ",", "err", "\n",...
// StatusSimpleValueOf returns the string format of Status
[ "StatusSimpleValueOf", "returns", "the", "string", "format", "of", "Status" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/status.go#L35-L38
144,235
gorilla/rpc
json/server.go
Method
func (c *CodecRequest) Method() (string, error) { if c.err == nil { return c.request.Method, nil } return "", c.err }
go
func (c *CodecRequest) Method() (string, error) { if c.err == nil { return c.request.Method, nil } return "", c.err }
[ "func", "(", "c", "*", "CodecRequest", ")", "Method", "(", ")", "(", "string", ",", "error", ")", "{", "if", "c", ".", "err", "==", "nil", "{", "return", "c", ".", "request", ".", "Method", ",", "nil", "\n", "}", "\n", "return", "\"", "\"", ","...
// Method returns the RPC method for the current request. // // The method uses a dotted notation as in "Service.Method".
[ "Method", "returns", "the", "RPC", "method", "for", "the", "current", "request", ".", "The", "method", "uses", "a", "dotted", "notation", "as", "in", "Service", ".", "Method", "." ]
bffcfa752ad4e523cc8f720afeb5b985ed41ae16
https://github.com/gorilla/rpc/blob/bffcfa752ad4e523cc8f720afeb5b985ed41ae16/json/server.go#L85-L90
144,236
gorilla/rpc
json/server.go
WriteResponse
func (c *CodecRequest) WriteResponse(w http.ResponseWriter, reply interface{}, methodErr error) error { if c.err != nil { return c.err } res := &serverResponse{ Result: reply, Error: &null, Id: c.request.Id, } if methodErr != nil { // Propagate error message as string. res.Error = methodErr.Error(...
go
func (c *CodecRequest) WriteResponse(w http.ResponseWriter, reply interface{}, methodErr error) error { if c.err != nil { return c.err } res := &serverResponse{ Result: reply, Error: &null, Id: c.request.Id, } if methodErr != nil { // Propagate error message as string. res.Error = methodErr.Error(...
[ "func", "(", "c", "*", "CodecRequest", ")", "WriteResponse", "(", "w", "http", ".", "ResponseWriter", ",", "reply", "interface", "{", "}", ",", "methodErr", "error", ")", "error", "{", "if", "c", ".", "err", "!=", "nil", "{", "return", "c", ".", "err...
// WriteResponse encodes the response and writes it to the ResponseWriter. // // The err parameter is the error resulted from calling the RPC method, // or nil if there was no error.
[ "WriteResponse", "encodes", "the", "response", "and", "writes", "it", "to", "the", "ResponseWriter", ".", "The", "err", "parameter", "is", "the", "error", "resulted", "from", "calling", "the", "RPC", "method", "or", "nil", "if", "there", "was", "no", "error"...
bffcfa752ad4e523cc8f720afeb5b985ed41ae16
https://github.com/gorilla/rpc/blob/bffcfa752ad4e523cc8f720afeb5b985ed41ae16/json/server.go#L111-L136
144,237
gorilla/rpc
v2/server.go
HasMethod
func (s *Server) HasMethod(method string) bool { if _, _, err := s.services.get(method); err == nil { return true } return false }
go
func (s *Server) HasMethod(method string) bool { if _, _, err := s.services.get(method); err == nil { return true } return false }
[ "func", "(", "s", "*", "Server", ")", "HasMethod", "(", "method", "string", ")", "bool", "{", "if", "_", ",", "_", ",", "err", ":=", "s", ".", "services", ".", "get", "(", "method", ")", ";", "err", "==", "nil", "{", "return", "true", "\n", "}"...
// HasMethod returns true if the given method is registered. // // The method uses a dotted notation as in "Service.Method".
[ "HasMethod", "returns", "true", "if", "the", "given", "method", "is", "registered", ".", "The", "method", "uses", "a", "dotted", "notation", "as", "in", "Service", ".", "Method", "." ]
bffcfa752ad4e523cc8f720afeb5b985ed41ae16
https://github.com/gorilla/rpc/blob/bffcfa752ad4e523cc8f720afeb5b985ed41ae16/v2/server.go#L139-L144
144,238
gorilla/rpc
map.go
register
func (m *serviceMap) register(rcvr interface{}, name string, passReq bool) error { // Setup service. s := &service{ name: name, rcvr: reflect.ValueOf(rcvr), rcvrType: reflect.TypeOf(rcvr), methods: make(map[string]*serviceMethod), passReq: passReq, } if name == "" { s.name = reflect.Indirect(s...
go
func (m *serviceMap) register(rcvr interface{}, name string, passReq bool) error { // Setup service. s := &service{ name: name, rcvr: reflect.ValueOf(rcvr), rcvrType: reflect.TypeOf(rcvr), methods: make(map[string]*serviceMethod), passReq: passReq, } if name == "" { s.name = reflect.Indirect(s...
[ "func", "(", "m", "*", "serviceMap", ")", "register", "(", "rcvr", "interface", "{", "}", ",", "name", "string", ",", "passReq", "bool", ")", "error", "{", "// Setup service.", "s", ":=", "&", "service", "{", "name", ":", "name", ",", "rcvr", ":", "r...
// register adds a new service using reflection to extract its methods.
[ "register", "adds", "a", "new", "service", "using", "reflection", "to", "extract", "its", "methods", "." ]
bffcfa752ad4e523cc8f720afeb5b985ed41ae16
https://github.com/gorilla/rpc/blob/bffcfa752ad4e523cc8f720afeb5b985ed41ae16/map.go#L53-L140
144,239
gorilla/rpc
map.go
get
func (m *serviceMap) get(method string) (*service, *serviceMethod, error) { parts := strings.Split(method, ".") if len(parts) != 2 { err := fmt.Errorf("rpc: service/method request ill-formed: %q", method) return nil, nil, err } m.mutex.Lock() service := m.services[parts[0]] m.mutex.Unlock() if service == nil...
go
func (m *serviceMap) get(method string) (*service, *serviceMethod, error) { parts := strings.Split(method, ".") if len(parts) != 2 { err := fmt.Errorf("rpc: service/method request ill-formed: %q", method) return nil, nil, err } m.mutex.Lock() service := m.services[parts[0]] m.mutex.Unlock() if service == nil...
[ "func", "(", "m", "*", "serviceMap", ")", "get", "(", "method", "string", ")", "(", "*", "service", ",", "*", "serviceMethod", ",", "error", ")", "{", "parts", ":=", "strings", ".", "Split", "(", "method", ",", "\"", "\"", ")", "\n", "if", "len", ...
// get returns a registered service given a method name. // // The method name uses a dotted notation as in "Service.Method".
[ "get", "returns", "a", "registered", "service", "given", "a", "method", "name", ".", "The", "method", "name", "uses", "a", "dotted", "notation", "as", "in", "Service", ".", "Method", "." ]
bffcfa752ad4e523cc8f720afeb5b985ed41ae16
https://github.com/gorilla/rpc/blob/bffcfa752ad4e523cc8f720afeb5b985ed41ae16/map.go#L145-L164
144,240
gorilla/rpc
map.go
isExportedOrBuiltin
func isExportedOrBuiltin(t reflect.Type) bool { for t.Kind() == reflect.Ptr { t = t.Elem() } // PkgPath will be non-empty even for an exported type, // so we need to check the type name as well. return isExported(t.Name()) || t.PkgPath() == "" }
go
func isExportedOrBuiltin(t reflect.Type) bool { for t.Kind() == reflect.Ptr { t = t.Elem() } // PkgPath will be non-empty even for an exported type, // so we need to check the type name as well. return isExported(t.Name()) || t.PkgPath() == "" }
[ "func", "isExportedOrBuiltin", "(", "t", "reflect", ".", "Type", ")", "bool", "{", "for", "t", ".", "Kind", "(", ")", "==", "reflect", ".", "Ptr", "{", "t", "=", "t", ".", "Elem", "(", ")", "\n", "}", "\n", "// PkgPath will be non-empty even for an expor...
// isExportedOrBuiltin returns true if a type is exported or a builtin.
[ "isExportedOrBuiltin", "returns", "true", "if", "a", "type", "is", "exported", "or", "a", "builtin", "." ]
bffcfa752ad4e523cc8f720afeb5b985ed41ae16
https://github.com/gorilla/rpc/blob/bffcfa752ad4e523cc8f720afeb5b985ed41ae16/map.go#L173-L180
144,241
gorilla/rpc
v2/compression_selector.go
Select
func (*CompressionSelector) Select(r *http.Request) Encoder { encHeader := r.Header.Get("Accept-Encoding") encTypes := strings.FieldsFunc(encHeader, func(r rune) bool { return unicode.IsSpace(r) || r == ',' }) for _, enc := range encTypes { switch enc { case "gzip": return &gzipEncoder{} case "deflate":...
go
func (*CompressionSelector) Select(r *http.Request) Encoder { encHeader := r.Header.Get("Accept-Encoding") encTypes := strings.FieldsFunc(encHeader, func(r rune) bool { return unicode.IsSpace(r) || r == ',' }) for _, enc := range encTypes { switch enc { case "gzip": return &gzipEncoder{} case "deflate":...
[ "func", "(", "*", "CompressionSelector", ")", "Select", "(", "r", "*", "http", ".", "Request", ")", "Encoder", "{", "encHeader", ":=", "r", ".", "Header", ".", "Get", "(", "\"", "\"", ")", "\n", "encTypes", ":=", "strings", ".", "FieldsFunc", "(", "e...
// Select method selects the correct compression encoder based on http HEADER.
[ "Select", "method", "selects", "the", "correct", "compression", "encoder", "based", "on", "http", "HEADER", "." ]
bffcfa752ad4e523cc8f720afeb5b985ed41ae16
https://github.com/gorilla/rpc/blob/bffcfa752ad4e523cc8f720afeb5b985ed41ae16/v2/compression_selector.go#L64-L80
144,242
gorilla/rpc
v2/json2/client.go
EncodeClientRequest
func EncodeClientRequest(method string, args interface{}) ([]byte, error) { c := &clientRequest{ Version: "2.0", Method: method, Params: args, Id: uint64(rand.Int63()), } return json.Marshal(c) }
go
func EncodeClientRequest(method string, args interface{}) ([]byte, error) { c := &clientRequest{ Version: "2.0", Method: method, Params: args, Id: uint64(rand.Int63()), } return json.Marshal(c) }
[ "func", "EncodeClientRequest", "(", "method", "string", ",", "args", "interface", "{", "}", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "c", ":=", "&", "clientRequest", "{", "Version", ":", "\"", "\"", ",", "Method", ":", "method", ",", "Para...
// EncodeClientRequest encodes parameters for a JSON-RPC client request.
[ "EncodeClientRequest", "encodes", "parameters", "for", "a", "JSON", "-", "RPC", "client", "request", "." ]
bffcfa752ad4e523cc8f720afeb5b985ed41ae16
https://github.com/gorilla/rpc/blob/bffcfa752ad4e523cc8f720afeb5b985ed41ae16/v2/json2/client.go#L42-L50
144,243
gorilla/rpc
v2/protorpc/server.go
ReadRequest
func (c *CodecRequest) ReadRequest(args interface{}) error { if c.err == nil { if c.request.Params != nil { c.err = json.Unmarshal(*c.request.Params, args) } else { c.err = errors.New("rpc: method request ill-formed: missing params field") } } return c.err }
go
func (c *CodecRequest) ReadRequest(args interface{}) error { if c.err == nil { if c.request.Params != nil { c.err = json.Unmarshal(*c.request.Params, args) } else { c.err = errors.New("rpc: method request ill-formed: missing params field") } } return c.err }
[ "func", "(", "c", "*", "CodecRequest", ")", "ReadRequest", "(", "args", "interface", "{", "}", ")", "error", "{", "if", "c", ".", "err", "==", "nil", "{", "if", "c", ".", "request", ".", "Params", "!=", "nil", "{", "c", ".", "err", "=", "json", ...
// ReadRequest fills the request object for the RPC method.
[ "ReadRequest", "fills", "the", "request", "object", "for", "the", "RPC", "method", "." ]
bffcfa752ad4e523cc8f720afeb5b985ed41ae16
https://github.com/gorilla/rpc/blob/bffcfa752ad4e523cc8f720afeb5b985ed41ae16/v2/protorpc/server.go#L106-L115
144,244
gorilla/rpc
v2/protorpc/server.go
WriteResponse
func (c *CodecRequest) WriteResponse(w http.ResponseWriter, reply interface{}) { res := &serverResponse{ Result: reply, Error: &null, Id: c.request.Id, } c.writeServerResponse(w, 200, res) }
go
func (c *CodecRequest) WriteResponse(w http.ResponseWriter, reply interface{}) { res := &serverResponse{ Result: reply, Error: &null, Id: c.request.Id, } c.writeServerResponse(w, 200, res) }
[ "func", "(", "c", "*", "CodecRequest", ")", "WriteResponse", "(", "w", "http", ".", "ResponseWriter", ",", "reply", "interface", "{", "}", ")", "{", "res", ":=", "&", "serverResponse", "{", "Result", ":", "reply", ",", "Error", ":", "&", "null", ",", ...
// WriteResponse encodes the response and writes it to the ResponseWriter.
[ "WriteResponse", "encodes", "the", "response", "and", "writes", "it", "to", "the", "ResponseWriter", "." ]
bffcfa752ad4e523cc8f720afeb5b985ed41ae16
https://github.com/gorilla/rpc/blob/bffcfa752ad4e523cc8f720afeb5b985ed41ae16/v2/protorpc/server.go#L118-L125
144,245
gorilla/rpc
v2/json2/server.go
NewCustomCodecWithErrorMapper
func NewCustomCodecWithErrorMapper(encSel rpc.EncoderSelector, errorMapper func(error) error) *Codec { return &Codec{ encSel: encSel, errorMapper: errorMapper, } }
go
func NewCustomCodecWithErrorMapper(encSel rpc.EncoderSelector, errorMapper func(error) error) *Codec { return &Codec{ encSel: encSel, errorMapper: errorMapper, } }
[ "func", "NewCustomCodecWithErrorMapper", "(", "encSel", "rpc", ".", "EncoderSelector", ",", "errorMapper", "func", "(", "error", ")", "error", ")", "*", "Codec", "{", "return", "&", "Codec", "{", "encSel", ":", "encSel", ",", "errorMapper", ":", "errorMapper",...
// NewCustomCodecWithErrorMapper returns a new JSON Codec based on the passed encoder selector // and also accepts an errorMapper function. // The errorMapper function will be called if the Service implementation returns an error, with that // error as a param, replacing it by the value returned by this function. This ...
[ "NewCustomCodecWithErrorMapper", "returns", "a", "new", "JSON", "Codec", "based", "on", "the", "passed", "encoder", "selector", "and", "also", "accepts", "an", "errorMapper", "function", ".", "The", "errorMapper", "function", "will", "be", "called", "if", "the", ...
bffcfa752ad4e523cc8f720afeb5b985ed41ae16
https://github.com/gorilla/rpc/blob/bffcfa752ad4e523cc8f720afeb5b985ed41ae16/v2/json2/server.go#L73-L78
144,246
brocaar/lorawan
phypayload.go
MarshalBinary
func (k AES128Key) MarshalBinary() ([]byte, error) { b := make([]byte, len(k)) for i, v := range k { // little endian b[len(k)-i-1] = v } return b, nil }
go
func (k AES128Key) MarshalBinary() ([]byte, error) { b := make([]byte, len(k)) for i, v := range k { // little endian b[len(k)-i-1] = v } return b, nil }
[ "func", "(", "k", "AES128Key", ")", "MarshalBinary", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "b", ":=", "make", "(", "[", "]", "byte", ",", "len", "(", "k", ")", ")", "\n", "for", "i", ",", "v", ":=", "range", "k", "{", "//...
// MarshalBinary encodes the key to a slice of bytes.
[ "MarshalBinary", "encodes", "the", "key", "to", "a", "slice", "of", "bytes", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L107-L114
144,247
brocaar/lorawan
phypayload.go
UnmarshalBinary
func (k *AES128Key) UnmarshalBinary(data []byte) error { if len(data) != len(k) { return fmt.Errorf("lorawan: %d bytes of data are expected", len(k)) } for i, v := range data { // little endian k[len(k)-i-1] = v } return nil }
go
func (k *AES128Key) UnmarshalBinary(data []byte) error { if len(data) != len(k) { return fmt.Errorf("lorawan: %d bytes of data are expected", len(k)) } for i, v := range data { // little endian k[len(k)-i-1] = v } return nil }
[ "func", "(", "k", "*", "AES128Key", ")", "UnmarshalBinary", "(", "data", "[", "]", "byte", ")", "error", "{", "if", "len", "(", "data", ")", "!=", "len", "(", "k", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "len", "(", "k",...
// UnmarshalBinary decodes the key from a slice of bytes.
[ "UnmarshalBinary", "decodes", "the", "key", "from", "a", "slice", "of", "bytes", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L117-L128
144,248
brocaar/lorawan
phypayload.go
SetUplinkDataMIC
func (p *PHYPayload) SetUplinkDataMIC(macVersion MACVersion, confFCnt uint32, txDR, txCh uint8, fNwkSIntKey, sNwkSIntKey AES128Key) error { mic, err := p.calculateUplinkDataMIC(macVersion, confFCnt, txDR, txCh, fNwkSIntKey, sNwkSIntKey) if err != nil { return err } p.MIC = mic return nil }
go
func (p *PHYPayload) SetUplinkDataMIC(macVersion MACVersion, confFCnt uint32, txDR, txCh uint8, fNwkSIntKey, sNwkSIntKey AES128Key) error { mic, err := p.calculateUplinkDataMIC(macVersion, confFCnt, txDR, txCh, fNwkSIntKey, sNwkSIntKey) if err != nil { return err } p.MIC = mic return nil }
[ "func", "(", "p", "*", "PHYPayload", ")", "SetUplinkDataMIC", "(", "macVersion", "MACVersion", ",", "confFCnt", "uint32", ",", "txDR", ",", "txCh", "uint8", ",", "fNwkSIntKey", ",", "sNwkSIntKey", "AES128Key", ")", "error", "{", "mic", ",", "err", ":=", "p...
// SetUplinkDataMIC calculates and sets the MIC field for uplink data frames. // The confirmed frame-counter, TX data-rate TX channel index and SNwkSIntKey // are only required for LoRaWAN 1.1 and can be left blank otherwise.
[ "SetUplinkDataMIC", "calculates", "and", "sets", "the", "MIC", "field", "for", "uplink", "data", "frames", ".", "The", "confirmed", "frame", "-", "counter", "TX", "data", "-", "rate", "TX", "channel", "index", "and", "SNwkSIntKey", "are", "only", "required", ...
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L174-L181
144,249
brocaar/lorawan
phypayload.go
SetDownlinkDataMIC
func (p *PHYPayload) SetDownlinkDataMIC(macVersion MACVersion, confFCnt uint32, sNwkSIntKey AES128Key) error { mic, err := p.calculateDownlinkDataMIC(macVersion, confFCnt, sNwkSIntKey) if err != nil { return err } p.MIC = mic return nil }
go
func (p *PHYPayload) SetDownlinkDataMIC(macVersion MACVersion, confFCnt uint32, sNwkSIntKey AES128Key) error { mic, err := p.calculateDownlinkDataMIC(macVersion, confFCnt, sNwkSIntKey) if err != nil { return err } p.MIC = mic return nil }
[ "func", "(", "p", "*", "PHYPayload", ")", "SetDownlinkDataMIC", "(", "macVersion", "MACVersion", ",", "confFCnt", "uint32", ",", "sNwkSIntKey", "AES128Key", ")", "error", "{", "mic", ",", "err", ":=", "p", ".", "calculateDownlinkDataMIC", "(", "macVersion", ",...
// SetDownlinkDataMIC calculates and sets the MIC field for downlink data frames. // The confirmed frame-counter and is only required for LoRaWAN 1.1 and can be // left blank otherwise.
[ "SetDownlinkDataMIC", "calculates", "and", "sets", "the", "MIC", "field", "for", "downlink", "data", "frames", ".", "The", "confirmed", "frame", "-", "counter", "and", "is", "only", "required", "for", "LoRaWAN", "1", ".", "1", "and", "can", "be", "left", "...
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L200-L207
144,250
brocaar/lorawan
phypayload.go
ValidateDownlinkDataMIC
func (p PHYPayload) ValidateDownlinkDataMIC(macVersion MACVersion, confFCnt uint32, sNwkSIntKey AES128Key) (bool, error) { mic, err := p.calculateDownlinkDataMIC(macVersion, confFCnt, sNwkSIntKey) if err != nil { return false, err } return p.MIC == mic, nil }
go
func (p PHYPayload) ValidateDownlinkDataMIC(macVersion MACVersion, confFCnt uint32, sNwkSIntKey AES128Key) (bool, error) { mic, err := p.calculateDownlinkDataMIC(macVersion, confFCnt, sNwkSIntKey) if err != nil { return false, err } return p.MIC == mic, nil }
[ "func", "(", "p", "PHYPayload", ")", "ValidateDownlinkDataMIC", "(", "macVersion", "MACVersion", ",", "confFCnt", "uint32", ",", "sNwkSIntKey", "AES128Key", ")", "(", "bool", ",", "error", ")", "{", "mic", ",", "err", ":=", "p", ".", "calculateDownlinkDataMIC"...
// ValidateDownlinkDataMIC validates the MIC of a downlink data frame. // In order to validate the MIC, the FCnt value must first be set to the // full 32 bit frame-counter value, as only the 16 least-significant bits // are transmitted. // The confirmed frame-counter and is only required for LoRaWAN 1.1 and can be // ...
[ "ValidateDownlinkDataMIC", "validates", "the", "MIC", "of", "a", "downlink", "data", "frame", ".", "In", "order", "to", "validate", "the", "MIC", "the", "FCnt", "value", "must", "first", "be", "set", "to", "the", "full", "32", "bit", "frame", "-", "counter...
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L215-L221
144,251
brocaar/lorawan
phypayload.go
SetUplinkJoinMIC
func (p *PHYPayload) SetUplinkJoinMIC(key AES128Key) error { mic, err := p.calculateUplinkJoinMIC(key) if err != nil { return err } p.MIC = mic return nil }
go
func (p *PHYPayload) SetUplinkJoinMIC(key AES128Key) error { mic, err := p.calculateUplinkJoinMIC(key) if err != nil { return err } p.MIC = mic return nil }
[ "func", "(", "p", "*", "PHYPayload", ")", "SetUplinkJoinMIC", "(", "key", "AES128Key", ")", "error", "{", "mic", ",", "err", ":=", "p", ".", "calculateUplinkJoinMIC", "(", "key", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "...
// SetUplinkJoinMIC calculates and sets the MIC field for uplink join requests.
[ "SetUplinkJoinMIC", "calculates", "and", "sets", "the", "MIC", "field", "for", "uplink", "join", "requests", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L224-L231
144,252
brocaar/lorawan
phypayload.go
ValidateUplinkJoinMIC
func (p PHYPayload) ValidateUplinkJoinMIC(key AES128Key) (bool, error) { mic, err := p.calculateUplinkJoinMIC(key) if err != nil { return false, err } return p.MIC == mic, nil }
go
func (p PHYPayload) ValidateUplinkJoinMIC(key AES128Key) (bool, error) { mic, err := p.calculateUplinkJoinMIC(key) if err != nil { return false, err } return p.MIC == mic, nil }
[ "func", "(", "p", "PHYPayload", ")", "ValidateUplinkJoinMIC", "(", "key", "AES128Key", ")", "(", "bool", ",", "error", ")", "{", "mic", ",", "err", ":=", "p", ".", "calculateUplinkJoinMIC", "(", "key", ")", "\n", "if", "err", "!=", "nil", "{", "return"...
// ValidateUplinkJoinMIC validates the MIC of an uplink join request.
[ "ValidateUplinkJoinMIC", "validates", "the", "MIC", "of", "an", "uplink", "join", "request", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L234-L240
144,253
brocaar/lorawan
phypayload.go
SetDownlinkJoinMIC
func (p *PHYPayload) SetDownlinkJoinMIC(joinReqType JoinType, joinEUI EUI64, devNonce DevNonce, key AES128Key) error { mic, err := p.calculateDownlinkJoinMIC(joinReqType, joinEUI, devNonce, key) if err != nil { return err } p.MIC = mic return nil }
go
func (p *PHYPayload) SetDownlinkJoinMIC(joinReqType JoinType, joinEUI EUI64, devNonce DevNonce, key AES128Key) error { mic, err := p.calculateDownlinkJoinMIC(joinReqType, joinEUI, devNonce, key) if err != nil { return err } p.MIC = mic return nil }
[ "func", "(", "p", "*", "PHYPayload", ")", "SetDownlinkJoinMIC", "(", "joinReqType", "JoinType", ",", "joinEUI", "EUI64", ",", "devNonce", "DevNonce", ",", "key", "AES128Key", ")", "error", "{", "mic", ",", "err", ":=", "p", ".", "calculateDownlinkJoinMIC", "...
// SetDownlinkJoinMIC calculates and sets the MIC field for downlink join requests.
[ "SetDownlinkJoinMIC", "calculates", "and", "sets", "the", "MIC", "field", "for", "downlink", "join", "requests", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L243-L250
144,254
brocaar/lorawan
phypayload.go
EncryptFOpts
func (p *PHYPayload) EncryptFOpts(nwkSEncKey AES128Key) error { macPL, ok := p.MACPayload.(*MACPayload) if !ok { return errors.New("lorawan: MACPayload must be of type *MACPayload") } // nothing to encrypt if len(macPL.FHDR.FOpts) == 0 { return nil } var macB []byte for _, mac := range macPL.FHDR.FOpts { ...
go
func (p *PHYPayload) EncryptFOpts(nwkSEncKey AES128Key) error { macPL, ok := p.MACPayload.(*MACPayload) if !ok { return errors.New("lorawan: MACPayload must be of type *MACPayload") } // nothing to encrypt if len(macPL.FHDR.FOpts) == 0 { return nil } var macB []byte for _, mac := range macPL.FHDR.FOpts { ...
[ "func", "(", "p", "*", "PHYPayload", ")", "EncryptFOpts", "(", "nwkSEncKey", "AES128Key", ")", "error", "{", "macPL", ",", "ok", ":=", "p", ".", "MACPayload", ".", "(", "*", "MACPayload", ")", "\n", "if", "!", "ok", "{", "return", "errors", ".", "New...
// EncryptFOpts encrypts the FOpts with the given key.
[ "EncryptFOpts", "encrypts", "the", "FOpts", "with", "the", "given", "key", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L340-L376
144,255
brocaar/lorawan
phypayload.go
DecryptFOpts
func (p *PHYPayload) DecryptFOpts(nwkSEncKey AES128Key) error { if err := p.EncryptFOpts(nwkSEncKey); err != nil { return nil } return p.DecodeFOptsToMACCommands() }
go
func (p *PHYPayload) DecryptFOpts(nwkSEncKey AES128Key) error { if err := p.EncryptFOpts(nwkSEncKey); err != nil { return nil } return p.DecodeFOptsToMACCommands() }
[ "func", "(", "p", "*", "PHYPayload", ")", "DecryptFOpts", "(", "nwkSEncKey", "AES128Key", ")", "error", "{", "if", "err", ":=", "p", ".", "EncryptFOpts", "(", "nwkSEncKey", ")", ";", "err", "!=", "nil", "{", "return", "nil", "\n", "}", "\n\n", "return"...
// DecryptFOpts decrypts the FOpts payload and decodes it into mac-command // structures.
[ "DecryptFOpts", "decrypts", "the", "FOpts", "payload", "and", "decodes", "it", "into", "mac", "-", "command", "structures", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L380-L386
144,256
brocaar/lorawan
phypayload.go
EncryptFRMPayload
func (p *PHYPayload) EncryptFRMPayload(key AES128Key) error { macPL, ok := p.MACPayload.(*MACPayload) if !ok { return errors.New("lorawan: MACPayload must be of type *MACPayload") } // nothing to encrypt if len(macPL.FRMPayload) == 0 { return nil } data, err := macPL.marshalPayload() if err != nil { ret...
go
func (p *PHYPayload) EncryptFRMPayload(key AES128Key) error { macPL, ok := p.MACPayload.(*MACPayload) if !ok { return errors.New("lorawan: MACPayload must be of type *MACPayload") } // nothing to encrypt if len(macPL.FRMPayload) == 0 { return nil } data, err := macPL.marshalPayload() if err != nil { ret...
[ "func", "(", "p", "*", "PHYPayload", ")", "EncryptFRMPayload", "(", "key", "AES128Key", ")", "error", "{", "macPL", ",", "ok", ":=", "p", ".", "MACPayload", ".", "(", "*", "MACPayload", ")", "\n", "if", "!", "ok", "{", "return", "errors", ".", "New",...
// EncryptFRMPayload encrypts the FRMPayload with the given key.
[ "EncryptFRMPayload", "encrypts", "the", "FRMPayload", "with", "the", "given", "key", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L389-L414
144,257
brocaar/lorawan
phypayload.go
DecryptFRMPayload
func (p *PHYPayload) DecryptFRMPayload(key AES128Key) error { if err := p.EncryptFRMPayload(key); err != nil { return err } macPL, ok := p.MACPayload.(*MACPayload) if !ok { return errors.New("lorawan: MACPayload must be of type *MACPayload") } // the FRMPayload contains MAC commands, which we need to unmars...
go
func (p *PHYPayload) DecryptFRMPayload(key AES128Key) error { if err := p.EncryptFRMPayload(key); err != nil { return err } macPL, ok := p.MACPayload.(*MACPayload) if !ok { return errors.New("lorawan: MACPayload must be of type *MACPayload") } // the FRMPayload contains MAC commands, which we need to unmars...
[ "func", "(", "p", "*", "PHYPayload", ")", "DecryptFRMPayload", "(", "key", "AES128Key", ")", "error", "{", "if", "err", ":=", "p", ".", "EncryptFRMPayload", "(", "key", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "macPL", "...
// DecryptFRMPayload decrypts the FRMPayload with the given key.
[ "DecryptFRMPayload", "decrypts", "the", "FRMPayload", "with", "the", "given", "key", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L417-L434
144,258
brocaar/lorawan
phypayload.go
MarshalText
func (p PHYPayload) MarshalText() ([]byte, error) { b, err := p.MarshalBinary() if err != nil { return nil, err } return []byte(base64.StdEncoding.EncodeToString(b)), nil }
go
func (p PHYPayload) MarshalText() ([]byte, error) { b, err := p.MarshalBinary() if err != nil { return nil, err } return []byte(base64.StdEncoding.EncodeToString(b)), nil }
[ "func", "(", "p", "PHYPayload", ")", "MarshalText", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "b", ",", "err", ":=", "p", ".", "MarshalBinary", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}"...
// MarshalText encodes the PHYPayload into base64.
[ "MarshalText", "encodes", "the", "PHYPayload", "into", "base64", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L535-L541
144,259
brocaar/lorawan
phypayload.go
UnmarshalText
func (p *PHYPayload) UnmarshalText(text []byte) error { b, err := base64.StdEncoding.DecodeString(string(text)) if err != nil { return err } return p.UnmarshalBinary(b) }
go
func (p *PHYPayload) UnmarshalText(text []byte) error { b, err := base64.StdEncoding.DecodeString(string(text)) if err != nil { return err } return p.UnmarshalBinary(b) }
[ "func", "(", "p", "*", "PHYPayload", ")", "UnmarshalText", "(", "text", "[", "]", "byte", ")", "error", "{", "b", ",", "err", ":=", "base64", ".", "StdEncoding", ".", "DecodeString", "(", "string", "(", "text", ")", ")", "\n", "if", "err", "!=", "n...
// UnmarshalText decodes the PHYPayload from base64.
[ "UnmarshalText", "decodes", "the", "PHYPayload", "from", "base64", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L544-L550
144,260
brocaar/lorawan
phypayload.go
MarshalJSON
func (p PHYPayload) MarshalJSON() ([]byte, error) { type phyAlias PHYPayload return json.Marshal(phyAlias(p)) }
go
func (p PHYPayload) MarshalJSON() ([]byte, error) { type phyAlias PHYPayload return json.Marshal(phyAlias(p)) }
[ "func", "(", "p", "PHYPayload", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "type", "phyAlias", "PHYPayload", "\n", "return", "json", ".", "Marshal", "(", "phyAlias", "(", "p", ")", ")", "\n", "}" ]
// MarshalJSON encodes the PHYPayload into JSON.
[ "MarshalJSON", "encodes", "the", "PHYPayload", "into", "JSON", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L553-L556
144,261
brocaar/lorawan
applayer/multicastsetup/multicastsetup.go
GetCommandPayload
func GetCommandPayload(uplink bool, c CID) (CommandPayload, error) { v, ok := commandPayloadRegistry[uplink][c] if !ok { return nil, ErrNoPayloadForCID } return v(), nil }
go
func GetCommandPayload(uplink bool, c CID) (CommandPayload, error) { v, ok := commandPayloadRegistry[uplink][c] if !ok { return nil, ErrNoPayloadForCID } return v(), nil }
[ "func", "GetCommandPayload", "(", "uplink", "bool", ",", "c", "CID", ")", "(", "CommandPayload", ",", "error", ")", "{", "v", ",", "ok", ":=", "commandPayloadRegistry", "[", "uplink", "]", "[", "c", "]", "\n", "if", "!", "ok", "{", "return", "nil", "...
// GetCommandPayload returns a new CommandPayload for the given CID.
[ "GetCommandPayload", "returns", "a", "new", "CommandPayload", "for", "the", "given", "CID", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/applayer/multicastsetup/multicastsetup.go#L61-L68
144,262
brocaar/lorawan
applayer/multicastsetup/multicastsetup.go
MarshalBinary
func (c Command) MarshalBinary() ([]byte, error) { b := []byte{byte(c.CID)} if c.Payload != nil { p, err := c.Payload.MarshalBinary() if err != nil { return nil, err } b = append(b, p...) } return b, nil }
go
func (c Command) MarshalBinary() ([]byte, error) { b := []byte{byte(c.CID)} if c.Payload != nil { p, err := c.Payload.MarshalBinary() if err != nil { return nil, err } b = append(b, p...) } return b, nil }
[ "func", "(", "c", "Command", ")", "MarshalBinary", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "b", ":=", "[", "]", "byte", "{", "byte", "(", "c", ".", "CID", ")", "}", "\n\n", "if", "c", ".", "Payload", "!=", "nil", "{", "p", ...
// MarshalBinary encodes the command to a slice of bytes.
[ "MarshalBinary", "encodes", "the", "command", "to", "a", "slice", "of", "bytes", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/applayer/multicastsetup/multicastsetup.go#L84-L96
144,263
brocaar/lorawan
applayer/multicastsetup/multicastsetup.go
UnmarshalBinary
func (c *Command) UnmarshalBinary(uplink bool, data []byte) error { if len(data) == 0 { return errors.New("lorawan/applayer/multicastsetup: at least 1 byte is expected") } c.CID = CID(data[0]) p, err := GetCommandPayload(uplink, c.CID) if err != nil { if err == ErrNoPayloadForCID { return nil } return...
go
func (c *Command) UnmarshalBinary(uplink bool, data []byte) error { if len(data) == 0 { return errors.New("lorawan/applayer/multicastsetup: at least 1 byte is expected") } c.CID = CID(data[0]) p, err := GetCommandPayload(uplink, c.CID) if err != nil { if err == ErrNoPayloadForCID { return nil } return...
[ "func", "(", "c", "*", "Command", ")", "UnmarshalBinary", "(", "uplink", "bool", ",", "data", "[", "]", "byte", ")", "error", "{", "if", "len", "(", "data", ")", "==", "0", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "...
// UnmarshalBinary decodes a slice of bytes into a command.
[ "UnmarshalBinary", "decodes", "a", "slice", "of", "bytes", "into", "a", "command", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/applayer/multicastsetup/multicastsetup.go#L99-L120
144,264
brocaar/lorawan
applayer/multicastsetup/multicastsetup.go
Size
func (c Command) Size() int { if c.Payload != nil { return c.Payload.Size() + 1 } return 1 }
go
func (c Command) Size() int { if c.Payload != nil { return c.Payload.Size() + 1 } return 1 }
[ "func", "(", "c", "Command", ")", "Size", "(", ")", "int", "{", "if", "c", ".", "Payload", "!=", "nil", "{", "return", "c", ".", "Payload", ".", "Size", "(", ")", "+", "1", "\n", "}", "\n", "return", "1", "\n", "}" ]
// Size returns the size of the command in bytes.
[ "Size", "returns", "the", "size", "of", "the", "command", "in", "bytes", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/applayer/multicastsetup/multicastsetup.go#L123-L128
144,265
brocaar/lorawan
applayer/multicastsetup/multicastsetup.go
MarshalBinary
func (c Commands) MarshalBinary() ([]byte, error) { var out []byte for _, cmd := range c { b, err := cmd.MarshalBinary() if err != nil { return nil, err } out = append(out, b...) } return out, nil }
go
func (c Commands) MarshalBinary() ([]byte, error) { var out []byte for _, cmd := range c { b, err := cmd.MarshalBinary() if err != nil { return nil, err } out = append(out, b...) } return out, nil }
[ "func", "(", "c", "Commands", ")", "MarshalBinary", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "out", "[", "]", "byte", "\n\n", "for", "_", ",", "cmd", ":=", "range", "c", "{", "b", ",", "err", ":=", "cmd", ".", "MarshalBin...
// MarshalBinary encodes the commands to a slice of bytes.
[ "MarshalBinary", "encodes", "the", "commands", "to", "a", "slice", "of", "bytes", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/applayer/multicastsetup/multicastsetup.go#L134-L145
144,266
brocaar/lorawan
applayer/multicastsetup/multicastsetup.go
UnmarshalBinary
func (c *Commands) UnmarshalBinary(uplink bool, data []byte) error { var i int for i < len(data) { var cmd Command if err := cmd.UnmarshalBinary(uplink, data[i:]); err != nil { return err } i += cmd.Size() *c = append(*c, cmd) } return nil }
go
func (c *Commands) UnmarshalBinary(uplink bool, data []byte) error { var i int for i < len(data) { var cmd Command if err := cmd.UnmarshalBinary(uplink, data[i:]); err != nil { return err } i += cmd.Size() *c = append(*c, cmd) } return nil }
[ "func", "(", "c", "*", "Commands", ")", "UnmarshalBinary", "(", "uplink", "bool", ",", "data", "[", "]", "byte", ")", "error", "{", "var", "i", "int", "\n\n", "for", "i", "<", "len", "(", "data", ")", "{", "var", "cmd", "Command", "\n", "if", "er...
// UnmarshalBinary decodes a slice of bytes into a slice of commands.
[ "UnmarshalBinary", "decodes", "a", "slice", "of", "bytes", "into", "a", "slice", "of", "commands", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/applayer/multicastsetup/multicastsetup.go#L148-L161
144,267
brocaar/lorawan
applayer/multicastsetup/multicastsetup.go
Size
func (p McGroupStatusAnsPayload) Size() int { var ansGroupMaskCount int for _, mask := range p.Status.AnsGroupMask { if mask { ansGroupMaskCount++ } } return 1 + (5 * ansGroupMaskCount) }
go
func (p McGroupStatusAnsPayload) Size() int { var ansGroupMaskCount int for _, mask := range p.Status.AnsGroupMask { if mask { ansGroupMaskCount++ } } return 1 + (5 * ansGroupMaskCount) }
[ "func", "(", "p", "McGroupStatusAnsPayload", ")", "Size", "(", ")", "int", "{", "var", "ansGroupMaskCount", "int", "\n", "for", "_", ",", "mask", ":=", "range", "p", ".", "Status", ".", "AnsGroupMask", "{", "if", "mask", "{", "ansGroupMaskCount", "++", "...
// Size returns the payload size in number of bytes.
[ "Size", "returns", "the", "payload", "size", "in", "number", "of", "bytes", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/applayer/multicastsetup/multicastsetup.go#L251-L260
144,268
brocaar/lorawan
applayer/multicastsetup/keys.go
GetMcKEKey
func GetMcKEKey(mcRootKey lorawan.AES128Key) (lorawan.AES128Key, error) { return getKey(mcRootKey, [16]byte{}) }
go
func GetMcKEKey(mcRootKey lorawan.AES128Key) (lorawan.AES128Key, error) { return getKey(mcRootKey, [16]byte{}) }
[ "func", "GetMcKEKey", "(", "mcRootKey", "lorawan", ".", "AES128Key", ")", "(", "lorawan", ".", "AES128Key", ",", "error", ")", "{", "return", "getKey", "(", "mcRootKey", ",", "[", "16", "]", "byte", "{", "}", ")", "\n", "}" ]
// GetMcKEKey returns the McKEKey given the McRootKey.
[ "GetMcKEKey", "returns", "the", "McKEKey", "given", "the", "McRootKey", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/applayer/multicastsetup/keys.go#L23-L25
144,269
brocaar/lorawan
applayer/multicastsetup/keys.go
GetMcAppSKey
func GetMcAppSKey(mcKey lorawan.AES128Key, mcAddr lorawan.DevAddr) (lorawan.AES128Key, error) { b := [16]byte{0x01} mcAddrB, err := mcAddr.MarshalBinary() if err != nil { return lorawan.AES128Key{}, err } copy(b[1:5], mcAddrB) return getKey(mcKey, b) }
go
func GetMcAppSKey(mcKey lorawan.AES128Key, mcAddr lorawan.DevAddr) (lorawan.AES128Key, error) { b := [16]byte{0x01} mcAddrB, err := mcAddr.MarshalBinary() if err != nil { return lorawan.AES128Key{}, err } copy(b[1:5], mcAddrB) return getKey(mcKey, b) }
[ "func", "GetMcAppSKey", "(", "mcKey", "lorawan", ".", "AES128Key", ",", "mcAddr", "lorawan", ".", "DevAddr", ")", "(", "lorawan", ".", "AES128Key", ",", "error", ")", "{", "b", ":=", "[", "16", "]", "byte", "{", "0x01", "}", "\n\n", "mcAddrB", ",", "...
// GetMcAppSKey returns the McAppSKey given the McKey and McAddr.
[ "GetMcAppSKey", "returns", "the", "McAppSKey", "given", "the", "McKey", "and", "McAddr", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/applayer/multicastsetup/keys.go#L28-L38
144,270
brocaar/lorawan
backend/joinserver/joinserver.go
NewHandler
func NewHandler(config HandlerConfig) (http.Handler, error) { if config.GetDeviceKeysByDevEUIFunc == nil { return nil, errors.New("backend/joinserver: GetDeviceKeysFunc must not be nil") } h := handler{ config: config, log: config.Logger, } if h.log == nil { h.log = &log.Logger{ Out: ioutil.Discard...
go
func NewHandler(config HandlerConfig) (http.Handler, error) { if config.GetDeviceKeysByDevEUIFunc == nil { return nil, errors.New("backend/joinserver: GetDeviceKeysFunc must not be nil") } h := handler{ config: config, log: config.Logger, } if h.log == nil { h.log = &log.Logger{ Out: ioutil.Discard...
[ "func", "NewHandler", "(", "config", "HandlerConfig", ")", "(", "http", ".", "Handler", ",", "error", ")", "{", "if", "config", ".", "GetDeviceKeysByDevEUIFunc", "==", "nil", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", ...
// NewHandler creates a new join-sever handler.
[ "NewHandler", "creates", "a", "new", "join", "-", "sever", "handler", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/backend/joinserver/joinserver.go#L42-L75
144,271
brocaar/lorawan
fhdr.go
NetIDType
func (a DevAddr) NetIDType() int { for i := 0; i < 8; i++ { if a[0]&(0xff<<(byte(7-i))) == 0xff&(0xff<<(byte(8-i))) { return i } } panic("NetIDType bug!") }
go
func (a DevAddr) NetIDType() int { for i := 0; i < 8; i++ { if a[0]&(0xff<<(byte(7-i))) == 0xff&(0xff<<(byte(8-i))) { return i } } panic("NetIDType bug!") }
[ "func", "(", "a", "DevAddr", ")", "NetIDType", "(", ")", "int", "{", "for", "i", ":=", "0", ";", "i", "<", "8", ";", "i", "++", "{", "if", "a", "[", "0", "]", "&", "(", "0xff", "<<", "(", "byte", "(", "7", "-", "i", ")", ")", ")", "==",...
// NetIDType returns the NetID type of the DevAddr.
[ "NetIDType", "returns", "the", "NetID", "type", "of", "the", "DevAddr", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/fhdr.go#L14-L21
144,272
brocaar/lorawan
fhdr.go
NwkID
func (a DevAddr) NwkID() []byte { switch a.NetIDType() { case 0: return a.getNwkID(1, 6) case 1: return a.getNwkID(2, 6) case 2: return a.getNwkID(3, 9) case 3: return a.getNwkID(4, 10) case 4: return a.getNwkID(5, 11) case 5: return a.getNwkID(6, 13) case 6: return a.getNwkID(7, 15) case 7: re...
go
func (a DevAddr) NwkID() []byte { switch a.NetIDType() { case 0: return a.getNwkID(1, 6) case 1: return a.getNwkID(2, 6) case 2: return a.getNwkID(3, 9) case 3: return a.getNwkID(4, 10) case 4: return a.getNwkID(5, 11) case 5: return a.getNwkID(6, 13) case 6: return a.getNwkID(7, 15) case 7: re...
[ "func", "(", "a", "DevAddr", ")", "NwkID", "(", ")", "[", "]", "byte", "{", "switch", "a", ".", "NetIDType", "(", ")", "{", "case", "0", ":", "return", "a", ".", "getNwkID", "(", "1", ",", "6", ")", "\n", "case", "1", ":", "return", "a", ".",...
// NwkID returns the NwkID bits of the DevAddr.
[ "NwkID", "returns", "the", "NwkID", "bits", "of", "the", "DevAddr", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/fhdr.go#L24-L45
144,273
brocaar/lorawan
fhdr.go
SetAddrPrefix
func (a *DevAddr) SetAddrPrefix(netID NetID) { switch netID.Type() { case 0: a.setAddrPrefix(1, 6, netID) case 1: a.setAddrPrefix(2, 6, netID) case 2: a.setAddrPrefix(3, 9, netID) case 3: a.setAddrPrefix(4, 10, netID) case 4: a.setAddrPrefix(5, 11, netID) case 5: a.setAddrPrefix(6, 13, netID) case 6...
go
func (a *DevAddr) SetAddrPrefix(netID NetID) { switch netID.Type() { case 0: a.setAddrPrefix(1, 6, netID) case 1: a.setAddrPrefix(2, 6, netID) case 2: a.setAddrPrefix(3, 9, netID) case 3: a.setAddrPrefix(4, 10, netID) case 4: a.setAddrPrefix(5, 11, netID) case 5: a.setAddrPrefix(6, 13, netID) case 6...
[ "func", "(", "a", "*", "DevAddr", ")", "SetAddrPrefix", "(", "netID", "NetID", ")", "{", "switch", "netID", ".", "Type", "(", ")", "{", "case", "0", ":", "a", ".", "setAddrPrefix", "(", "1", ",", "6", ",", "netID", ")", "\n", "case", "1", ":", ...
// SetAddrPrefix sets the NetID based AddrPrefix.
[ "SetAddrPrefix", "sets", "the", "NetID", "based", "AddrPrefix", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/fhdr.go#L48-L67
144,274
brocaar/lorawan
fhdr.go
IsNetID
func (a DevAddr) IsNetID(netID NetID) bool { tempDevAddr := a tempDevAddr.SetAddrPrefix(netID) if a == tempDevAddr { return true } return false }
go
func (a DevAddr) IsNetID(netID NetID) bool { tempDevAddr := a tempDevAddr.SetAddrPrefix(netID) if a == tempDevAddr { return true } return false }
[ "func", "(", "a", "DevAddr", ")", "IsNetID", "(", "netID", "NetID", ")", "bool", "{", "tempDevAddr", ":=", "a", "\n", "tempDevAddr", ".", "SetAddrPrefix", "(", "netID", ")", "\n\n", "if", "a", "==", "tempDevAddr", "{", "return", "true", "\n", "}", "\n\...
// IsNetID returns a bool indicating if the NwkID matches the given NetID.
[ "IsNetID", "returns", "a", "bool", "indicating", "if", "the", "NwkID", "matches", "the", "given", "NetID", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/fhdr.go#L70-L79
144,275
brocaar/lorawan
netid.go
ID
func (n NetID) ID() []byte { switch n.Type() { case 0, 1: return n.getID(6) case 2: return n.getID(9) case 3, 4, 5, 6, 7: return n.getID(21) default: return nil } }
go
func (n NetID) ID() []byte { switch n.Type() { case 0, 1: return n.getID(6) case 2: return n.getID(9) case 3, 4, 5, 6, 7: return n.getID(21) default: return nil } }
[ "func", "(", "n", "NetID", ")", "ID", "(", ")", "[", "]", "byte", "{", "switch", "n", ".", "Type", "(", ")", "{", "case", "0", ",", "1", ":", "return", "n", ".", "getID", "(", "6", ")", "\n", "case", "2", ":", "return", "n", ".", "getID", ...
// ID returns the NetID ID part.
[ "ID", "returns", "the", "NetID", "ID", "part", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/netid.go#L20-L31
144,276
brocaar/lorawan
airtime/airtime.go
CalculateLoRaAirtime
func CalculateLoRaAirtime(payloadSize, sf, bandwidth, preambleNumber int, codingRate CodingRate, headerEnabled, lowDataRateOptimization bool) (time.Duration, error) { symbolDuration := CalculateLoRaSymbolDuration(sf, bandwidth) preambleDuration := CalculateLoRaPreambleDuration(symbolDuration, preambleNumber) payloa...
go
func CalculateLoRaAirtime(payloadSize, sf, bandwidth, preambleNumber int, codingRate CodingRate, headerEnabled, lowDataRateOptimization bool) (time.Duration, error) { symbolDuration := CalculateLoRaSymbolDuration(sf, bandwidth) preambleDuration := CalculateLoRaPreambleDuration(symbolDuration, preambleNumber) payloa...
[ "func", "CalculateLoRaAirtime", "(", "payloadSize", ",", "sf", ",", "bandwidth", ",", "preambleNumber", "int", ",", "codingRate", "CodingRate", ",", "headerEnabled", ",", "lowDataRateOptimization", "bool", ")", "(", "time", ".", "Duration", ",", "error", ")", "{...
// CalculateLoRaAirtime calculates the airtime for a LoRa modulated frame.
[ "CalculateLoRaAirtime", "calculates", "the", "airtime", "for", "a", "LoRa", "modulated", "frame", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/airtime/airtime.go#L24-L34
144,277
brocaar/lorawan
airtime/airtime.go
CalculateLoRaSymbolDuration
func CalculateLoRaSymbolDuration(sf int, bandwidth int) time.Duration { return time.Duration((1 << uint(sf)) * 1000000 / bandwidth) }
go
func CalculateLoRaSymbolDuration(sf int, bandwidth int) time.Duration { return time.Duration((1 << uint(sf)) * 1000000 / bandwidth) }
[ "func", "CalculateLoRaSymbolDuration", "(", "sf", "int", ",", "bandwidth", "int", ")", "time", ".", "Duration", "{", "return", "time", ".", "Duration", "(", "(", "1", "<<", "uint", "(", "sf", ")", ")", "*", "1000000", "/", "bandwidth", ")", "\n", "}" ]
// CalculateLoRaSymbolDuration calculates the LoRa symbol duration.
[ "CalculateLoRaSymbolDuration", "calculates", "the", "LoRa", "symbol", "duration", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/airtime/airtime.go#L37-L39
144,278
brocaar/lorawan
airtime/airtime.go
CalculateLoRaPreambleDuration
func CalculateLoRaPreambleDuration(symbolDuration time.Duration, preambleNumber int) time.Duration { return time.Duration((100*preambleNumber)+425) * symbolDuration / 100 }
go
func CalculateLoRaPreambleDuration(symbolDuration time.Duration, preambleNumber int) time.Duration { return time.Duration((100*preambleNumber)+425) * symbolDuration / 100 }
[ "func", "CalculateLoRaPreambleDuration", "(", "symbolDuration", "time", ".", "Duration", ",", "preambleNumber", "int", ")", "time", ".", "Duration", "{", "return", "time", ".", "Duration", "(", "(", "100", "*", "preambleNumber", ")", "+", "425", ")", "*", "s...
// CalculateLoRaPreambleDuration calculates the LoRa preamble duration.
[ "CalculateLoRaPreambleDuration", "calculates", "the", "LoRa", "preamble", "duration", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/airtime/airtime.go#L42-L44
144,279
brocaar/lorawan
airtime/airtime.go
CalculateLoRaPayloadSymbolNumber
func CalculateLoRaPayloadSymbolNumber(payloadSize, sf int, codingRate CodingRate, headerEnabled, lowDataRateOptimization bool) (int, error) { var pl, spreadingFactor, h, de, cr float64 if codingRate < 1 || codingRate > 4 { return 0, errors.New("codingRate must be between 1 - 4") } if lowDataRateOptimization { ...
go
func CalculateLoRaPayloadSymbolNumber(payloadSize, sf int, codingRate CodingRate, headerEnabled, lowDataRateOptimization bool) (int, error) { var pl, spreadingFactor, h, de, cr float64 if codingRate < 1 || codingRate > 4 { return 0, errors.New("codingRate must be between 1 - 4") } if lowDataRateOptimization { ...
[ "func", "CalculateLoRaPayloadSymbolNumber", "(", "payloadSize", ",", "sf", "int", ",", "codingRate", "CodingRate", ",", "headerEnabled", ",", "lowDataRateOptimization", "bool", ")", "(", "int", ",", "error", ")", "{", "var", "pl", ",", "spreadingFactor", ",", "h...
// CalculateLoRaPayloadSymbolNumber returns the number of symbols that make // up the packet payload and header.
[ "CalculateLoRaPayloadSymbolNumber", "returns", "the", "number", "of", "symbols", "that", "make", "up", "the", "packet", "payload", "and", "header", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/airtime/airtime.go#L48-L72
144,280
brocaar/lorawan
applayer/fragmentation/encode.go
Encode
func Encode(data []byte, fragmentSize, redundancy int) ([][]byte, error) { if len(data)%fragmentSize != 0 { return nil, errors.New("length of data must be a multiple of the given fragment-size") } // fragment the data into rows var dataRows [][]byte for i := 0; i < len(data)/fragmentSize; i++ { offset := i * ...
go
func Encode(data []byte, fragmentSize, redundancy int) ([][]byte, error) { if len(data)%fragmentSize != 0 { return nil, errors.New("length of data must be a multiple of the given fragment-size") } // fragment the data into rows var dataRows [][]byte for i := 0; i < len(data)/fragmentSize; i++ { offset := i * ...
[ "func", "Encode", "(", "data", "[", "]", "byte", ",", "fragmentSize", ",", "redundancy", "int", ")", "(", "[", "]", "[", "]", "byte", ",", "error", ")", "{", "if", "len", "(", "data", ")", "%", "fragmentSize", "!=", "0", "{", "return", "nil", ","...
// Encode encodes the given slice of bytes to fragments including forward error correction. // This is based on the proposed FEC code from the Fragmented Data Block Transport over // LoRaWAN recommendation.
[ "Encode", "encodes", "the", "given", "slice", "of", "bytes", "to", "fragments", "including", "forward", "error", "correction", ".", "This", "is", "based", "on", "the", "proposed", "FEC", "code", "from", "the", "Fragmented", "Data", "Block", "Transport", "over"...
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/applayer/fragmentation/encode.go#L10-L39
144,281
brocaar/lorawan
backend/joinserver/session_keys.go
getJSIntKey
func getJSIntKey(nwkKey lorawan.AES128Key, devEUI lorawan.EUI64) (lorawan.AES128Key, error) { return getJSKey(0x06, devEUI, nwkKey) }
go
func getJSIntKey(nwkKey lorawan.AES128Key, devEUI lorawan.EUI64) (lorawan.AES128Key, error) { return getJSKey(0x06, devEUI, nwkKey) }
[ "func", "getJSIntKey", "(", "nwkKey", "lorawan", ".", "AES128Key", ",", "devEUI", "lorawan", ".", "EUI64", ")", "(", "lorawan", ".", "AES128Key", ",", "error", ")", "{", "return", "getJSKey", "(", "0x06", ",", "devEUI", ",", "nwkKey", ")", "\n", "}" ]
// getJSIntKey returns the JSIntKey.
[ "getJSIntKey", "returns", "the", "JSIntKey", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/backend/joinserver/session_keys.go#L34-L36
144,282
brocaar/lorawan
backend/joinserver/session_keys.go
getJSEncKey
func getJSEncKey(nwkKey lorawan.AES128Key, devEUI lorawan.EUI64) (lorawan.AES128Key, error) { return getJSKey(0x05, devEUI, nwkKey) }
go
func getJSEncKey(nwkKey lorawan.AES128Key, devEUI lorawan.EUI64) (lorawan.AES128Key, error) { return getJSKey(0x05, devEUI, nwkKey) }
[ "func", "getJSEncKey", "(", "nwkKey", "lorawan", ".", "AES128Key", ",", "devEUI", "lorawan", ".", "EUI64", ")", "(", "lorawan", ".", "AES128Key", ",", "error", ")", "{", "return", "getJSKey", "(", "0x05", ",", "devEUI", ",", "nwkKey", ")", "\n", "}" ]
// getJSEncKey returns the JSEncKey.
[ "getJSEncKey", "returns", "the", "JSEncKey", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/backend/joinserver/session_keys.go#L39-L41
144,283
brocaar/lorawan
band/band.go
intSliceDiff
func intSliceDiff(x, y []int) []int { var out []int for _, cX := range x { found := false for _, cY := range y { if cX == cY { found = true break } } if !found { out = append(out, cX) } } for _, cY := range y { found := false for _, cX := range x { if cY == cX { found = true ...
go
func intSliceDiff(x, y []int) []int { var out []int for _, cX := range x { found := false for _, cY := range y { if cX == cY { found = true break } } if !found { out = append(out, cX) } } for _, cY := range y { found := false for _, cX := range x { if cY == cX { found = true ...
[ "func", "intSliceDiff", "(", "x", ",", "y", "[", "]", "int", ")", "[", "]", "int", "{", "var", "out", "[", "]", "int", "\n\n", "for", "_", ",", "cX", ":=", "range", "x", "{", "found", ":=", "false", "\n", "for", "_", ",", "cY", ":=", "range",...
// y that are not in x.
[ "y", "that", "are", "not", "in", "x", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/band/band.go#L558-L588
144,284
brocaar/lorawan
band/band.go
GetConfig
func GetConfig(name Name, repeaterCompatible bool, dt lorawan.DwellTime) (Band, error) { switch name { case AS_923, AS923: return newAS923Band(repeaterCompatible, dt) case AU_915_928, AU915: return newAU915Band(repeaterCompatible, dt) case CN_470_510, CN470: return newCN470Band(repeaterCompatible) case CN_77...
go
func GetConfig(name Name, repeaterCompatible bool, dt lorawan.DwellTime) (Band, error) { switch name { case AS_923, AS923: return newAS923Band(repeaterCompatible, dt) case AU_915_928, AU915: return newAU915Band(repeaterCompatible, dt) case CN_470_510, CN470: return newCN470Band(repeaterCompatible) case CN_77...
[ "func", "GetConfig", "(", "name", "Name", ",", "repeaterCompatible", "bool", ",", "dt", "lorawan", ".", "DwellTime", ")", "(", "Band", ",", "error", ")", "{", "switch", "name", "{", "case", "AS_923", ",", "AS923", ":", "return", "newAS923Band", "(", "rep...
// GetConfig returns the band configuration for the given band. // Please refer to the LoRaWAN specification for more details about the effect // of the repeater and dwell time arguments.
[ "GetConfig", "returns", "the", "band", "configuration", "for", "the", "given", "band", ".", "Please", "refer", "to", "the", "LoRaWAN", "specification", "for", "more", "details", "about", "the", "effect", "of", "the", "repeater", "and", "dwell", "time", "argume...
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/band/band.go#L602-L627
144,285
brocaar/lorawan
mac_commands.go
GetMACPayloadAndSize
func GetMACPayloadAndSize(uplink bool, c CID) (MACCommandPayload, int, error) { macPayloadMutex.RLock() defer macPayloadMutex.RUnlock() v, ok := macPayloadRegistry[uplink][c] if !ok { return nil, 0, fmt.Errorf("lorawan: payload unknown for uplink=%v and CID=%v", uplink, c) } return v.payload(), v.size, nil }
go
func GetMACPayloadAndSize(uplink bool, c CID) (MACCommandPayload, int, error) { macPayloadMutex.RLock() defer macPayloadMutex.RUnlock() v, ok := macPayloadRegistry[uplink][c] if !ok { return nil, 0, fmt.Errorf("lorawan: payload unknown for uplink=%v and CID=%v", uplink, c) } return v.payload(), v.size, nil }
[ "func", "GetMACPayloadAndSize", "(", "uplink", "bool", ",", "c", "CID", ")", "(", "MACCommandPayload", ",", "int", ",", "error", ")", "{", "macPayloadMutex", ".", "RLock", "(", ")", "\n", "defer", "macPayloadMutex", ".", "RUnlock", "(", ")", "\n\n", "v", ...
// GetMACPayloadAndSize returns a new MACCommandPayload instance and it's size.
[ "GetMACPayloadAndSize", "returns", "a", "new", "MACCommandPayload", "instance", "and", "it", "s", "size", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/mac_commands.go#L134-L144
144,286
brocaar/lorawan
mac_commands.go
RegisterProprietaryMACCommand
func RegisterProprietaryMACCommand(uplink bool, cid CID, payloadSize int) error { if !(cid >= 128 && cid <= 255) { return fmt.Errorf("lorawan: invalid CID %x", byte(cid)) } if payloadSize == 0 { // no need to register the payload size return nil } macPayloadMutex.Lock() defer macPayloadMutex.Unlock() ma...
go
func RegisterProprietaryMACCommand(uplink bool, cid CID, payloadSize int) error { if !(cid >= 128 && cid <= 255) { return fmt.Errorf("lorawan: invalid CID %x", byte(cid)) } if payloadSize == 0 { // no need to register the payload size return nil } macPayloadMutex.Lock() defer macPayloadMutex.Unlock() ma...
[ "func", "RegisterProprietaryMACCommand", "(", "uplink", "bool", ",", "cid", "CID", ",", "payloadSize", "int", ")", "error", "{", "if", "!", "(", "cid", ">=", "128", "&&", "cid", "<=", "255", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ...
// RegisterProprietaryMACCommand registers a proprietary MAC command. Note // that there is no need to call this when the size of the payload is > 0 bytes.
[ "RegisterProprietaryMACCommand", "registers", "a", "proprietary", "MAC", "command", ".", "Note", "that", "there", "is", "no", "need", "to", "call", "this", "when", "the", "size", "of", "the", "payload", "is", ">", "0", "bytes", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/mac_commands.go#L148-L167
144,287
brocaar/lorawan
mac_commands.go
UnmarshalBinary
func (p *ProprietaryMACCommandPayload) UnmarshalBinary(data []byte) error { p.Bytes = data return nil }
go
func (p *ProprietaryMACCommandPayload) UnmarshalBinary(data []byte) error { p.Bytes = data return nil }
[ "func", "(", "p", "*", "ProprietaryMACCommandPayload", ")", "UnmarshalBinary", "(", "data", "[", "]", "byte", ")", "error", "{", "p", ".", "Bytes", "=", "data", "\n", "return", "nil", "\n", "}" ]
// UnmarshalBinary decodes the object from a slice of bytes.
[ "UnmarshalBinary", "decodes", "the", "object", "from", "a", "slice", "of", "bytes", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/mac_commands.go#L228-L231
144,288
brocaar/lorawan
mac_commands.go
MarshalBinary
func (p TXParamSetupReqPayload) MarshalBinary() ([]byte, error) { var b uint8 for i, v := range []uint8{8, 10, 12, 13, 14, 16, 18, 20, 21, 24, 26, 27, 29, 30, 33, 36} { if v == p.MaxEIRP { b = uint8(i) } } if b == 0 { return nil, errors.New("lorawan: invalid MaxEIRP value") } if p.UplinkDwellTime == Dwe...
go
func (p TXParamSetupReqPayload) MarshalBinary() ([]byte, error) { var b uint8 for i, v := range []uint8{8, 10, 12, 13, 14, 16, 18, 20, 21, 24, 26, 27, 29, 30, 33, 36} { if v == p.MaxEIRP { b = uint8(i) } } if b == 0 { return nil, errors.New("lorawan: invalid MaxEIRP value") } if p.UplinkDwellTime == Dwe...
[ "func", "(", "p", "TXParamSetupReqPayload", ")", "MarshalBinary", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "b", "uint8", "\n", "for", "i", ",", "v", ":=", "range", "[", "]", "uint8", "{", "8", ",", "10", ",", "12", ",", "...
// MarshalBinary encodes the object into a bytes.
[ "MarshalBinary", "encodes", "the", "object", "into", "a", "bytes", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/mac_commands.go#L706-L725
144,289
brocaar/lorawan
mac_commands.go
decodeDataPayloadToMACCommands
func decodeDataPayloadToMACCommands(uplink bool, payloads []Payload) ([]Payload, error) { if len(payloads) != 1 { return nil, errors.New("lorawan: exactly one Payload expected") } dataPL, ok := payloads[0].(*DataPayload) if !ok { return nil, fmt.Errorf("lorawan: expected *DataPayload, got %T", payloads[0]) } ...
go
func decodeDataPayloadToMACCommands(uplink bool, payloads []Payload) ([]Payload, error) { if len(payloads) != 1 { return nil, errors.New("lorawan: exactly one Payload expected") } dataPL, ok := payloads[0].(*DataPayload) if !ok { return nil, fmt.Errorf("lorawan: expected *DataPayload, got %T", payloads[0]) } ...
[ "func", "decodeDataPayloadToMACCommands", "(", "uplink", "bool", ",", "payloads", "[", "]", "Payload", ")", "(", "[", "]", "Payload", ",", "error", ")", "{", "if", "len", "(", "payloads", ")", "!=", "1", "{", "return", "nil", ",", "errors", ".", "New",...
// decodeDataPayloadToMACCommands decodes a DataPayload into a slice of // MACCommands.
[ "decodeDataPayloadToMACCommands", "decodes", "a", "DataPayload", "into", "a", "slice", "of", "MACCommands", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/mac_commands.go#L1278-L1312
144,290
brocaar/lorawan
applayer/clocksync/clocksync.go
UnmarshalBinary
func (p *AppTimeAnsPayload) UnmarshalBinary(data []byte) error { if len(data) < p.Size() { return fmt.Errorf("lorawan/applayer/clocksync: %d bytes are expected", p.Size()) } p.TimeCorrection = int32(binary.LittleEndian.Uint32(data[0:4])) p.Param.TokenAns = uint8(data[4] & 0x0f) return nil }
go
func (p *AppTimeAnsPayload) UnmarshalBinary(data []byte) error { if len(data) < p.Size() { return fmt.Errorf("lorawan/applayer/clocksync: %d bytes are expected", p.Size()) } p.TimeCorrection = int32(binary.LittleEndian.Uint32(data[0:4])) p.Param.TokenAns = uint8(data[4] & 0x0f) return nil }
[ "func", "(", "p", "*", "AppTimeAnsPayload", ")", "UnmarshalBinary", "(", "data", "[", "]", "byte", ")", "error", "{", "if", "len", "(", "data", ")", "<", "p", ".", "Size", "(", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "p", ...
// UnmarshalBinary decoces the payload from a slice of bytes.
[ "UnmarshalBinary", "decoces", "the", "payload", "from", "a", "slice", "of", "bytes", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/applayer/clocksync/clocksync.go#L253-L262
144,291
brocaar/lorawan
applayer/fragmentation/fragmentation.go
MarshalBinary
func (p DataFragmentPayload) MarshalBinary() ([]byte, error) { b := make([]byte, p.Size()) binary.LittleEndian.PutUint16(b[0:2], p.IndexAndN.N&0x3fff) b[1] |= (p.IndexAndN.FragIndex & 0x03) << 6 copy(b[2:], p.Payload) return b, nil }
go
func (p DataFragmentPayload) MarshalBinary() ([]byte, error) { b := make([]byte, p.Size()) binary.LittleEndian.PutUint16(b[0:2], p.IndexAndN.N&0x3fff) b[1] |= (p.IndexAndN.FragIndex & 0x03) << 6 copy(b[2:], p.Payload) return b, nil }
[ "func", "(", "p", "DataFragmentPayload", ")", "MarshalBinary", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "b", ":=", "make", "(", "[", "]", "byte", ",", "p", ".", "Size", "(", ")", ")", "\n\n", "binary", ".", "LittleEndian", ".", "P...
// MarshalBinary encodes the given payload to a slice of bytes.
[ "MarshalBinary", "encodes", "the", "given", "payload", "to", "a", "slice", "of", "bytes", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/applayer/fragmentation/fragmentation.go#L419-L427
144,292
Netflix/rend
server/listen.go
TCPListener
func TCPListener(port int) ListenConst { return func() (Listener, error) { listener, err := net.Listen("tcp", fmt.Sprintf(":%d", port)) if err != nil { return nil, fmt.Errorf("Error binding to port %d: %v", port, err.Error()) } return &tcpListener{listener: listener}, nil } }
go
func TCPListener(port int) ListenConst { return func() (Listener, error) { listener, err := net.Listen("tcp", fmt.Sprintf(":%d", port)) if err != nil { return nil, fmt.Errorf("Error binding to port %d: %v", port, err.Error()) } return &tcpListener{listener: listener}, nil } }
[ "func", "TCPListener", "(", "port", "int", ")", "ListenConst", "{", "return", "func", "(", ")", "(", "Listener", ",", "error", ")", "{", "listener", ",", "err", ":=", "net", ".", "Listen", "(", "\"", "\"", ",", "fmt", ".", "Sprintf", "(", "\"", "\"...
// TCPListener is a ListenConst that returns a tcp listener for the given port
[ "TCPListener", "is", "a", "ListenConst", "that", "returns", "a", "tcp", "listener", "for", "the", "given", "port" ]
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/server/listen.go#L55-L63
144,293
Netflix/rend
server/listen.go
UnixListener
func UnixListener(path string) ListenConst { return func() (Listener, error) { err := os.Remove(path) if err != nil && !os.IsNotExist(err) { return nil, fmt.Errorf("Error removing previous unix socket file at %s", path) } listener, err := net.Listen("unix", path) if err != nil { return nil, fmt.Errorf...
go
func UnixListener(path string) ListenConst { return func() (Listener, error) { err := os.Remove(path) if err != nil && !os.IsNotExist(err) { return nil, fmt.Errorf("Error removing previous unix socket file at %s", path) } listener, err := net.Listen("unix", path) if err != nil { return nil, fmt.Errorf...
[ "func", "UnixListener", "(", "path", "string", ")", "ListenConst", "{", "return", "func", "(", ")", "(", "Listener", ",", "error", ")", "{", "err", ":=", "os", ".", "Remove", "(", "path", ")", "\n", "if", "err", "!=", "nil", "&&", "!", "os", ".", ...
// UnixListener is a ListenConst that returns a unix domain socket listener for the given path
[ "UnixListener", "is", "a", "ListenConst", "that", "returns", "a", "unix", "domain", "socket", "listener", "for", "the", "given", "path" ]
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/server/listen.go#L78-L92
144,294
Netflix/rend
metrics/bulkcallback.go
RegisterBulkCallback
func RegisterBulkCallback(bcb BulkCallback) { id := atomic.AddUint32(curBulkCbID, 1) - 1 if id >= maxNumCallbacks { panic("Too many callbacks") } bulkCBs[id] = bcb }
go
func RegisterBulkCallback(bcb BulkCallback) { id := atomic.AddUint32(curBulkCbID, 1) - 1 if id >= maxNumCallbacks { panic("Too many callbacks") } bulkCBs[id] = bcb }
[ "func", "RegisterBulkCallback", "(", "bcb", "BulkCallback", ")", "{", "id", ":=", "atomic", ".", "AddUint32", "(", "curBulkCbID", ",", "1", ")", "-", "1", "\n\n", "if", "id", ">=", "maxNumCallbacks", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n...
// RegisterBulkCallback registers a bulk callback which will be called every time // metrics are requested. // There is a maximum of 1024 bulk callbacks, after which adding a new one will panic.
[ "RegisterBulkCallback", "registers", "a", "bulk", "callback", "which", "will", "be", "called", "every", "time", "metrics", "are", "requested", ".", "There", "is", "a", "maximum", "of", "1024", "bulk", "callbacks", "after", "which", "adding", "a", "new", "one",...
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/metrics/bulkcallback.go#L38-L46
144,295
Netflix/rend
metrics/gauges.go
AddIntGauge
func AddIntGauge(name string, tgs Tags) uint32 { id := atomic.AddUint32(curIntGaugeID, 1) - 1 if id >= maxNumGauges { panic("Too many int gauges") } intgnames[id] = name tgs = copyTags(tgs) tgs[TagMetricType] = MetricTypeGauge tgs[TagDataType] = DataTypeUint64 intgtags[id] = tgs return id }
go
func AddIntGauge(name string, tgs Tags) uint32 { id := atomic.AddUint32(curIntGaugeID, 1) - 1 if id >= maxNumGauges { panic("Too many int gauges") } intgnames[id] = name tgs = copyTags(tgs) tgs[TagMetricType] = MetricTypeGauge tgs[TagDataType] = DataTypeUint64 intgtags[id] = tgs return id }
[ "func", "AddIntGauge", "(", "name", "string", ",", "tgs", "Tags", ")", "uint32", "{", "id", ":=", "atomic", ".", "AddUint32", "(", "curIntGaugeID", ",", "1", ")", "-", "1", "\n\n", "if", "id", ">=", "maxNumGauges", "{", "panic", "(", "\"", "\"", ")",...
// AddIntGauge registers an integer-based gauge and returns an ID that can be // used to update it. // There is a maximum of 1024 gauges, after which adding a new one will panic
[ "AddIntGauge", "registers", "an", "integer", "-", "based", "gauge", "and", "returns", "an", "ID", "that", "can", "be", "used", "to", "update", "it", ".", "There", "is", "a", "maximum", "of", "1024", "gauges", "after", "which", "adding", "a", "new", "one"...
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/metrics/gauges.go#L39-L54
144,296
Netflix/rend
metrics/gauges.go
AddFloatGauge
func AddFloatGauge(name string, tgs Tags) uint32 { id := atomic.AddUint32(curFloatGaugeID, 1) - 1 if id >= maxNumGauges { panic("Too many float gauges") } floatgnames[id] = name tgs = copyTags(tgs) tgs[TagMetricType] = MetricTypeGauge tgs[TagDataType] = DataTypeFloat64 floatgtags[id] = tgs return id }
go
func AddFloatGauge(name string, tgs Tags) uint32 { id := atomic.AddUint32(curFloatGaugeID, 1) - 1 if id >= maxNumGauges { panic("Too many float gauges") } floatgnames[id] = name tgs = copyTags(tgs) tgs[TagMetricType] = MetricTypeGauge tgs[TagDataType] = DataTypeFloat64 floatgtags[id] = tgs return id }
[ "func", "AddFloatGauge", "(", "name", "string", ",", "tgs", "Tags", ")", "uint32", "{", "id", ":=", "atomic", ".", "AddUint32", "(", "curFloatGaugeID", ",", "1", ")", "-", "1", "\n\n", "if", "id", ">=", "maxNumGauges", "{", "panic", "(", "\"", "\"", ...
// AddFloatGauge registers a float-based gauge and returns an ID that can be // used to access it. // There is a maximum of 1024 gauges, after which adding a new one will panic
[ "AddFloatGauge", "registers", "a", "float", "-", "based", "gauge", "and", "returns", "an", "ID", "that", "can", "be", "used", "to", "access", "it", ".", "There", "is", "a", "maximum", "of", "1024", "gauges", "after", "which", "adding", "a", "new", "one",...
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/metrics/gauges.go#L59-L74
144,297
Netflix/rend
metrics/gauges.go
SetIntGauge
func SetIntGauge(id uint32, value uint64) { atomic.StoreUint64(&intgauges[id], value) }
go
func SetIntGauge(id uint32, value uint64) { atomic.StoreUint64(&intgauges[id], value) }
[ "func", "SetIntGauge", "(", "id", "uint32", ",", "value", "uint64", ")", "{", "atomic", ".", "StoreUint64", "(", "&", "intgauges", "[", "id", "]", ",", "value", ")", "\n", "}" ]
// SetIntGauge sets a gauge by the ID returned from AddIntGauge to the value given.
[ "SetIntGauge", "sets", "a", "gauge", "by", "the", "ID", "returned", "from", "AddIntGauge", "to", "the", "value", "given", "." ]
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/metrics/gauges.go#L77-L79
144,298
Netflix/rend
metrics/gauges.go
SetFloatGauge
func SetFloatGauge(id uint32, value float64) { // The float64 value needs to be converted into an int64 here because // there is no atomic store for float values. This is a literal // reinterpretation of the same exact bits. v2 := math.Float64bits(value) atomic.StoreUint64(&floatgauges[id], v2) }
go
func SetFloatGauge(id uint32, value float64) { // The float64 value needs to be converted into an int64 here because // there is no atomic store for float values. This is a literal // reinterpretation of the same exact bits. v2 := math.Float64bits(value) atomic.StoreUint64(&floatgauges[id], v2) }
[ "func", "SetFloatGauge", "(", "id", "uint32", ",", "value", "float64", ")", "{", "// The float64 value needs to be converted into an int64 here because", "// there is no atomic store for float values. This is a literal", "// reinterpretation of the same exact bits.", "v2", ":=", "math"...
// SetFloatGauge sets a gauge by the ID returned from AddFloatGauge to the value given.
[ "SetFloatGauge", "sets", "a", "gauge", "by", "the", "ID", "returned", "from", "AddFloatGauge", "to", "the", "value", "given", "." ]
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/metrics/gauges.go#L82-L88
144,299
Netflix/rend
client/cmd/setget/main.go
fillKeys
func fillKeys(chans []chan []byte) { totalCap := 0 for _, c := range chans { totalCap += cap(c) } if totalCap < f.NumOps { panic("Channels cannot hold all the ops. Deadlock guaranteed.") } ci := 0 key := bytes.Repeat([]byte{byte('A')}, f.KeyLength) for i := 0; i < f.NumOps; i++ { key = nextKey(key) cha...
go
func fillKeys(chans []chan []byte) { totalCap := 0 for _, c := range chans { totalCap += cap(c) } if totalCap < f.NumOps { panic("Channels cannot hold all the ops. Deadlock guaranteed.") } ci := 0 key := bytes.Repeat([]byte{byte('A')}, f.KeyLength) for i := 0; i < f.NumOps; i++ { key = nextKey(key) cha...
[ "func", "fillKeys", "(", "chans", "[", "]", "chan", "[", "]", "byte", ")", "{", "totalCap", ":=", "0", "\n", "for", "_", ",", "c", ":=", "range", "chans", "{", "totalCap", "+=", "cap", "(", "c", ")", "\n", "}", "\n", "if", "totalCap", "<", "f",...
// fills a bunch of channels round robin with keys
[ "fills", "a", "bunch", "of", "channels", "round", "robin", "with", "keys" ]
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/client/cmd/setget/main.go#L80-L101