Skip to content

Commit c110832

Browse files
committed
net: schema: Configuration schema using jsonschema yaml format
Convert network configuration schema in pykwalify format to jsonschema format because pykwalify is being deprecated in zephyr and jsonschema is used in the future. Signed-off-by: Jukka Rissanen <[email protected]>
1 parent 93caed4 commit c110832

File tree

1 file changed

+220
-156
lines changed

1 file changed

+220
-156
lines changed
Lines changed: 220 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -1,160 +1,224 @@
11
# SPDX-License-Identifier: Apache-2.0
22
#
3-
# Copyright (c) 2024 Nordic Semiconductor ASA
3+
# Copyright (c) 2025 Nordic Semiconductor ASA
44
#
5-
# A pykwalify schema for basic validation of the network configuration yaml file.
5+
# A JSON schema for basic validation of the network configuration yaml file.
66

7-
type: map
8-
mapping:
9-
"net_init_config":
10-
type: map
11-
mapping:
12-
"config_format_hash":
13-
type: str
14-
"network_interfaces":
15-
type: seq
16-
sequence:
17-
- type: map
18-
required: true
19-
mapping:
20-
"bind_to":
21-
type: any
22-
"name":
23-
type: str
24-
"device_name":
25-
type: str
26-
"set_name":
27-
type: str
28-
"set_default":
29-
type: bool
30-
"flags":
31-
type: seq
32-
sequence:
33-
- type: str
34-
required: true
35-
"ipv6":
36-
type: map
37-
mapping:
38-
"status":
39-
type: bool
40-
"ipv6_addresses":
41-
type: seq
42-
sequence:
43-
- type: str
44-
required: true
45-
"ipv6_multicast_addresses":
46-
type: seq
47-
sequence:
48-
- type: str
49-
required: true
50-
"prefixes":
51-
type: seq
52-
sequence:
53-
- type: map
54-
required: true
55-
mapping:
56-
"address":
57-
type: str
58-
required: true
59-
"len":
60-
type: int
61-
required: true
62-
"lifetime":
63-
type: int
64-
required: true
65-
"hop_limit":
66-
type: int
67-
"multicast_hop_limit":
68-
type: int
69-
"dhcpv6":
70-
type: map
71-
mapping:
72-
"status":
73-
type: bool
74-
"do_request_address":
75-
type: bool
76-
"do_request_prefix":
77-
type: bool
78-
"ipv4":
79-
type: map
80-
mapping:
81-
"status":
82-
type: bool
83-
"ipv4_addresses":
84-
type: seq
85-
sequence:
86-
- type: str
87-
required: true
88-
"ipv4_multicast_addresses":
89-
type: seq
90-
sequence:
91-
- type: str
92-
required: true
93-
"gateway":
94-
type: str
95-
"time_to_live":
96-
type: int
97-
"multicast_time_to_live":
98-
type: int
99-
"dhcpv4":
100-
type: map
101-
mapping:
102-
"status":
103-
type: bool
104-
"dhcpv4_server":
105-
type: map
106-
mapping:
107-
"status":
108-
type: bool
109-
"base_address":
110-
type: str
111-
"ipv4_autoconf":
112-
type: map
113-
mapping:
114-
"status":
115-
type: bool
116-
"vlan":
117-
type: map
118-
mapping:
119-
"status":
120-
type: bool
121-
"tag":
122-
type: int
123-
required: true
124-
"ieee_802_15_4":
125-
type: map
126-
mapping:
127-
"status":
128-
type: bool
129-
"bind_to":
130-
type: any
131-
"pan_id":
132-
type: int
133-
required: true
134-
"channel":
135-
type: int
136-
required: true
137-
"tx_power":
138-
type: int
139-
"security_key":
140-
type: seq
141-
sequence:
142-
- type: int
143-
"security_key_mode":
144-
type: int
145-
"security_level":
146-
type: int
147-
"ack_required":
148-
type: bool
149-
"sntp":
150-
type: map
151-
mapping:
152-
"status":
153-
type: bool
154-
"server":
155-
type: str
156-
required: true
157-
"timeout":
158-
type: int
159-
"bind_to":
160-
type: any
7+
$id: "https://zephyrproject.org/schemas/zephyr/network"
8+
$schema: "https://json-schema.org/draft/2020-12/schema"
9+
10+
title: "Zephyr Network Configuration Schema"
11+
description: Schema for validating Zephyr network configuration metadata files
12+
type: object
13+
properties:
14+
net_init_config:
15+
type: object
16+
properties:
17+
config_format_hash:
18+
type: string
19+
description: Hash for the configuration data (internal)
20+
network_interfaces:
21+
description: List of network interfaces
22+
type: array
23+
items:
24+
type: object
25+
properties:
26+
bind_to: {}
27+
name:
28+
description: Network interface name to bind to
29+
type: string
30+
# CONFIG_NET_INTERFACE_NAME_LEN
31+
maxLength: 15
32+
minLength: 2
33+
device_name:
34+
description: Device name to bind to
35+
type: string
36+
set_name:
37+
description: New name of the network interface
38+
type: string
39+
# CONFIG_NET_INTERFACE_NAME_LEN
40+
maxLength: 15
41+
minLength: 2
42+
set_default:
43+
description: Set this interface as a default one
44+
type: boolean
45+
flags:
46+
description: Network interface flags to set
47+
type: array
48+
items:
49+
type: string
50+
maxLength: 32
51+
ipv6:
52+
description: IPv6 configuration
53+
type: object
54+
properties:
55+
status:
56+
description: Is IPv6 enabled for this interface
57+
type: boolean
58+
ipv6_addresses:
59+
description: Static IPv6 addresses for this interface
60+
type: array
61+
items:
62+
type: string
63+
# INET6_ADDRSTRLEN + prefix len (like "/128")
64+
maxLength: 50
65+
ipv6_multicast_addresses:
66+
description: Multicast IPv6 addresses for this interface
67+
type: array
68+
items:
69+
type: string
70+
# NET_IPV6_ADDR_STR_LEN
71+
maxLength: 40
72+
prefixes:
73+
description: IPv6 prefixes for this interface
74+
type: array
75+
items:
76+
type: object
77+
properties:
78+
address:
79+
description: IPv6 prefix
80+
type: string
81+
# NET_IPV6_ADDR_STR_LEN
82+
maxLength: 40
83+
len:
84+
description: IPv6 prefix length
85+
type: integer
86+
lifetime:
87+
description: IPv6 prefix lifetime (in sec)
88+
type: integer
89+
required:
90+
- address
91+
- len
92+
- lifetime
93+
hop_limit:
94+
description: IPv6 hop limit
95+
type: integer
96+
multicast_hop_limit:
97+
description: IPv6 multicast hop limit
98+
type: integer
99+
dhcpv6:
100+
description: DHCPv6 configuration
101+
type: object
102+
properties:
103+
status:
104+
description: Is DHCPv6 enabled for this interface
105+
type: boolean
106+
do_request_address:
107+
description: Set request address flag
108+
type: boolean
109+
do_request_prefix:
110+
description: Set request prefix flag
111+
type: boolean
112+
ipv4:
113+
description: IPv4 configuration
114+
type: object
115+
properties:
116+
status:
117+
description: Is IPv4 enabled for this interface
118+
type: boolean
119+
ipv4_addresses:
120+
description: Static IPv4 addresses for this interface
121+
type: array
122+
items:
123+
type: string
124+
# INET_ADDRSTRLEN + netmask len (like "/24")
125+
maxLength: 19
126+
ipv4_multicast_addresses:
127+
description: Multicast IPv4 addresses for this interface
128+
type: array
129+
items:
130+
type: string
131+
# INET_ADDRSTRLEN
132+
maxLength: 16
133+
gateway:
134+
description: IPv4 gateway to use
135+
type: string
136+
# INET_ADDRSTRLEN
137+
maxLength: 16
138+
time_to_live:
139+
description: IPv4 time-to-live
140+
type: integer
141+
multicast_time_to_live:
142+
description: IPv4 multicast time-to-live
143+
type: integer
144+
dhcpv4:
145+
description: DHCPv4 configuration
146+
type: object
147+
properties:
148+
status:
149+
description: Is DHCPv4 enabled for this interface
150+
type: boolean
151+
dhcpv4_server:
152+
type: object
153+
properties:
154+
status:
155+
description: Is DHCPv4 server enabled for this interface
156+
type: boolean
157+
base_address:
158+
description: Set base address for the DHCPv4 server
159+
type: string
160+
# INET_ADDRSTRLEN
161+
maxLength: 16
162+
ipv4_autoconf:
163+
description: IPv4 autoconfiguration
164+
type: object
165+
properties:
166+
status:
167+
description: Is IPv4 auto configuration enabled for this interface
168+
type: boolean
169+
vlan:
170+
description: Virtual LAN configuration
171+
type: object
172+
properties:
173+
status:
174+
description: Is VLAN enabled for this interface
175+
type: boolean
176+
tag:
177+
description: VLAN tag for this interface
178+
type: integer
179+
required:
180+
- tag
181+
ieee_802_15_4:
182+
type: object
183+
properties:
184+
status:
185+
description: Is IEEE 802.15.4 enabled
186+
type: boolean
187+
bind_to: {}
188+
pan_id:
189+
type: integer
190+
channel:
191+
type: integer
192+
tx_power:
193+
type: integer
194+
security_key_mode:
195+
type: integer
196+
security_level:
197+
type: integer
198+
ack_required:
199+
type: boolean
200+
security_key:
201+
type: array
202+
items:
203+
type: integer
204+
required:
205+
- pan_id
206+
- channel
207+
sntp:
208+
type: object
209+
properties:
210+
status:
211+
description: Is SNTP enabled
212+
type: boolean
213+
server:
214+
description: SNTP server address
215+
type: string
216+
# INET6_ADDRSTRLEN
217+
maxLength: 46
218+
timeout:
219+
description: Request timeout in sec
220+
type: integer
221+
bind_to: {}
222+
required:
223+
- server
224+
additionalProperties: false

0 commit comments

Comments
 (0)