bgpmon: github.com/CSUNetSec/bgpmon Index | Files | Directories

package bgpmon

import "github.com/CSUNetSec/bgpmon"

Package bgpmon provides the core interfaces for developing bgpmon client programs and modules.

Index

Package Files

module.go server.go

Constants

const (
    // A task will run until it's finished. It will only be deallocated by
    // the server when it calls its own FinishFunc.
    ModuleTask = iota

    // A daemon will run constantly, and won't stop until it is closed by
    // the server. If it encounters an error, it can call its FinishFunc
    // to be deallocated early.
    ModuleDaemon
)

Types of modules.

func RegisterModule Uses

func RegisterModule(handle ModuleHandler)

RegisterModule adds a module type to a list of known modules. Once a module maker is registered, the server can create and launch modules of this type

type BgpmondServer Uses

type BgpmondServer interface {
    // OpenSession opens a session of type sType, which must come from the config file.
    // The ID of this session is sID, which is used to interact with this
    // session, and wc is the worker count, or 0, to use a default wc of 1.
    OpenSession(sType, sID string, wc int) error

    // ListSessionTypes returns types which can be opened on the server. These are
    // defined in netsec-protobus, but the name of a SessionType returned
    // here should be a valid sType for OpenSession.
    ListSessionTypes() []*pb.SessionType

    // ListSessions returns a slice of currently active sesions on the server.
    // Each session handle includes a name, a session type, and a pointer to the
    // underlying session.
    ListSessions() []SessionHandle

    // CloseSession attempts to close active session with the provided session ID.
    // If that ID does not exist, or that session fails to close, this will return
    // an error.
    CloseSession(string) error

    // OpenWriteStream tries to open a write stream on the provided session ID with
    // the provided type. If the session doesn't exist or the WriteStream fails to
    // open, this will return an error.
    OpenWriteStream(string, db.SessionType) (db.WriteStream, error)

    // OpenReadStream tries to open a read stream on the provided session ID with
    // the provided type and filter options. If the session doesn't exist or the ReadStream
    // fails to open, this will return an error.
    OpenReadStream(string, db.SessionType, db.FilterOptions) (db.ReadStream, error)

    // RunModule will launch the module specified with mType with the ID mID. opts will
    // be passed to the modules Run function.
    RunModule(mType string, mID string, opts map[string]string) error

    // ListModuleTypes will return a slice of ModuleInfo specifying the type of module
    // and the options it accepts.
    ListModuleTypes() []ModuleInfo

    // ListRunningModules returns a slice of the active modules on the server.
    // OpenModuleInfo describes the modules type, options, and status.
    ListRunningModules() []OpenModuleInfo

    // CloseModule attempts to close an active module with the provided ID. If that ID
    // does not exist, or the module fails to close, this will return an error.
    CloseModule(string) error

    // Close will close all active modules, then all active sessions.
    Close() error
}

BgpmondServer is the interface for interacting with a server instance. It provides functions to open and close sessions and modules, and get data on the state on the server.

func NewServer Uses

func NewServer(conf config.Configer) (BgpmondServer, error)

NewServer creates a BgpmondServer instance from a configuration. It loads session types from the configuration, and launches any modules specified. It returns an error if a module type is specified that isn't registered with the server.

func NewServerFromFile Uses

func NewServerFromFile(fName string) (BgpmondServer, error)

NewServerFromFile does the same thing as NewServer, but loads the configuration from a specified file name. Returns an error if the file can't be parsed, or specifies an invalid module.

type Module Uses

type Module interface {
    // Run starts the module, and is guaranteed to launch in a separate
    // goroutine. Args can be used to pass any information the module
    // needs.
    Run(args map[string]string)

    // GetType should return one of the module types defined above.
    GetType() int

    // GetName returns a string to identify the module type. Each
    // instance of a module should share the same name.
    GetName() string

    // GetInfo returns a struct containing info that describes the
    // running module.
    GetInfo() OpenModuleInfo

    // Stop is called to prematurely cancel a running module. The
    // module should be deallocated just after calling this. Stop
    // should be blocking until it knows the module has been stopped.
    Stop() error
}

Module describes a service that can be started by the server. It can interact with the server in any way, including opening sessions, streams, and other modules.

type ModuleHandler Uses

type ModuleHandler struct {
    Info  ModuleInfo
    Maker ModuleMaker
}

ModuleHandler wraps the info and maker types. It's used to store modules globally, and as the argument to register new modules.

type ModuleInfo Uses

type ModuleInfo struct {
    Type        string
    Description string
    Opts        string
}

ModuleInfo is used to describe an available module. It should include the type of the module, a description, and a description of the opts that the module uses.

type ModuleMaker Uses

type ModuleMaker func(BgpmondServer, util.Logger) Module

ModuleMaker is a function to instantiate a module. It is given a handle to the BgpmondServer, and a logger to print information.

type OpenModuleInfo Uses

type OpenModuleInfo struct {
    Type   string
    ID     string
    Status string
}

OpenModuleInfo describes an actively running module. It should include the type of the module, the ID, and a string describing the status of the module. Modules don't keep track of their own ID, so that field must be populated by the server.

func NewOpenModuleInfo Uses

func NewOpenModuleInfo(modType string, status string) OpenModuleInfo

NewOpenModuleInfo returns an info struct with a type and a status, and leaves the ID to be populated by something else.

type SessionHandle Uses

type SessionHandle struct {
    Name     string
    SessType *pb.SessionType
    Session  *db.Session
}

SessionHandle is used to return information on an open session.

Directories

PathSynopsis
configPackage config defines the constants and functions necessary to parse configuration files for bgpmon
dbPackage db is responsible for the communication between the database backends and the bgpmon daemon.
modulesPackage modules defines commonly used modules for bgpmon.
utilPackage util defines miscellaneous functions used in multiple parts of bgpmon or other projects

Package bgpmon imports 7 packages (graph) and is imported by 1 packages. Updated 2019-08-06. Refresh now. Tools for package owners.