Skip to content

feat(p2): typed SET values, multi-varbind set, Client#set - #22

Merged
stakach merged 3 commits into
spider-gazelle:masterfrom
n-rodriguez:feat/p2-write
Jul 11, 2026
Merged

feat(p2): typed SET values, multi-varbind set, Client#set#22
stakach merged 3 commits into
spider-gazelle:masterfrom
n-rodriguez:feat/p2-write

Conversation

@n-rodriguez

Copy link
Copy Markdown
Contributor

Second slice of the P2 (protocol completeness) group (#7) — the write story. Follows #21 (read/bulk).

Commits (one per audit item)

  1. feat: typed SNMP SET value typesSession#set only understood String/Int/Bool/Nil and the AppTags enum was unused, so counters/gauges/timeticks/addresses couldn't be set without hand-building a BER. Adds a TypedValue module + Counter32/Gauge32/TimeTicks/Counter64/IpAddress/Opaque/OID structs, each encoding itself as an application-tagged (RFC 3416) value. Verified to round-trip through the wire.
  2. feat: multi-varbind setset(values : Hash(String, _)) assigns several OIDs in one SetRequest; the Hash keeps insertion order. Extracts a shared to_varbind helper.
  3. feat(client): expose setClient#set(oid, value) and Client#set(values : Hash), mirroring the existing read methods.

Usage

client.set("1.3.6.1.2.1.1.6.0", "server-room")                 # OctetString
client.set("1.3.6.1.2.1.1.3.0", SNMP::TimeTicks.new(9000_u32)) # application-tagged
client.set({                                                    # multi-varbind
  "1.3.6.1.2.1.1.5.0" => "sysname",
  "1.3.6.1.2.1.1.6.0" => "syslocation",
})

Tests

set_values_spec (each type's tag/number/payload + a Session#set wire) and multi_set_spec (v2c + v3 builders) — offline. Client#set is socket glue, exercised by the e2e suite. Deterministic 70/70, multi-threaded 70/70, legacy 3/3, ameba clean, format clean; commits bisect-clean.

Tracked in #7. Remaining P2 slices: v3 Report/usmStats resync → HC counters/ifXTable → trap/inform sending.

🤖 Generated with Claude Code

n-rodriguez and others added 3 commits July 10, 2026 19:33
Session#set only understood String/Int/Bool/Nil; the AppTags enum was unused, so
Counters, Gauges, TimeTicks, IpAddress etc could not be set without hand-building
a BER. Add typed value structs that encode themselves as application-tagged
(RFC 3416) values, verified to round-trip through the wire.

- values: TypedValue module + Counter32/Gauge32/TimeTicks/Counter64/IpAddress/
  Opaque/OID structs, each with #to_ber setting the right Application tag
- session, v3/session: recognise TypedValue in set; extract a to_varbind helper
- spec: set_values_spec covers each type's tag/number/payload + a Session#set wire

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
RFC 3416 lets one SetRequest assign several variables. Add a Hash(String, _)
overload so multiple OID => value pairs go out in a single request; the Hash
keeps insertion order, so varbind order is preserved.

- session, v3/session: set(values : Hash(String, _)) reusing to_varbind
- spec: multi_set_spec covers the v2c and v3 builders

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Client had get/get_next/get_bulk/walk/bulk_walk but no set. Add single and
multi-varbind set that round-trip through the socket, mirroring the existing
read methods.

- client: set(oid, value) and set(values : Hash(String, _))

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@stakach
stakach merged commit 8e8007e into spider-gazelle:master Jul 11, 2026
6 checks passed
@n-rodriguez
n-rodriguez deleted the feat/p2-write branch July 12, 2026 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants