summaryrefslogtreecommitdiffstats
path: root/src/plugins/yang/openconfig/openconfig-ospfv2-lsdb.yang
blob: b3457242b4448d7230131dd4cfc4e1bab79540ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
submodule openconfig-ospfv2-lsdb {

  belongs-to openconfig-ospfv2 {
    prefix "oc-ospfv2";
  }

  // import some basic types
  import ietf-yang-types { prefix "yang"; }
  import ietf-inet-types { prefix "inet"; }
  import openconfig-types { prefix "oc-types"; }
  import openconfig-extensions { prefix "oc-ext"; }
  import openconfig-ospf-types { prefix "oc-ospf-types"; }

  // meta
  organization "OpenConfig working group";

  contact
    "OpenConfig working group
    www.openconfig.net";

  description
    "An OpenConfig model for the Open Shortest Path First (OSPF)
    version 2 link-state database (LSDB)";

  oc-ext:openconfig-version "0.1.2";

  revision "2018-06-05" {
    description
      "Bug fixes in when statements in lsdb";
    reference "0.1.2";
  }

  revision "2017-08-24" {
    description
      "Minor formatting fixes.";
    reference "0.1.1";
  }

  revision "2017-02-28"{
    description
      "Initial public release of OSPFv2";
    reference "0.1.0";
  }

  revision "2016-06-24" {
    description
      "Initial revision";
    reference "0.0.1";
  }

  grouping ospfv2-lsdb-common-prefix-properties {
    description
      "Common properties used in the LSDB that relate to IPv4 prefixes";

    leaf prefix-length {
      type uint8 {
        range "0..32";
      }
      description
        "The length of the IPv4 prefix contained in the Extended Prefix LSA";
    }

    leaf address-family {
      // TODO: should this be an identity?
      type enumeration {
        enum IPV4_UNICAST {
          value 0;
          description
            "The prefix contained within the Extended Prefix LSA is an IPv4
            unicast prefix";
        }
      }
      description
        "The address family of the prefix contained in the Extended Prefix
        LSA";
    }
  }

  grouping ospfv2-lsdb-common-link-specification {
    description
      "Generic attributes used to identify links within OSPFv2";

    leaf link-id {
      type yang:dotted-quad;
      description
        "The identifier for the link specified. The value of the link
        identifier is dependent upon the type of the LSA. The value is
        specified to be, per sub-type:
          1) Neighbouring router's router ID.
          2) IP address of DR.
          3) IP network address.
          4) Neighbouring router router's ID.";
    }

    leaf link-data {
      type union {
        type yang:dotted-quad;
        type uint32;
      }
      description
        "The data associated with the link type. The value is
        dependent upon the subtype of the LSA. When the connection is
        to a stub network it represents the mask; for p2p connections
        that are unnumbered it represents the ifIndex value of the
        router's interface; for all other connections it represents
        the local system's IP address";
    }

  }

  grouping ospfv2-lsdb-common-unknown-tlv {
    description
      "A generic specification of a TLV to be used when the
      value cannot be decoded by the local system";

    leaf type {
      type uint16;
      description
        "The type value of the unknown TLV";
    }

    leaf length {
      type uint16;
      description
        "The length value of the unknown TLV";
    }

    leaf value {
      type binary;
      description
        "The value portion of the unknwon TLV";
    }
  }

  grouping ospfv2-lsdb-common-unknown-tlv-structure {
    description
      "A generic specification of an unknown TLV";

    container unknown-tlv {
      description
        "An unknown TLV within the context. Unknown TLVs are
        defined to be the set of TLVs that are not modelled
        within the OpenConfig model, or are unknown to the
        local system such that it cannot decode their value.";

      container state {
        description
          "Contents of an unknown TLV within the LSA";
        uses ospfv2-lsdb-common-unknown-tlv;
      }
    }
  }

  grouping ospfv2-lsdb-common-unknown-subtlv-structure {
    description
      "A generic specification of an unknown TLV";

    container unknown-subtlv {
      description
        "An unknown SubTLV within the context. Unknown Sub-TLV
        are defined to be the set of SubTLVs that are not modelled
        by the OpenConfig schema, or are unknown to the local system
        such that it cannot decode their value.";

      container state {
        description
          "Contents of an unknown TLV within the LSA";
        uses ospfv2-lsdb-common-unknown-tlv;
      }
    }
  }

  grouping ospfv2-lsdb-common-tos-metric {
    description
      "Common LSDB LSA parameters for type of service and metric";

    leaf tos {
      type uint8;
      description
        "OSPF encoding of the type of service referred to by this
        LSA. Encoding for OSPF TOS are described in RFC2328.";
    }

    leaf metric {
      type oc-ospf-types:ospf-metric;
      description
        "The metric value to be used for the TOS specified. This value
        represents the cost of use of the link for the specific type
        of service.";
    }
  }

  grouping ospfv2-lsdb-common-sr-sid-spec {
    description
      "Re-usable specification of a segment routing SID";

    leaf sid-type {
      type oc-ospf-types:sr-sid-type;
      description
        "The type of the value contained within the sub-TLV";
    }

    leaf sid-value {
      type uint32;
      description
        "The value of the binding included within the sub-TLV. The type of
        this binding is indicated by the type leaf.";
    }
  }

  grouping ospfv2-lsdb-area-state {
    description
      "Per-area operational state parameters for an OSPFv2 area";

    leaf identifier {
      type oc-ospf-types:ospf-area-identifier;
      description
        "An identifier for the area, expressed as a dotted quad or
        an unsigned 32-bit integer";
    }
  }

  grouping ospfv2-lsdb-area-lsa-type-state {
    description
      "Per-LSA type operational state parameters for an OSPFv2 area";

    leaf type {
      type identityref {
        base "oc-ospf-types:OSPF_LSA_TYPE";
      }
      description
        "The type of LSA being described. The type of the LSA is
        expressed as a canonical name.";
    }
  }

  grouping ospfv2-lsdb-area-lsa-state {
    description
      "Generic parameters of an OSPFv2 LSA";

    leaf link-state-id {
      type yang:dotted-quad;
      description
        "The Link State ID for the specified LSA type. The exact
        defined value of the Link State ID is dependent on the LSA
        type.";
    }

    leaf advertising-router {
      type yang:dotted-quad;
      description
        "The router ID of the router that originated the LSA";
    }

    leaf sequence-number {
      type int32;
      description
        "A signed 32-bit integer used to detect old and duplicate
        LSAs. The greater the sequence number the more recent the
        LSA.";
    }

    leaf checksum {
      type uint16;
      description
        "The checksum of the complete contents of the LSA excluding
        the age field.";
    }

    leaf age {
      type uint16;
      units seconds;
      description
        "The time since the LSA's generation in seconds";
    }
  }

  grouping ospfv2-lsdb-router-lsa-structure {
    description
      "Structural grouping for Router LSA contents within the LSDB";

    container router-lsa {
      description
        "Contents of the router LSA";

      container state {
        description
          "State parameters of the router LSA";
        uses ospfv2-lsdb-router-lsa-state;
      }

      uses ospfv2-lsdb-generic-lsa-tos-metric-structure;
    }
  }

  grouping ospfv2-lsdb-generic-lsa-tos-metric-structure {
    description
      "Grouping including a generic TOS/metric structure for an
      LSA";

    container types-of-service {
      description
        "Breakdown of LSA contents specifying multiple
        TOS values";

      list type-of-service {
        key "tos";
        description
          "Per-type of service parameters for the LSA";

        leaf tos {
          type leafref {
            path "../state/tos";
          }
          description
            "Reference to the type of service identifier which is
            specified in the LSA";
        }

        container state {
          description
            "Per-TOS parameters for the LSA";

          uses ospfv2-lsdb-generic-lsa-tos-metric-state;
        }
      }
    }
  }

  grouping ospfv2-lsdb-network-lsa-structure {
    description
      "Structural grouping for Network LSA contents within the LSDB";

    container network-lsa {
      description
        "Contents of the network LSA";

      container state {
        description
          "State parameters of the network LSA";
        uses ospfv2-lsdb-network-lsa-state;
      }
    }
  }

  grouping ospfv2-lsdb-summary-lsa-structure {
    description
      "Structural grouping for the Summary LSA contents within the
      LSDB";

    container summary-lsa {
      description
        "Contents of the summary LSA";

      container state {
        description
          "State parameters of the summary LSA";
        uses ospfv2-lsdb-summary-lsa-state;
      }

      uses ospfv2-lsdb-generic-lsa-tos-metric-structure;
    }
  }

  grouping ospfv2-lsdb-asexternal-lsa-structure {
    description
      "Structural grouping for the AS External LSA contents within
      the LSDB";

    container as-external-lsa {
      description
        "Contents of the AS External LSA";

      container state {
        description
          "State parameters for the AS external LSA";
        uses ospfv2-lsdb-asexternal-lsa-state;
      }

      container types-of-service {
        description
          "Breakdown of External LSA contents specifying multiple
          TOS values";

        list type-of-service {
          key "tos";
          description
            "Per-type of service parameters for the AS External LSA";

          leaf tos {
            type leafref {
              path "../state/tos";
            }
            description
              "Reference to the type of service identifier which is
              specified in the AS External LSA";
          }

          container state {
            description
              "Per-TOS parameters for the LSA";

            uses ospfv2-lsdb-asexternal-tos-state;
          }
        }
      }

    }
  }

  grouping ospfv2-lsdb-nssa-external-lsa-structure {
    description
      "Structural grouping for the NSSA External LSA contents within
      the LSDB";

    container nssa-external-lsa {
      description
        "Contents of the NSSA External LSA";

      container state {
        description
          "State parameters for the AS external LSA";
        // Type 7 LSAs are are a super-set of Type 5 LSAs so we simply
        // include the Type 5
        uses ospfv2-lsdb-asexternal-lsa-state;
        uses ospfv2-lsdb-nssa-external-lsa-state;
      }

      container types-of-service {
        description
          "Breakdown of the NSSA External LSA contents specifying multiple
          TOS values";

        list type-of-service {
          key "tos";
          description
            "Per-type of service parameters for the NSSA external LSA";

          leaf tos {
            type leafref {
              path "../state/tos";
            }
            description
              "Reference to the type of services identifier which is specified
              in the NSSA External LSA";
          }

          container state {
            description
              "Per-TOS parameters for the LSA";
            uses ospfv2-lsdb-asexternal-tos-state;
          }
        }
      }
    }
  }

  grouping ospfv2-lsdb-opaque-lsa-structure {
    description
      "Structural grouping for Opaque LSA contents within the LSDB";

    container opaque-lsa {
      description
        "Contents of the opaque LSA";

      container state {
        description
          "State parameters for the opaque LSA";
        uses ospfv2-lsdb-opaque-lsa-state;
      }

      container traffic-engineering {
        when "../state/type = 'TRAFFIC_ENGINEERING'" {
          description
            "Include the traffic-engineering information when
            the Opaque LSA being described is a Traffic Engineering
            LSA";
        }
        description
          "Contents of the Traffic Engineering Opaque LSA";

        container tlvs {
          description
            "The TLVs contained in the TE Opaque LSA";
          list tlv {
            // this is an unkeyed list
            description
              "The Type-Length-Value tuples included in the TE LSA";

            container state {
              description
                "The contents of the TLV tuple within the TE LSA";
              uses ospfv2-lsdb-opaque-lsa-te-tlv-state;
            }

            uses ospfv2-lsdb-common-unknown-tlv-structure;

            container router-address {
              when "../state/type = 'TE_ROUTER_ADDRESS'" {
                description
                  "Include the router address container only when the type
                  of the TLV is Router Address";
              }

              description
                "Parameters included in the Router Address TLV";

              container state {
                description
                  "State parameters of the router address TLV";
                uses ospfv2-lsdb-opaque-te-router-address-state;
              }
            }

            container link {
              when "../state/type = 'TE_ROUTER_LINK'" {
                description
                  "Include the link container only when the type of the
                  TLV describes a traffic engineering link";
              }

              description
                "Parameters included in the Link TLV";
              container sub-tlvs {
                description
                  "Sub-TLVs included in the Link TLV";

                list sub-tlv {
                  // unkeyed list
                  description
                    "The Sub-TLVs included within the Traffic Engineering
                    LSA's sub-TLV";

                  container state {
                    description
                      "State parameters of the Link Sub-TLV";

                    uses ospfv2-lsdb-opaque-te-link-state;
                  }

                  uses ospfv2-lsdb-common-unknown-subtlv-structure;

                  container unreserved-bandwidths {
                    description
                      "The unreserved link bandwidths for the Traffic
                      Engineering LSA - utilised when the sub-TLV type
                      indicates that the sub-TLV describes unreserved
                      bandwidth";

                    list unreserved-bandwidth {
                      key "priority";

                      description
                        "The unreserved bandwidth at each priority level";

                      leaf priority {
                        type leafref {
                          path "../state/priority";
                        }
                        description
                          "A reference to the priority level being described";
                      }

                      container state {
                        description
                          "State parameters relating to the unreserved
                          bandwidth of the link being described";
                        uses ospfv2-lsdb-opaque-te-link-unreserved-bw-state;
                      }
                    }
                  }

                  container administrative-groups {
                    description
                      "The administrative groups that are set for the
                      Traffic Engineering LSA - utilised when the sub-TLV type
                      indicates that the sub-TLV describes administrative
                      groups";

                    list admin-group {
                      key "bit-index";

                      description
                        "The administrative group described within the
                        sub-TLV";

                      leaf bit-index {
                        type leafref {
                          path "../state/bit-index";
                        }
                        description
                          "A reference to the bit index being described";
                      }

                      container state {
                        description
                          "State parameters relating to the administrative
                          groups being described for the link";
                        uses ospfv2-lsdb-opaque-te-link-admin-group-state;
                      }
                    }
                  }
                }
              }
            }

            container node-attribute {
              when "../state/type = 'TE_NODE_ATTRIBUTE'" {
                description
                  "Include the node-attribute container only when the type of
                  the TLV describes a node attribute";
              }

              description
                "Parameters included in the Node Attribute TLV";

              container sub-tlvs {
                description
                  "Sub-TLVs of the Node Attribute TLV of the Traffic
                  Engineering LSA";

                list sub-tlv {
                  // unkeyed list
                  description
                    "List of the Sub-TLVs contained within the Node Attribute
                    TLV";

                  container state {
                    description
                      "State parameters of the Node Attribute TLV sub-TLV";
                    uses ospfv2-lsdb-opaque-te-node-attribute-state;
                  }

                  uses ospfv2-lsdb-common-unknown-subtlv-structure;
                }
              }
            }

            // A set of TLVs are omitted here - based on operational
            // requirements, these are:
            // * link-local
            // * ipv6-address (OSPFv3 only)
            // * optical-node-property
          }
        }
      } // traffic-engineering

      container grace-lsa {
        when "../state/type = 'GRACE_LSA'" {
          description
            "Include the grace-lsa container when the opaque LSA is specified
            to be of that type.";
        }

        description
          "The Grace LSA is utilised when a remote system is undergoing
          graceful restart";

        container tlvs {
          description
            "TLVs of the Grace LSA";

          list tlv {
            description
              "TLV entry in the Grace LSA, advertised by a system undergoing
              graceful restart";

            // unkeyed list
            container state {
              description
                "Per-TLV state parameters of the Grace LSA";
              uses ospfv2-lsdb-opaque-grace-state;
            }
            uses ospfv2-lsdb-common-unknown-tlv-structure;
          }
        }
      } // grace LSA

      container router-information {
        when "../state/type = 'ROUTER_INFORMATION_LSA'" {
          description
            "Include the router-information container when the opaque LSA
            type is specified to be an RI LSA";
        }

        description
          "The router information LSA is utilised to advertise capabilities
          of a system to other systems who receive the LSA";

        container tlvs {
          description
            "The TLVs included within the Router Information LSA.";

          list tlv {
            description
              "TLV entry in the Router Information LSA";

            // unkeyed list
            container state {
              description
                "Per-TLV state parameters of the RI LSA";
              uses ospfv2-lsdb-opaque-ri-state;
            }

            uses ospfv2-lsdb-common-unknown-tlv-structure;

            container informational-capabilities {
              when "../state/type = 'RI_INFORMATIONAL_CAPABILITIES'" {
                description
                  "Include the informational capabilities specification when
                  the TLV of the RI LSA is specified to be of this type";
              }

              description
                "Information related to the capabilities of the advertising
                router within the scope that the opaque RI LSA is being
                advertised";

              container state {
                description
                  "State parameters of the informational capabilitis of the
                  RI LSA";
                uses ospfv2-lsdb-opaque-ri-informational-state;
              }
            }

            container node-administrative-tags {
              when "../state/type = 'RI_NODE_ADMIN_TAG'" {
                description
                  "Include the node administrative tags specification when
                  the TLV of the RI LSA is specified to be of this type";
              }

              description
                "Per-node administrative tags associated with the local system
                specified by the operator";

              container state {
                description
                  "State parameters of the node administrative tags advertised
                  in the RI LSA";
                uses ospfv2-lsdb-opaque-ri-admintag-state;
              }
            }

            container segment-routing-algorithm {
              when "../state/type = 'RI_SR_ALGORITHM'" {
                description
                  "Include the segment routing algorithm specific parameters when
                  the TLV of the RI LSA is specified to be of this type";
              }

              description
                "The algorithms supported for Segment Routing by the local system";

              container state {
                description
                  "State parameters of the Segment Routing algorithm advertised in
                  the RI LSA";
                uses ospfv2-lsdb-opaque-ri-sralgo-state;
              }
            }

            container segment-routing-sid-label-range {
              when "../state/type = 'RI_SR_SID_LABEL_RANGE'" {
                description
                  "Include the segment routing SID/Label range TLV specific state when
                  the TLV of the RI LSA is specified to be of this type";
              }

              description
                "The Segment Identifier (SID) or label ranges that are supported by
                the local system for Segment Routing";

              container tlvs {
                description
                  "Sub-TLVs of the SID/Label range TLV of the RI LSA";

                list tlv {
                  // unkeyed list
                  description
                    "Sub-TLVs of the SID/Label range TLV";

                  uses ospfv2-lsdb-common-unknown-tlv-structure;

                  container state {
                    description
                      "State parameters of the sub-TLVs of the SR/Label range TLV";
                    uses ospfv2-lsdb-opaque-ri-srrange-tlv-state;
                  }

                  container sid-label {
                    description
                      "Sub-TLV used to advertise the SID or label associated with the
                      subset of the SRGB being advertised";

                    container state {
                      description
                        "State parameters of the SID/Label sub-TLV of the SR/Label
                        range TLV of the RI LSA";
                      uses ospfv2-lsdb-opaque-ri-srrange-sid-label-tlv-state;
                    }
                  }
                }
              }
            }
          }
        }
      } // router-information

      container extended-prefix {
        when "../state/type = 'OSPFV2_EXTENDED_PREFIX'" {
          description
            "Include the extended-prefix container when the opaque LSA
            type is specified to be an extended prefix LSA";
        }

        description
          "An OSPFv2 Extended Prefix Opaque LSA, used to encapsulate
          TLV attributes associated with a prefix advertised in OSPF.";

        reference "RFC7684 - OSPFv2 Prefix/Link Attribute Advertisement";

        container state {
          description
            "State parameters of the Extended Prefix LSA";
          uses ospfv2-lsdb-extended-prefix-state;
        }

        container tlvs {
          description
            "TLVs contained within the Extended Prefix LSA";

          list tlv {
            // unkeyed list
            description
              "A TLV contained within the extended prefix LSA";

            container state {
              description
                "State parameters relating to the sub-TLV of the extended
                prefix LSA";
              uses ospfv2-lsdb-extended-prefix-tlv-state;
            }

            container extended-prefix-range {
              when "../state/type = 'EXTENDED_PREFIX_RANGE'" {
                description
                  "Include the prefix range sub-TLV when the type of the
                  sub-TLV is specified as such";
              }

              description
                "State parameters relating to the extended prefix range
                sub-TLV of the extended prefix LSA";

              container state {
                description
                  "State parameters relating to the Extended Prefix Range
                  sub-TLV of the Extended Prefix LSA";
                uses ospfv2-lsdb-extended-prefix-range-state;
              }
            }

            container prefix-sid {
              when "../state/type = 'PREFIX_SID'" {
                description
                  "Include parameters relating to the Prefix SID when the type
                  of the sub-TLV is indicated as such";
              }

              description
                "State parameters relating to the Prefix SID sub-TLV of the
                extended prefix LSA";

              container state {
                description
                  "State parameters relating to the Prefix SID sub-TLV of the
                  extended prefix LSA";
                uses ospfv2-lsdb-extended-prefix-prefix-sid-state;
              }
            } // prefix-sid

            container sid-label-binding {
              when "../state/type = 'SID_LABEL_BINDING'" {
                description
                  "Include parameters relating to the SID/Label binding sub-TLV
                  only when the type is indicated as such";
              }

              description
                "State parameters relating to the SID/Label binding sub-TLV
                of the extended prefix LSA";

              container state {
                description
                  "State parameters relating to the SID/Label binding sub-TLV
                  of the extended prefix LSA";
                uses ospfv2-lsdb-extended-prefix-sid-label-binding-state;
              }

              container tlvs {
                description
                  "TLVs contained within the SID/Label Binding sub-TLV of the
                  SID/Label Binding TLV";

                list tlv {
                  description
                    "A TLV contained within the SID/Label Binding sub-TLV";

                  container state {
                    description
                      "State parameters relating to the SID/Label Binding
                      sub-TLV";
                    uses ospfv2-lsdb-extended-prefix-sid-label-binding-tlv-state;
                  }

                  container sid-label-binding {
                    when "../state/type = 'SID_LABEL_BINDING'" {
                      description
                        "Include the SID/Label Binding sub-TLV parameters only
                        when the type is indicated as such";
                    }

                    description
                      "Parameters for the SID/Label Binding sub-TLV of the
                      SID/Label binding TLV";

                    container state {
                      description
                        "State parameteres relating to the SID/Label Binding
                        sub-TLV";
                      uses ospfv2-lsdb-extprefix-sid-label-binding-state;
                    }
                  } // sid-label-binding

                  container ero-metric {
                    when "../state/type = 'ERO_METRIC'" {
                      description
                        "Include the ERO Metric sub-TLV parameters only when
                        the type is indicated as such";
                    }

                    description
                      "Parameters for the ERO Metric Sub-TLV of the SID/Label
                      binding TLV";

                    container state {
                      description
                        "State parameters relating to the ERO Metric Sub-TLV of
                        the SID/Label binding TLV";
                      uses ospfv2-lsdb-extprefix-sid-label-ero-metric-state;
                    }
                  } // ero-metric

                  container ero-path {
                    when "../state/type = 'ERO_PATH'" {
                      description
                        "Include the ERO Path sub-TLV parameters only when the
                        type is indicated as such";
                    }

                    description
                      "Parameters for the ERO Path Sub-TLV of the SID/Label
                      binding TLV";

                    container segments {
                      description
                        "Segments of the path described within the SID/Label
                        Binding sub-TLV";

                      list segment {
                        description
                          "A segment of the path described within the sub-TLV";

                        container state {
                          description
                            "State parameters relating to the path segment
                            contained within the sub-TLV";
                          uses ospfv2-lsdb-extprefix-sid-lbl-ero-path-seg-state;
                        }

                        container ipv4-segment {
                          when "../state/type = 'IPV4_SEGMENT'" {
                            description
                              "Include the IPv4 segment only when the type is
                              indicated as such";
                          }

                          description
                            "Details of the IPv4 segment interface of the ERO";

                          container state {
                            description
                              "State parameters of the IPv4 segment of the ERO";
                            uses ospfv2-lsdb-extprefix-sid-lbl-ero-ipv4-state;
                          }
                        } // ipv4-segment

                        container unnumbered-hop {
                          when "../state/type = 'UNNUMBERED_INTERFACE_SEGMENT'" {
                            description
                              "Include the unnumbered segment only when the
                              type is indicated as such";
                          }

                          description
                            "Details of the unnumbered interface segment of the
                            ERO";

                          container state {
                            description
                              "State parameters of the unnumbered interface
                              segment of the ERO";
                            uses ospfv2-lsdb-extprefix-sid-lbl-ero-unnum-state;
                          }
                        } // unnumbered-hop
                      } // tlv
                    } // tlvs
                  }
                }
              }
            } // sid-label-binding

            uses ospfv2-lsdb-common-unknown-tlv-structure;
          }
        }
      } // extended-prefix

      container extended-link {
        description
          "The OSPFv2 Extended Link Opaque LSA, used to encapsulate TLV
          attributes associated with a link advertised in OSPF.";

        reference "RFC7684 - OSPFv2 Prefix/Link Attribute Advertisement";

        container state {
          description
            "State parameters of the Extended Link LSA";
          uses ospfv2-lsdb-extended-link-state;
        }

        container tlvs {
          description
            "TLVs contained within the Extended Link LSA";

          list tlv {
            description
              "List of TLVs within the Extended Link LSA";

            container state {
              description
                "State parameters relating to the sub-TLV of the extended link
                LSA";
              uses ospfv2-lsdb-extended-link-tlv-state;
            }

            uses ospfv2-lsdb-common-unknown-tlv-structure;

            container adjacency-sid {
              when "../state/type = 'ADJACENCY_SID'" {
                description
                  "Include the Adjacency SID parameters only when the type of
                  the sub-TLV is indicated as such";
              }

              description
                "Parameters relating to an Adjacency SID sub-TLV of the
                extended link LSA";

              container state {
                description
                  "State parameters relating to an Adjacency SID";

                uses ospfv2-lsdb-extended-link-adj-sid-state;
              }
            }
          }
        }

      } // extended-link

      uses ospfv2-lsdb-common-unknown-tlv-structure;
    }
  }

  grouping ospfv2-lsdb-generic-lsa-tos-metric-state {
    description
      "Per-TOS state parameters for the Router LSA";

    uses ospfv2-lsdb-common-tos-metric;
  }

  grouping ospfv2-lsdb-router-lsa-state {
    description
      "Parameters of the router LSA";

    leaf type {
      type identityref {
        base "oc-ospf-types:ROUTER_LSA_TYPES";
      }
      description
        "The sub-type of the Router LSA.";
    }

    uses ospfv2-lsdb-common-link-specification;

    leaf metric {
      type oc-ospf-types:ospf-metric;
      description
        "The cost of utilising the link specified independent of TOS";
    }

    leaf number-links {
      type uint16;
      description
        "The number of links that are described within the LSA";
    }

    leaf number-tos-metrics {
      type uint16;
      description
        "The number of different TOS metrics given for this link, not
        including the link metric (which is referred to as TOS 0).";
    }
  }

  grouping ospfv2-lsdb-network-lsa-state {
    description
      "Parameters of the Network LSA";

    leaf network-mask {
      type uint8 {
        range "0..32";
      }
      description
        "The mask of the network described by the Network LSA
        represented as a CIDR mask.";
    }

    leaf-list attached-router {
      type yang:dotted-quad;
      description
        "A list of the router ID of the routers that are attached to
        the network described by the Network LSA";
    }
  }

  grouping ospfv2-lsdb-summary-lsa-state {
    description
      "Parameters of the Summary LSA";

    leaf network-mask {
      type uint8 {
        range "0..32";
      }
      description
        "The mask of the network described by the Summary LSA
        represented as a CIDR mask.";
    }
  }

  grouping ospfv2-lsdb-asexternal-lsa-common-parameters {
    description
      "Common parameters that are used for OSPFv2 AS External LSAs";

    leaf forwarding-address {
      type inet:ipv4-address-no-zone;
      description
        "The destination to which traffic for the external prefix
        should be advertised. When this value is set to 0.0.0.0 then
        traffic should be forwarded to the LSA's originator";
    }

    leaf external-route-tag {
      type uint32;
      description
        "An opaque tag that set by the LSA originator to carry
        information relating to the external route";
    }
  }

  grouping ospfv2-lsdb-asexternal-lsa-state {
    description
      "Parameters for the AS External LSA";

    leaf mask {
      type uint8 {
        range "0..32";
      }
      description
        "The subnet mask for the advertised destination";
    }

    leaf metric-type {
      type enumeration {
        enum "TYPE_1" {
          description
            "When the metric of a prefix is specified as Type 1
            then it is considered to be expressed in the same units as
            the link-state metrics carried in OSPF. That is to say
            that the metric advertised is directly compared to the
            internal cost";
        }
        enum "TYPE_2" {
          description
            "When the metric of a prefix is specified as Type 2 then
            it is considered to be expressed as a cost in addition to
            that of the link-state metric to the advertising router.
            That is to say that the metric is considered to be the
            cost to the advertising router plus the advertised metric
            for the external entity";
        }
      }
      description
        "The type of metric included within the AS External LSA.";
    }

    leaf metric {
      type oc-ospf-types:ospf-metric;
      description
        "The cost to reach the external network specified. The exact
        interpretation of this cost is dependent on the type of
        metric specified";
    }

    uses ospfv2-lsdb-asexternal-lsa-common-parameters;
  }

  grouping ospfv2-lsdb-asexternal-tos-state {
    description
      "Per-TOS parameters for the AS External LSA";

    uses ospfv2-lsdb-asexternal-lsa-common-parameters;
    uses ospfv2-lsdb-common-tos-metric;
  }

  grouping ospfv2-lsdb-nssa-external-lsa-state {
    description
      "Operational state parameters specific to the NSSA External
      LSA";

    leaf propagate {
      type boolean;
      description
        "When this bit is set to true, an NSSA border router will
        translate a Type 7 LSA (NSSA External) to a Type 5 LSA
        (AS External).";
      reference "RFC3101, Section 2.3";
    }
  }

  grouping ospfv2-lsdb-opaque-lsa-state {
    description
      "Operational state parameters specific to an Opaque LSA";

    leaf scope {
      type enumeration {
        enum LINK {
          description
            "The scope of the LSA is the current link. The LSA
            is not flooded beyond the local network. This
            enumeration denotes a Type 9 LSA.";
        }
        enum AREA {
          description
            "The scope of the LSA is the local area. The LSA
            is not flooded beyond the area of origin. This
            enumeration denotes a Type 10 LSA.";
        }
        enum AS {
          description
            "The scope of the LSA is the local autonomous
            system (AS). The flooding domain is the same
            as a Type 5 LSA - it is not flooded into
            stub areas or NSSAs. This enumeration denotes a
            Type 11 LSA.";
        }
      }
      description
        "The scope of the opaque LSA. The type of the LSA
        indicates its scope - the value of this leaf
        determines both the flooding domain, and the type
        of the LSA.";
    }

    leaf type {
      type identityref {
        base "oc-ospf-types:OSPF_OPAQUE_LSA_TYPE";
      }
      description
        "The Opaque Type of the LSA. This value is used to
        indicate the type of data carried by the opaque LSA";
    }
  }

  grouping ospfv2-lsdb-opaque-lsa-te-tlv-state {
    description
      "The contents of the Traffic Engineering LSA";

    leaf type {
      type identityref {
        base "oc-ospf-types:OSPF_TE_LSA_TLV_TYPE";
      }
      description
        "The type of TLV within the Traffic Engineering LSA";
    }
  }

  grouping ospfv2-lsdb-opaque-te-unknown-state {
    description
      "The contents of the unknown TLV within the Traffic Engineering LSA";

    uses ospfv2-lsdb-common-unknown-tlv;
  }

  grouping ospfv2-lsdb-opaque-te-link-state {
    description
      "The contents of the sub-TLVs of a Traffic Engineering LSA Link TLV";

    leaf type {
      type union {
        type identityref {
          base "oc-ospf-types:OSPF_TE_LINK_TLV_TYPE";
        }
        type enumeration {
          enum UNKNOWN {
            description
              "The sub-TLV received in the LSA is unknown to the local
              system";
          }
        }
      }
      description
        "The sub-TLV type specified in the Link TLV. When the value is
        known by the local system, a canonical name of the sub-TLV is utilised
        - the special UNKNOWN value indicates that the system did not
        support the sub-TLV type received in the LSA.";
    }

    leaf unknown-type {
      when "../type = 'UNKNOWN'" {
        description
          "Include the unknown type field only when the sub-TLV was not
          known to the local system";
      }

      type uint16;
      description
        "The value of the type field of an unknown sub-TLV";
    }

    leaf unknown-value {
      when "../type = 'UNKNOWN'" {
        description
          "Include the unknown value field only when the sub-TLV was not
          known to the local system";
      }

      type binary;
      description
        "The binary contents of the unknown TLV";
    }

    leaf link-type {
      when "../type = 'TE_LINK_TYPE'" {
        description
          "Include the link-type field only when the sub-TLV type was a TE
          link type";
      }

      type enumeration {
        enum POINT_TO_POINT {
          description
            "The link being described by the TE LSA Link sub-TLV is a
            point-to-point link to exactly one other system";
        }
        enum MULTI_ACCESS {
          description
            "The link being described by the TE LSA Link sub-TLV is a
            multi-access link that supports connectivity to multiple remote
            systems";
        }
        enum UNKNOWN {
          description
            "The link type received was unknown to the local system";
        }
      }
      description
        "The type of the link that is being described by the TE LSA Link
        sub-TLV";
    }

    leaf link-id {
      when "../type = 'TE_LINK_ID'" {
        description
          "Include the link ID field only when the sub-TLV type was a TE
          Link identifier";
      }

      type yang:dotted-quad;
      description
        "The ID of the remote system. For point-to-point links, this is the
        router ID of the neighbor. For multi-access links it is the address
        of the designated router.";
    }

    leaf-list local-ip-address {
      when "../type = 'TE_LINK_LOCAL_IP'" {
        description
          "Include the local IP address field only when the sub-TLV type was
          a local IP address";
      }

      type inet:ipv4-address-no-zone;
      description
        "The IP address(es) of the local system that correspond to the
        specified TE link";
    }

    leaf-list remote-ip-address {
      when "../type = 'TE_LINK_REMOTE_IP'" {
        description
          "Include the remote IP address field only when the sub-TLV type was
          a remote IP address";
      }

      type inet:ipv4-address-no-zone;
      description
        "The IP address(es) of the remote systems that are attached to the
        specified TE link";
    }

    leaf metric {
      when "../type = 'TE_LINK_METRIC'" {
        description
          "Include the traffic engineering metric only when the sub-TLV type
          is a TE metric";
      }

      type uint32;
      description
        "The metric of the link that should be used for traffic engineering
        purposes. This link may be different than the standard OSPF link
        metric.";
    }

    leaf maximum-bandwidth {
      when "../type = 'TE_LINK_MAXIMUM_BANDWIDTH'" {
        description
          "Include the traffic engineering metric only when the sub-TLV type
          is the maximum bandwidth";
      }

      type oc-types:ieeefloat32;
      units "bytes per second";
      description
        "The maximum bandwidth of the link. This value reflects the actual
        bandwidth of the link expressed asn IEEE 32-bit floating point
        number";
    }

    leaf maximum-reservable-bandwidth {
      when "../type = 'TE_LINK_MAXIUMUM_RESERVABLE_BANDWIDTH'" {
        description
          "Include the maximum reservable bandwidth field only when the
          sub-TLV type is the maximum reservable bandwidth";
      }

      type oc-types:ieeefloat32;
      units "bytes per second";
      description
        "The maximum reservable bandwidth for the link. This value represents
        the total bandwidth which may be used for traffic engineering
        purposes. The value may exceed the maximum-bandwidth value
        in cases where the link is oversubscribed. The value is reflected as
        a 32-bit IEEE floating-point number";
    }
  }

  grouping ospfv2-lsdb-opaque-te-link-unreserved-bw-state {
    description
      "The per-priority unreserved bandwidth described within the unreserved
      bandwidth sub-TLV of the Link TLV of the Traffic Engineering LSA";

    leaf priority {
      type uint8 {
        range "0..7";
      }
      description
        "The priority level being described";
    }

    leaf unreserved-bandwidth {
      type oc-types:ieeefloat32;
      description
        "The unreserved bandwidth for at priority level P, where P is
        equal to the priority of the current list entry. The reservable
        bandwidth at priority P is equal to the sum of the reservable
        bandwidth at all levels 0..P.";
    }
  }

  grouping ospfv2-lsdb-opaque-te-link-admin-group-state {
    description
      "Per bit administrative group status";

    leaf bit-index {
      type uint8 {
        range "0..31";
      }
      description
        "The index of the bit within the 32-bit administrative group field
        of the Administrative Group sub-TLV of the Traffic Engineering LSA";
    }

    leaf set {
      type boolean;
      default false;
      description
        "Whether the bit is set within the administrative group field";
    }
  }

  grouping ospfv2-lsdb-opaque-te-node-attribute-state {
    description
      "State parameters relating to the Traffic Engineering Node Attribute
      TLV of the Traffic Engineering LSA";

    leaf type {
      type union {
        type identityref {
          base "oc-ospf-types:TE_NODE_ATTRIBUTE_TLV_TYPE";
        }
        type enumeration {
          enum UNKNOWN {
            description
              "The sub-TLV type received within the TE LSA Node Attribute TLV
              was unknown the the local system";
          }
        }
      }
      description
        "The type of the sub-TLV of the Node Attribute TLV contained within
        the TE LSA. If the local system can interpret the value received the
        canonical name of the type is utilised, otherwise the special UNKNOWN
        value is used";
    }

    leaf-list local-ipv4-addresses {
      when "../type = 'NODE_IPV4_LOCAL_ADDRESS'" {
        description
          "Include the local IPv4 addresses when the type of the sub-TLV
          indicates that this is the contained data";
      }

      type inet:ipv4-prefix;
      description
        "The local IPv4 addresses of the node expressed in CIDR notation";
    }

    leaf-list local-ipv6-addresses {
      when "../type = 'NODE_LOCAL_IPV6_ADDRESS'" {
        description
          "Include the local IPv6 addresses when the type of the sub-TLV
          indicfates that this is the contained data";
      }

      type inet:ipv6-prefix;
      description
        "The local IPv6 addreses of the node";
    }
  }

  grouping ospfv2-lsdb-opaque-te-router-address-state {
    description
      "The contents of the value field of the Router Address TLV of the
      Traffic Engineering LSA.";

    leaf address {
      type inet:ipv4-address-no-zone;
      description
        "A stable IP address of the advertising router, that is always
        reachable when the router is connected to the network. Typically this
        is a loopback address.";
    }
  }

  grouping ospfv2-lsdb-opaque-grace-state {
    description
      "State parameters on a per-TLV basis of the Grace LSA";

    leaf type {
      type identityref {
        base "oc-ospf-types:GRACE_LSA_TLV_TYPES";
      }
      description
        "The type of the sub-TLV received within the Grace LSA";
    }

    leaf period {
      when "../type = 'GRACE_PERIOD'" {
        description
          "Include the period specification when the sub-TLV type is indicated
          to be of this type";
      }

      type uint32;
      units seconds;
      description
        "The number of seconds that the router's neighbors should advertise
        the local system as fully adjacent regardless of database
        synchronization state";
      reference "RFC3623";
    }

    leaf reason {
      when "../type = 'GRACE_RESTART_REASON'" {
        description
          "Include the restart reason when the sub-TLV type specifies this
          is included";
      }

      type enumeration {
        enum UNKNOWN {
          value 0;
          description
            "The reason for the graceful restart is unknown";
        }
        enum SOFTWARE_RESTART {
          value 1;
          description
            "The local system is restarting due to a software component
            restart";
        }
        enum SOFTWARE_RELOAD_UPGRADE {
          value 2;
          description
            "The local system is restarting due to a software reload or
            upgrade";
        }
        enum CONTROL_PROCESSOR_SWITCH {
          value 3;
          description
            "The local system is restarting due to a switch to a redundant
            control plane element";
        }
      }
      description
        "The reason for the graceful restart event occurring, as advertised
        by the restarting system";
      reference "RFC3623";
    }

    leaf ip-interface-address {
      when "../type = 'GRACE_IP_INTERFACE_ADDRESS'" {
        description
          "Include the interface address when the sub-TLV type specifies that
          it is included";
      }

      type inet:ipv4-address-no-zone;
      description
        "The restarting system's IP address on the interface via which the
        Grace LSA is being advertised.";
    }
  }

  grouping ospfv2-lsdb-opaque-ri-state {
    description
      "State parameters of the Router Information Opaque LSA";

    leaf type {
      type union {
        type identityref {
          base "oc-ospf-types:RI_LSA_TLV_TYPES";
        }
        type enumeration {
          enum UNKNOWN {
            description
              "The TLV received within the RI LSA is unknown";
          }
        }
      }
      description
        "The type of sub-TLV of the Router Information opaque LSA";
    }
  }

  grouping ospfv2-lsdb-opaque-ri-informational-state {
    description
      "State parmaeters of the Router Information Informational Capabilities
      sub-TLV";

    leaf graceful-restart-capable {
      type boolean;
      default false;
      description
        "When this leaf is set to true, the advertising system is capable of
        OSPF graceful restart.";
    }

    leaf graceful-restart-helper {
      type boolean;
      default false;
      description
        "When this leaf is set to true, the advertising system is capable of
        being a helper for OSPF graceful restart";
    }

    leaf stub-router {
      type boolean;
      default false;
      description
        "When this leaf is set to true, the advertising system is able to
        advertise its status as a stub router";
      reference "RFC6987";
    }

    leaf traffic-engineering {
      type boolean;
      default false;
      description
        "When this leaf is set to true, the advertising system supports OSPFv2
        traffic engineering capabilities";
    }

    leaf point-to-point-over-lan {
      type boolean;
      default false;
      description
        "When this leaf is set to true, the advertising system supports treating
        LAN adjacencies as though they were point to point";
      reference "RFC5309";
    }

    leaf experimental-te {
      type boolean;
      default false;
      description
        "When this leaf is set to ture, the advertising system supports the
        experimental extensions to OSPF for TE described in RFC4973";
      reference "RFC4973";
    }
  }

  grouping ospfv2-lsdb-opaque-ri-admintag-state {
    description
      "State parameters relating to the administrative tags specified for
      a node within the RI LSA";

    leaf-list administrative-tags {
      type uint32;
      description
        "The set of administrative tags assigned to the local system by
        the network operator. The meaning of these tags is opaque to OSPF
        - and their interpretation is per-domain specific";
      reference "RFC7777";
    }
  }

  grouping ospfv2-lsdb-opaque-ri-unknown-state {
    description
      "State parameters relating to an unknown TLV within the RI LSA";
    uses ospfv2-lsdb-common-unknown-tlv;
  }

  grouping ospfv2-lsdb-opaque-ri-sralgo-state {
    description
      "State parameters relating to the SR Algorithms TLV of the RI LSA";

    leaf-list supported-algorithms {
      type identityref {
        base "oc-ospf-types:SR_ALGORITHM";
      }
      description
        "A list of the algorithms that are supported for segment routing
        by the advertising system";
    }
  }

  grouping ospfv2-lsdb-opaque-ri-srrange-tlv-state {
    description
      "State parameters relating to the SR SID/Label range TLV of the
      RI LSA";

    leaf type {
      type union {
        type identityref {
          base "oc-ospf-types:OSPF_RI_SR_SID_LABEL_TLV_TYPES";
        }
        type enumeration {
          enum UNKNOWN {
            description
              "The type of the sub-TLV advertised with the SID/Label range
              TLV of the RI LSA is unknown to the receiving system";
          }
        }
      }
      description
        "The type of the sub-TLV received by the local system within the
        SR SID/Label Range TLV of the RI LSA";
    }

    leaf range-size {
      type uint32 {
        range "0..16777216";
      }
      description
        "The number of entries within the range being described within the
        SID/Label range TLV";
    }
  }

  grouping ospfv2-lsdb-opaque-ri-srrange-sid-label-tlv-state {
    description
      "State parameters relating to the SR SID/Label sub-TLV of the SR SID/Label
      range TLV of the RI LSA";

    leaf entry-type {
      type oc-ospf-types:sr-sid-type;
      description
        "The type of entry that is contained within the sub-TLV. The range may
        be represented as either a range of MPLS labels, or numeric segment
        identifiers";
    }

    leaf first-value {
      type uint32;
      description
        "The first value within the SRGB range being specified. The type of the
        entry is determined based on the value of the entry type as this value
        may represent either a segment identifier or an MPLS label.";
    }
  }

  grouping ospfv2-lsdb-extended-prefix-state {
    description
      "State parameters relating to an Extended Prefix LSA";

    leaf route-type {
      type enumeration {
        enum UNSPECIFIED {
          value 0;
          description
            "The prefix described in the extended prefix LSA is of an
            unspecified type";
        }
        enum INTRA_AREA {
          value 1;
          description
            "The prefix described in the extended prefix LSA is an intra-area
            prefix for the advertising system";
        }
        enum INTER_AREA {
          value 3;
          description
            "The prefix described in the extended prefix LSA is an inter-area
            prefix for the advertising system";
        }
        enum AS_EXTERNAL {
          value 5;
          description
            "The prefix described in the extended prefix LSA is external to the
            autonomous system of the advertising system";
        }
        enum NSSA_EXTERNAL {
          value 7;
          description
            "The prefix described in the extended prefix LSA externally
            advertised from an NSSA area visibile to the advertising system";
        }
      }
      description
        "The type of prefix that is contained within the Extended Prefix LSA.
        The information contained in sub-TLVs of the attribute is applicable
        regardless of this value.";
    }

    uses ospfv2-lsdb-common-prefix-properties;

    leaf attached {
      type boolean;
      default false;
      description
        "If this value is set to true, the prefix being advertised was
        generated by an ABR for an inter-area prefix. The value corresponds
        to the A-flag of the flags field of the Extended Prefix LSA";
    }

    leaf node {
      type boolean;
      default false;
      description
        "If this value is set to true, the prefix being advertised represents
        the advertising router. Typically, the prefix within the LSA is
        expected to be globally-reachable prefix associated with a loopback
        interface";
    }

    leaf prefix {
      type inet:ipv4-address-no-zone;
      description
        "The IPv4 prefix contained within the extended prefix LSA";
    }
  }

  grouping ospfv2-lsdb-extended-link-state {
    description
      "State parameters related to an extended link LSA";

    leaf link-type {
      type identityref {
        base "oc-ospf-types:OSPFV2_ROUTER_LINK_TYPE";
      }
      description
        "The type of link with which extended attributes are associated";
    }

    uses ospfv2-lsdb-common-link-specification;

  }

  grouping ospfv2-lsdb-extended-link-tlv-state {
    description
      "State parameters relating to a sub-TLV of the extended link LSA";

    leaf type {
      type identityref {
        base "oc-ospf-types:OSPFV2_EXTENDED_LINK_SUBTLV_TYPE";
      }
      description
        "The type of the sub-TLV contained within the extended link TLV";
    }
  }

  grouping ospfv2-lsdb-extended-prefix-tlv-state {
    description
      "State parameters related to a sub-TLV of an Extended Prefix LSA";

    leaf type {
      type identityref {
        base "oc-ospf-types:OSPFV2_EXTENDED_PREFIX_SUBTLV_TYPE";
      }
      description
        "The type of sub-TLV as indicated by the Extended Prefix LSA";
    }
  }

  grouping ospfv2-lsdb-extended-prefix-range-state {
    description
      "Parameters of the Extended Prefix Range SubTLV";

    uses ospfv2-lsdb-common-prefix-properties;

    leaf range-size {
      type uint16;
      description
        "The number of prefixes that are covered by the advertisement.";
    }

    leaf inter-area {
      type boolean;
      default false;
      description
        "When this leaf is set to true, then the prefix range is inter-area -
        the flag is set by the ABR that advertises the Extended Prefix Range
        TLV";
    }

    leaf prefix {
      type inet:ipv4-prefix;
      description
        "The first prefix in the range of prefixes being described by the
        extended prefix range sub-TLV";
    }
  }

  grouping ospfv2-lsdb-extended-prefix-prefix-sid-state {
    description
      "Parameters of the Prefix-SID sub-TLV";

    leaf no-php {
      type boolean;
      default false;
      description
        "If this leaf is set the advertising system has indicated that the
        prefix SID must not be popped before delivering packets to it";
    }

    leaf mapping-server {
      type boolean;
      default false;
      description
        "If this leaf is set the SID was advertised by a Segment Routing
        mapping server";
    }

    leaf explicit-null {
      type boolean;
      default false;
      description
        "If this leaf is set, the advertising system has requested that the
        prefix SID value should be replaced with the explicit null label
        value";
    }

    leaf sid-value-type {
      type enumeration {
        enum ABSOLUTE {
          description
            "The SID contained in the Prefix-SID sub-TLV is an absolute
            value";
        }
        enum INDEX {
          description
            "The SID contained in the Prefix-SID sub-TLV is an index to the
            SRGB";
        }
      }
      description
        "Specifies the type of the value specified within the Prefix SID
        sub-TLV - in particular, whether the value is an index or an
        absolute value. This value corresponds with the V-flag of the Prefix
        SID sub-TLV";
    }

    leaf sid-scope {
      type enumeration {
        enum LOCAL {
          description
            "The value of the SID is
            significant only to the advertising system";
        }
        enum GLOBAL {
          description
            "The value of the SID is globally significant";
        }
      }
      description
        "Specifies the scope of the SID advertisement within the Prefix SID
        sub-TLV. The scope of the SID is independent of whether the SID
        contained is an index, or an absolute value";
    }

    leaf multi-topology-identifier {
      type uint8;
      description
        "The identifier for the topology to which the Prefix SID relates. The
        value of this leaf is a MT-ID as defined in RFC4915";
    }

    leaf algorithm {
      type uint8;
      description
        "The algorithm that computes the path associated with the Prefix SID";
    }

    leaf sid-value {
      type uint32;
      description
        "The value of the Prefix SID. The meaning of this value is dependent
        upon the type of SID, and its scope. The value contained is either a
        32-bit value indicating the index of the SID, or a 24-bit label where
        the 20 right-most bits are used for encoding the label value";
    }
  }

  grouping ospfv2-lsdb-extended-prefix-sid-label-binding-state {
    description
      "State parameters relating to the extended prefix SID SID/Label binding
      sub-TLV";

    leaf mirroring {
      type boolean;
      default false;
      description
        "When set to true, this indicates that the SID/Label Binding sub-TLV
        entries contained within this TLV are indicative of a mirroring
        context";
    }

    leaf multi-topology-identifier {
      type uint8;
      description
        "The identifier for the topology to which the SID/Label Binding
        sub-TLV is associated. The value of this leaf is a MT-ID as defined
        in RFC4915";
    }

    leaf weight {
      type uint8;
      description
        "The weight of the advertised binding when used for load-balancing
        purposes";
    }
  }

  grouping ospfv2-lsdb-extended-prefix-sid-label-binding-tlv-state {
    description
      "State parameters directly relating to the SID/Label Binding TLV";

    leaf type {
      type identityref {
        base
         "oc-ospf-types:OSPFV2_EXTENDED_PREFIX_SID_LABEL_BINDING_SUBTLV_TYPE";
      }
      description
        "The type of sub-TLV that is being contained within the SID/Label
        sub-TLV";
    }
  }

  grouping ospfv2-lsdb-extprefix-sid-label-binding-state {
    description
      "State parameters relating to the SID/Label binding sub-TLV of the
      SID/Label/Binding TLV";

    uses ospfv2-lsdb-common-sr-sid-spec;
  }

  grouping ospfv2-lsdb-extprefix-sid-label-ero-metric-state {
    description
      "State parameters relating to the ERO Metric Sub-TLV of the SID/Label
      Binding TLV";

    leaf metric {
      type uint32;
      description
        "The metric representing the aggregate IGP or TE path cost for the
        binding included within the SID/Label Binding TLV";
    }
  }

  grouping ospfv2-lsdb-extprefix-sid-lbl-ero-path-seg-state {
    description
      "State parameters relating to the a segment included within the
      ERO Path Sub-TLV of the SID/Label Binding TLV";

    leaf type {
      type identityref {
        base "oc-ospf-types:OSPFV2_EXTPREFIX_BINDING_ERO_PATH_SEGMENT_TYPE";
      }
      description
        "The type of the segment being specified as part of the ERO";
    }

    leaf loose {
      type boolean;
      default false;
      description
        "If this leaf is set the segment is identifier as a loose path
        segment, otherwise the path strictly follows the path specified";
    }
  }

  grouping ospfv2-lsdb-extprefix-sid-lbl-ero-ipv4-state {
    description
      "State parameters relating to an IPv4 address segment included within
      the ERO path";

    leaf address {
      type inet:ipv4-address-no-zone;
      description
        "The IPv4 address of the hop within the ERO";
    }
  }

  grouping ospfv2-lsdb-extprefix-sid-lbl-ero-unnum-state {
    description
      "State parameters relating to an unnumbered hop within the ERO path";

    leaf router-id {
      type inet:ipv4-address-no-zone;
      description
        "The IPv4 router identtifier of the remote system";
    }

    leaf interface-id {
      type uint32;
      description
        "The identifier assigned to the link by the remote system";
    }
  }

  grouping ospfv2-lsdb-extended-link-adj-sid-state {
    description
      "State parameters relating to the Adjacency SID sub-TLV of the
      Extended Link LSA";

    leaf backup {
      type boolean;
      default false;
      description
        "When this flag is set, it indicates that the adjacency SID refers to
        an adjacency which is eligible for protection";
    }

    leaf group {
      type boolean;
      default false;
      description
        "When this flag is set it indicates that the adjacency SID refers to
        a group of adjacencies that have a common value";
    }

    uses ospfv2-lsdb-common-sr-sid-spec;

    leaf weight {
      type uint8;
      description
        "The weight of the Adjacency SID when used for load-balancing";
    }

    leaf multi-topology-identifier {
      type uint8;
      description
        "The multi-topology identifier with which the adjacency SID is
        associated";
    }
  }

  grouping ospfv2-lsdb-structure {
    description
      "Structural grouping for per-area LSDB contents";

    container lsdb {
      // Top-level RO, if this were ever to become writeable then
      // the state containers lower down need config false added
      config false;
      description
        "The link-state database for the OSPFv2 area";

      container state {
        description
          "Operational state parameters relating to the OSPFv2
          area";

        uses ospfv2-lsdb-area-state;
      }

      container lsa-types {
        description
          "Enclosing container for a list of LSA types that are
          in the LSDB for the specified area";

        list lsa-type {
          key "type";

          description
            "List of LSA types in the LSDB for the specified
            area";

          leaf type {
            type leafref {
              path "../state/type";
            }
            description
              "A reference for the LSA type being described within
              the LSDB";
          }

          container state {
            description
              "Top-level operational state parameters relating to
              an LSA within the area";
            uses ospfv2-lsdb-area-lsa-type-state;
          }

          container lsas {
            description
              "Enclosing container for a list of the LSAs of
              the specified type received by the system";

            list lsa {
              key "link-state-id";

              description
                "List of the LSAs of a specified type in the
                LSDB for the specified area";

              leaf link-state-id {
                type leafref {
                  path "../state/link-state-id";
                }
                description
                  "Reference to the Link State ID of the LSA";
              }

              container state {
                description
                  "Operational state parameters relating to all
                  LSA types";
                uses ospfv2-lsdb-area-lsa-state;
              }

              uses ospfv2-lsdb-router-lsa-structure {
                when "../../state/type = 'ROUTER_LSA'" {
                  description
                    "Include the router LSA hierarchy solely when
                    that LSA type is being described";
                }
              }

              uses ospfv2-lsdb-network-lsa-structure {
                when "../../state/type = 'NETWORK_LSA'" {
                  description
                    "Include the network LSA hierarchy solely when
                    that LSA type is being described";
                }
              }

              uses ospfv2-lsdb-summary-lsa-structure {
                // rjs TODO: check this syntax
                when "../../state/type = " +
                  "'SUMMARY_IP_NETWORK_LSA' or " +
                  "../../state/type = 'SUMMARY_ASBR_LSA'" {
                  description
                    "Include the summary LSA hierarchy solely when
                    that LSA type is being described";
                }
              }

              uses ospfv2-lsdb-asexternal-lsa-structure {
                when "../../state/type = 'AS_EXTERNAL_LSA'" {
                  description
                    "Include the AS external LSA hierarchy solely when
                    that LSA type is being described";
                }
              }

              uses ospfv2-lsdb-nssa-external-lsa-structure {
                when "../../state/type = 'NSSA_AS_EXTERNAL_LSA'" {
                  description
                    "Include the NSSA External LSA hierarchy solely
                    when that LSA type is being described";
                }
              }

              uses ospfv2-lsdb-opaque-lsa-structure {
                when "../../state/type = 'OSPFV2_LINK_SCOPE_OPAQUE_LSA'
                  or ../../state/type = 'OSPFV2_AREA_SCOPE_OPAQUE_LSA'
                  or ../../state/type = 'OSPFV2_AS_SCOPE_OPAQUE_LSA'" {
                  description
                    "Include the Opaque LSA structure when type of entry
                    being described in an opaque LSA";
                }
              }
            }
          }
        }
      }
    }
  }
}