Skip to content

Commit

Permalink
make a godforsaken macro
Browse files Browse the repository at this point in the history
  • Loading branch information
ifd3f committed Apr 8, 2024
1 parent 2bf93e8 commit df9b72f
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions netconf/util.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -55,29 +55,43 @@
(cons (cons obj before) after)]
[('()) (cons '() '())])

(define-record-type WireguardTunnel
(struct dual-stack (v4 v6))

(define-syntax (network-struct stx)
(syntax-case stx ()
[(_ name fields)
(syntax-case (datum->syntax #'name
(string->symbol (format "~a-raw" (syntax->datum #'name)))) ()
[raw-constructor-name #'(struct name fields #:transparent #:constructor-name raw-constructor-name)])]))

(define-record-type wireguard/tunnel
(ifname
our-address
our-private-key
description
peers
our-endpoint-port))

(define-record-type WireguardPeer
(define-record-type wireguard/peer
(name
public-key
endpoint))

(define-record-type LinkLocalBgpPeer
(define-record-type bgp/link-local-peer
(link-ifname
description
peer-address
peer-asn
peer-group))

(define-record-type FirewallRule
(description
cmds
src
dst))
(network-struct firewall/rule
(description
cmds
src
dst))

#;(define (firewall/rule-fmap f))

;(define orig (firewall/rule-id #:description "test rule" #:cmds '(a) #:src 'a #:dst 'a))

;(struct-copy firewall/rule orig [src 'b])

0 comments on commit df9b72f

Please sign in to comment.