Can a table entry include a complex data object? For example can a table entry look like this?
ExampleTableEntry ::=
SEQUENCE {
simpleDataObject1 INTEGER,
complexDataObject2 ComplexType,
SimpleDataObject3 TruthValue
}
ComplexType OBJECT-IDENTITY
STATUS current
DESCRIPTION
" What ever "
::= { parent 1 }
subObject1 OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
MAX-ACCESS read-create
STATUS current
DESCRIPTION
" Diameter peer's host name. Reference: RFC 3588 "
::= { ComplexType 1 }
subObject2 OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-create
STATUS current
DESCRIPTION
" "
::= { ComplexType 2 }
Can the ComplexType be defined through a Textual convention or as an Object Identity?
Object Group?
If not, am I forced to add the sub objects to the parent table entry?
Thanks for your comments.
This is something strictly defined in SNMP RFC documents, such as
https://www.rfc-editor.org/rfc/rfc2578#page-25
As the <syntax> part must be of SYNTAX clause format, it cannot be the thing you imagined.
In your case, you either define more objects in the sequence, or write a secondary table to accompany.
Related
RFC 4188 defines the dot1dStaticEntry as follows:
dot1dStaticEntry OBJECT-TYPE
SYNTAX Dot1dStaticEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"Filtering information configured into the bridge by
(local or network) management specifying the set of
ports to which frames received from a specific port and
containing a specific destination address are allowed to
be forwarded."
REFERENCE
"IEEE 802.1D-1998: clause 14.7.2"
INDEX { dot1dStaticAddress, dot1dStaticReceivePort }
::= { dot1dStaticTable 1 }
Dot1dStaticEntry ::=
SEQUENCE {
dot1dStaticAddress MacAddress,
dot1dStaticReceivePort Integer32,
dot1dStaticAllowedToGoTo OCTET STRING,
dot1dStaticStatus INTEGER
}
The columns defined for this table are all denoted read-create. However, there is no RowStatus column defined for this table.
How do I add a row in this table via SNMP, given that the table does not have a RowStatus column?
Yeah just off the top of my head that looks totally broken to me, unless there's some extension I'm not aware of.
But it looks like dot1dStaticStatus is a sort of non-standard RowStatus.
If you want to use this feature I think you'll have to ask the vendor for the equipment you're using that implements the MIB, to clarify.
Just curious, is there a way to export a function whose name starts with a lower case character, like "print" or "start"?
A side note: just like you do with JSON:
type T struct {
FieldA int `json:"field_a"`
FieldB string `json:"field_b,omitempty"`
}
No, there is not. The Go language specification specifies this clearly:
Exported identifiers
An identifier may be exported to permit access to it from another package. An identifier is exported if both:
the first character of the identifier's name is a Unicode upper case letter (Unicode class "Lu"); and
the identifier is declared in the package block or it is a field name or method name.
All other identifiers are not exported.
I came across this type declaration:
type Handler func(*Conn)
type Server struct {
Handshake func(*Config, *http.Request) error
Handler
}
(this is a simplified version of https://github.com/golang/net/blob/38c17adf51120973d1735785a7c02f8ce8297c5e/websocket/server.go#L55-L66
The second field in the Server structure is anonymous. There is just type and no name.
Here is the grammar for type declarations (https://golang.org/ref/spec#Type_declarations):
TypeDecl = "type" ( TypeSpec | "(" { TypeSpec ";" } ")" ) .
TypeSpec = identifier Type .
and it clearly requires an identifier name. But yet the section that I referenced that contains the grammar, also mentions anonymous fields.
I do not understand why this syntax is correct and how anonymous fields are used.
You want to look at the part of the grammar that has to do with structures, not just types. See: Struct types and the use of AnonymousField. Looking just at the production for TypeSpec is focusing attention on the wrong place. Instead, look at FieldDecl; the grammar shows that we have two possibilities: named fields (IdentifierList Type), or anonymous fields (AnonymousField).
Anonymous fields are typically used for embedding. In your example, a Server will act like a Handler because it has embedded that field.
I've been trying to find out how to use mgo (MongoDB driver for Go) and I came across this struct declaration:
type Something struct {
Id bson.ObjectId "_id,omitempty"
Name string
}
I don't quite understand the syntax of the first element (Id). I understand that it's being declared as type bson.ObjectId, but what is the string literal doing there?
My question is not about the mgo driver functionality,
but about this strange <name> <type> <string_literal> syntax.
I couldn't find anything on the Go specs, and I don't know how to google this either.
It's explained in the Struct types section of the language specification:
A field declaration may be followed by an optional string literal
tag, which becomes an attribute for all the fields in the corresponding field declaration. The tags are made visible through a
reflection interface but are otherwise ignored.
// A struct corresponding to the TimeStamp protocol buffer.
// The tag strings define the protocol buffer field numbers.
struct {
microsec uint64 "field 1"
serverIP6 uint64 "field 2"
process string "field 3"
}
is there a generic OID(s) so that i can get it's Model Number.
for devices like Cisco, Juniper, Alcatel etc...
For example for sonicWall Router
enterprises.8741.2.1.1.1.0 = snwlSysModel = "TZ 100"
Unfortunately, no. There are a few objects to help you get a clue but nothing that lists versions outright. This is the best one to start with:
SNMPv2-MIB::sysObjectID
sysObjectID OBJECT-TYPE
-- FROM SNMPv2-MIB, RFC1213-MIB
SYNTAX OBJECT IDENTIFIER
MAX-ACCESS read-only
STATUS current
DESCRIPTION "The vendor's authoritative identification of the
network management subsystem contained in the entity.
This value is allocated within the SMI enterprises
subtree (1.3.6.1.4.1) and provides an easy and
unambiguous means for determining `what kind of box' is
being managed. For example, if vendor `Flintstones,
Inc.' was assigned the subtree 1.3.6.1.4.1.424242,
it could assign the identifier 1.3.6.1.4.1.424242.1.1
to its `Fred Router'."
::= { iso(1) org(3) dod(6) internet(1) mgmt(2) mib-2(1) system(1) 2 }
followed by looking through the HOST-RESOURCES-MIB and, if supported, the ENTITY-MIB.
entPhysicalIndex entPhysicalIndex 1.3.6.1.2.1.47.1.1.1.1.1 OBJECT-TYPE
entPhysicalSoftwareRev entPhysicalSoftwareRev 1.3.6.1.2.1.47.1.1.1.1.10 OBJECT-TYPE
entPhysicalSerialNum entPhysicalSerialNum 1.3.6.1.2.1.47.1.1.1.1.11 OBJECT-TYPE
entPhysicalMfgName entPhysicalMfgName 1.3.6.1.2.1.47.1.1.1.1.12 OBJECT-TYPE
entPhysicalModelName entPhysicalModelName 1.3.6.1.2.1.47.1.1.1.1.13 OBJECT-TYPE
entPhysicalAlias entPhysicalAlias 1.3.6.1.2.1.47.1.1.1.1.14 OBJECT-TYPE
entPhysicalAssetID entPhysicalAssetID 1.3.6.1.2.1.47.1.1.1.1.15 OBJECT-TYPE
entPhysicalIsFRU entPhysicalIsFRU 1.3.6.1.2.1.47.1.1.1.1.16 OBJECT-TYPE
entPhysicalDescr entPhysicalDescr 1.3.6.1.2.1.47.1.1.1.1.2 OBJECT-TYPE
entPhysicalVendorType entPhysicalVendorType 1.3.6.1.2.1.47.1.1.1.1.3 OBJECT-TYPE
entPhysicalContainedIn entPhysicalContainedIn 1.3.6.1.2.1.47.1.1.1.1.4 OBJECT-TYPE
entPhysicalClass entPhysicalClass 1.3.6.1.2.1.47.1.1.1.1.5 OBJECT-TYPE
entPhysicalParentRelPos entPhysicalParentRelPos 1.3.6.1.2.1.47.1.1.1.1.6 OBJECT-TYPE
entPhysicalName entPhysicalName 1.3.6.1.2.1.47.1.1.1.1.7 OBJECT-TYPE
entPhysicalHardwareRev entPhysicalHardwareRev 1.3.6.1.2.1.47.1.1.1.1.8 OBJECT-TYPE
entPhysicalFirmwareRev entPhysicalFirmwareRev 1.3.6.1.2.1.47.1.1.1.1.9 OBJECT-TYPE