Skip to content

Commit

Permalink
fix: #106 /interface/bridge resource schema (IGMP snooping).
Browse files Browse the repository at this point in the history
The behavior of the resource must be controlled manually. Mikrotik allows you to set slave properties without error for a disabled main one (for example, for IGMP-snooping).
  • Loading branch information
vaerh committed Feb 17, 2023
1 parent 68a67d4 commit dd9baaa
Show file tree
Hide file tree
Showing 2 changed files with 143 additions and 0 deletions.
138 changes: 138 additions & 0 deletions routeros/resource_interface_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ func ResourceInterfaceBridge() *schema.Resource {
MetaId: PropId(Name),

KeyActualMtu: PropActualMtuRo,
"add_dhcp_option82": {
Type: schema.TypeBool,
Optional: true,
Description: "Whether to add DHCP Option-82 information (Agent Remote ID and Agent Circuit ID) to DHCP " +
"packets. Can be used together with Option-82 capable DHCP server to assign IP addresses and implement " +
"policies. This property only has effect when dhcp-snooping is set to yes.",
RequiredWith: []string{"dhcp_snooping"},
},
"admin_mac": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -76,6 +84,16 @@ func ResourceInterfaceBridge() *schema.Resource {
Description: "Enables multicast group and port learning to prevent multicast traffic from flooding all " +
"interfaces in a bridge.",
},
"igmp_version": {
Type: schema.TypeInt,
Optional: true,
// Default: "2",
Computed: true,
Description: "Selects the IGMP version in which IGMP general membership queries will be generated. " +
"This property only has effect when igmp-snooping is set to yes.",
ValidateFunc: validation.IntInSlice([]int{2, 3}),
RequiredWith: []string{"igmp_snooping"},
},
"ingress_filtering": {
Type: schema.TypeBool,
Optional: true,
Expand All @@ -84,19 +102,68 @@ func ResourceInterfaceBridge() *schema.Resource {
"of the received VLAN ID in the bridge VLAN table. Should be used with frame-types to specify if " +
"the ingress traffic should be tagged or untagged. This property only has effect when " +
"vlan-filtering is set to yes.",
RequiredWith: []string{"vlan_filtering"},
},
KeyL2Mtu: PropL2MtuRo,
"last_member_interval": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "If a port has fast-leave set to no and a bridge port receives a IGMP Leave message, " +
"then a IGMP Snooping enabled bridge will send a IGMP query to make sure that no devices has " +
"subscribed to a certain multicast stream on a bridge port.",
DiffSuppressFunc: TimeEquall,
RequiredWith: []string{"igmp_snooping"},
},
"last_member_query_count": {
Type: schema.TypeInt,
Optional: true,
// Default: 2,
Computed: true,
Description: "How many times should last-member-interval pass until a IGMP Snooping bridge will stop " +
"forwarding a certain multicast stream. This property only has effect when igmp-snooping is set to yes.",
RequiredWith: []string{"igmp_snooping"},
},
"mac_address": {
Type: schema.TypeString,
Computed: true,
},
"max_hops": {
Type: schema.TypeInt,
Optional: true,
// Default: 20,
Computed: true,
Description: "Bridge count which BPDU can pass in a MSTP enabled network in the same region before BPDU " +
"is being ignored. This property only has effect when protocol-mode is set to mstp.",
ValidateFunc: validation.IntBetween(6, 40),
},
"max_message_age": {
Type: schema.TypeString,
Optional: true,
Default: "20s",
Description: "Changes the Max Age value in BPDU packets, which is transmitted by the root bridge. " +
"This property only has effect when protocol-mode is set to stp or rstp. Value: 6s..40s",
},
"membership_interval": {
Type: schema.TypeString,
Optional: true,
// Default: "4m20s",
Computed: true,
Description: "Amount of time after an entry in the Multicast Database (MDB) is removed if a IGMP membership " +
"report is not received on a certain port. This property only has effect when igmp-snooping is set to yes.",
DiffSuppressFunc: TimeEquall,
RequiredWith: []string{"igmp_snooping"},
},
"mld_version": {
Type: schema.TypeInt,
Optional: true,
// Default: 1,
Computed: true,
Description: "Selects the MLD version. Version 2 adds support for source-specific multicast. This " +
"property only has effect when RouterOS IPv6 package is enabled and igmp-snooping is set to yes.",
ValidateFunc: validation.IntInSlice([]int{1, 2}),
RequiredWith: []string{"igmp_snooping"},
},
"mtu": {
Type: schema.TypeString,
Optional: true,
Expand All @@ -107,6 +174,15 @@ func ResourceInterfaceBridge() *schema.Resource {
"of the bridge (set by the mtu property), then manually set value will be ignored and the bridge " +
"will act as if mtu=auto is set.",
},
"multicast_querier": {
Type: schema.TypeBool,
Optional: true,
Description: "Multicast querier generates IGMP general membership queries to which all IGMP capable " +
"devices respond with an IGMP membership report, usually a PIM (multicast) router or IGMP proxy " +
"generates these queries. This property only has an effect when igmp-snooping is set to yes. " +
"Additionally, the igmp-snooping should be disabled/enabled after changing multicast-querier property.",
RequiredWith: []string{"igmp_snooping"},
},
KeyName: PropNameRw,
"priority": {
Type: schema.TypeString,
Expand All @@ -132,7 +208,69 @@ func ResourceInterfaceBridge() *schema.Resource {
"This property only has effect when vlan-filtering is set to yes.",
ValidateFunc: validation.IntBetween(1, 4094),
},
"querier_interval": {
Type: schema.TypeString,
Optional: true,
// Default: "4m15s",
Computed: true,
Description: "Used to change the interval how often a bridge checks if it is the active multicast " +
"querier. This property only has effect when igmp-snooping and multicast-querier is set to yes.",
DiffSuppressFunc: TimeEquall,
RequiredWith: []string{"igmp_snooping", "multicast_querier"},
},
"query_interval": {
Type: schema.TypeString,
Optional: true,
// Default: "2m5s",
Computed: true,
Description: "Used to change the interval how often IGMP general membership queries are sent out. " +
"This property only has effect when igmp-snooping and multicast-querier is set to yes.",
DiffSuppressFunc: TimeEquall,
RequiredWith: []string{"igmp_snooping", "multicast_querier"},
},
"query_response_interval": {
Type: schema.TypeString,
Optional: true,
// Default: "10s",
Computed: true,
Description: "Interval in which a IGMP capable device must reply to a IGMP query with a IGMP membership " +
"report. This property only has effect when igmp-snooping and multicast-querier is set to yes.",
DiffSuppressFunc: TimeEquall,
RequiredWith: []string{"igmp_snooping", "multicast_querier"},
},
KeyRunning: PropRunningRo,
"region_name": {
Type: schema.TypeString,
Optional: true,
Description: "MSTP region name. This property only has effect when protocol-mode is set to mstp.",
},
"region_revision": {
Type: schema.TypeInt,
Optional: true,
Description: "MSTP configuration revision number. This property only has effect when protocol-mode is set to mstp.",
ValidateFunc: validation.IntBetween(0, 65535),
},
"startup_query_count": {
Type: schema.TypeInt,
Optional: true,
// Default: 2,
Computed: true,
Description: "Specifies how many times must startup-query-interval pass until the bridge starts sending " +
"out IGMP general membership queries periodically. This property only has effect when igmp-snooping " +
"and multicast-querier is set to yes.",
RequiredWith: []string{"igmp_snooping", "multicast_querier"},
},
"startup_query_interval": {
Type: schema.TypeString,
Optional: true,
// Default: "31s250ms",
Computed: true,
Description: "Used to change the amount of time after a bridge starts sending out IGMP general membership " +
"queries after the bridge is enabled. This property only has effect when igmp-snooping and " +
"multicast-querier is set to yes.",
DiffSuppressFunc: TimeEquall,
RequiredWith: []string{"igmp_snooping", "multicast_querier"},
},
"transmit_hold_count": {
Type: schema.TypeInt,
Optional: true,
Expand Down
5 changes: 5 additions & 0 deletions routeros/resource_interface_bridge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ resource "routeros_interface_bridge" "test_bridge" {
resource "routeros_interface_bridge" "test_bridge_w_space" {
name = "Main bridge"
ingress_filtering = true
protocol_mode = "rstp"
priority = "0x3000"
igmp_snooping = true
vlan_filtering = true
}
`
Expand Down

0 comments on commit dd9baaa

Please sign in to comment.