#!/bin/bash

# support for strings and integers in named maps.
# without typeof, this is 'type string' and 'type integer',
# but neither could be used because it lacks size information.

EXPECTED="table inet t {
	map m1 {
		typeof osf name : ct mark
		elements = { "Linux" : 0x00000001 }
	}

	map m2 {
		typeof vlan id : mark
		elements = { 1 : 0x1,
			     4095 : 0x4095 }
	}

	map m3 {
		typeof ip saddr . ip daddr : meta mark
		elements = { 1.2.3.4 . 5.6.7.8 : 0x00000001,
			     2.3.4.5 . 6.7.8.9 : 0x00000002 }
	}

	chain c {
		ct mark set osf name map @m1
		ether type vlan meta mark set vlan id map @m2
		meta mark set ip saddr . ip daddr map @m3
	}
}"

set -e
$NFT -f - <<< $EXPECTED

