@@ -2168,7 +2168,7 @@ handle_bridge_port_priority(NetplanParser* npp, yaml_node_t* node, const char* k
21682168}
21692169
21702170static gboolean
2171- handle_generic_vlans (yaml_document_t * doc , yaml_node_t * node , GArray * * entryptr , const void * data , GError * * error )
2171+ handle_generic_vlans (NetplanParser * npp , yaml_node_t * node , GArray * * entryptr , GError * * error )
21722172{
21732173 static regex_t re ;
21742174 static gboolean re_inited = FALSE;
@@ -2180,8 +2180,8 @@ handle_generic_vlans(yaml_document_t* doc, yaml_node_t* node, GArray** entryptr,
21802180
21812181 for (yaml_node_item_t * i = node -> data .sequence .items .start ; i < node -> data .sequence .items .top ; i ++ ) {
21822182 g_autofree char * vlan = NULL ;
2183- yaml_node_t * entry = yaml_document_get_node (doc , * i );
2184- assert_type (entry , YAML_SCALAR_NODE );
2183+ yaml_node_t * entry = yaml_document_get_node (& npp -> doc , * i );
2184+ assert_type (npp , entry , YAML_SCALAR_NODE );
21852185
21862186 vlan = g_strdup (scalar (entry ));
21872187
@@ -2191,7 +2191,7 @@ handle_generic_vlans(yaml_document_t* doc, yaml_node_t* node, GArray** entryptr,
21912191 if (regexec (& re , vlan , maxGroups , groups , 0 ) == 0 ) {
21922192 NetplanBridgeVlan * data = g_new0 (NetplanBridgeVlan , 1 );
21932193 for (unsigned g = 1 ; g < maxGroups ; g = g + 2 ) {
2194- if (groups [g ].rm_so == (size_t )-1 )
2194+ if (groups [g ].rm_so == (int )( size_t )-1 )
21952195 continue ; // Invalid group
21962196
21972197 char cursorCopy [strlen (vlan ) + 1 ];
@@ -2200,17 +2200,17 @@ handle_generic_vlans(yaml_document_t* doc, yaml_node_t* node, GArray** entryptr,
22002200 guint v = 0 ;
22012201 switch (g ) {
22022202 case 1 :
2203- v = g_ascii_strtoull (cursorCopy + groups [g ].rm_so , NULL , 10 );
2203+ v = ( guint ) g_ascii_strtoull (cursorCopy + groups [g ].rm_so , NULL , 10 );
22042204 if (v < 1 || v > 4094 )
2205- return yaml_error (node , error , "malformed vlan vid '%u', must be in range [1..4094]" , v );
2205+ return yaml_error (npp , node , error , "malformed vlan vid '%u', must be in range [1..4094]" , v );
22062206 data -> vid = v ;
22072207 break ;
22082208 case 3 :
2209- v = g_ascii_strtoull (cursorCopy + groups [g ].rm_so , NULL , 10 );
2209+ v = ( guint ) g_ascii_strtoull (cursorCopy + groups [g ].rm_so , NULL , 10 );
22102210 if (v < 1 || v > 4094 )
2211- return yaml_error (node , error , "malformed vlan vid '%u', must be in range [1..4094]" , v );
2211+ return yaml_error (npp , node , error , "malformed vlan vid '%u', must be in range [1..4094]" , v );
22122212 else if (v <= data -> vid )
2213- return yaml_error (node , error , "malformed vlan vid range '%s': %u > %u!" , scalar (entry ), data -> vid , v );
2213+ return yaml_error (npp , node , error , "malformed vlan vid range '%s': %u > %u!" , scalar (entry ), data -> vid , v );
22142214 data -> vid_to = v ;
22152215 break ;
22162216 case 5 :
@@ -2228,41 +2228,41 @@ handle_generic_vlans(yaml_document_t* doc, yaml_node_t* node, GArray** entryptr,
22282228 continue ;
22292229 }
22302230
2231- return yaml_error (node , error , "malformed vlan '%s', must be: $vid [pvid] [untagged] [, $vid [pvid] [untagged]]" , scalar (entry ));
2231+ return yaml_error (npp , node , error , "malformed vlan '%s', must be: $vid [pvid] [untagged] [, $vid [pvid] [untagged]]" , scalar (entry ));
22322232 }
22332233
22342234 return TRUE;
22352235}
22362236
22372237static gboolean
2238- handle_bridge_vlans (yaml_document_t * doc , yaml_node_t * node , const void * data , GError * * error )
2238+ handle_bridge_vlans (NetplanParser * npp , yaml_node_t * node , const void * , GError * * error )
22392239{
2240- return handle_generic_vlans (doc , node , & (cur_netdef -> bridge_params .vlans ), data , error );
2240+ return handle_generic_vlans (npp , node , & (npp -> current . netdef -> bridge_params .vlans ), error );
22412241}
22422242
22432243static gboolean
2244- handle_bridge_port_vlans (yaml_document_t * doc , yaml_node_t * node , const void * data , GError * * error )
2244+ handle_bridge_port_vlans (NetplanParser * npp , yaml_node_t * node , const char * , const void * , GError * * error )
22452245{
22462246 for (yaml_node_pair_t * entry = node -> data .mapping .pairs .start ; entry < node -> data .mapping .pairs .top ; entry ++ ) {
22472247 yaml_node_t * key , * value ;
22482248 NetplanNetDefinition * component ;
22492249 GArray * * ref_ptr ;
22502250
2251- key = yaml_document_get_node (doc , entry -> key );
2252- assert_type (key , YAML_SCALAR_NODE );
2253- value = yaml_document_get_node (doc , entry -> value );
2254- assert_type (value , YAML_SEQUENCE_NODE );
2251+ key = yaml_document_get_node (& npp -> doc , entry -> key );
2252+ assert_type (npp , key , YAML_SCALAR_NODE );
2253+ value = yaml_document_get_node (& npp -> doc , entry -> value );
2254+ assert_type (npp , value , YAML_SEQUENCE_NODE );
22552255
2256- component = g_hash_table_lookup (netdefs , scalar (key ));
2256+ component = g_hash_table_lookup (npp -> parsed_defs , scalar (key ));
22572257 if (!component ) {
2258- add_missing_node (key );
2258+ add_missing_node (npp , key );
22592259 } else {
22602260 ref_ptr = & (component -> bridge_params .port_vlans );
22612261 if (* ref_ptr )
2262- return yaml_error (node , error , "%s: interface '%s' already has port vlans" ,
2263- cur_netdef -> id , scalar (key ));
2262+ return yaml_error (npp , node , error , "%s: interface '%s' already has port vlans" ,
2263+ npp -> current . netdef -> id , scalar (key ));
22642264
2265- if (!handle_generic_vlans (doc , value , ref_ptr , data , error ))
2265+ if (!handle_generic_vlans (npp , value , ref_ptr , error ))
22662266 return FALSE;
22672267 }
22682268 }
@@ -2277,10 +2277,11 @@ static const mapping_entry_handler bridge_params_handlers[] = {
22772277 {"max-age" , YAML_SCALAR_NODE , {.generic = handle_netdef_str }, netdef_offset (bridge_params .max_age )},
22782278 {"path-cost" , YAML_MAPPING_NODE , {.map = {.custom = handle_bridge_path_cost }}, netdef_offset (bridge_params .path_cost )},
22792279 {"port-priority" , YAML_MAPPING_NODE , {.map = {.custom = handle_bridge_port_priority }}, netdef_offset (bridge_params .port_priority )},
2280- {"port-vlans" , YAML_MAPPING_NODE , handle_bridge_port_vlans },
22812280 {"priority" , YAML_SCALAR_NODE , {.generic = handle_netdef_guint }, netdef_offset (bridge_params .priority )},
22822281 {"stp" , YAML_SCALAR_NODE , {.generic = handle_netdef_bool }, netdef_offset (bridge_params .stp )},
2283- {"vlans" , YAML_SEQUENCE_NODE , handle_bridge_vlans },
2282+ {"port-vlans" , YAML_MAPPING_NODE , {.map = {.custom = handle_bridge_port_vlans }}, netdef_offset (bridge_params .port_vlans )},
2283+ {"vlans" , YAML_SEQUENCE_NODE , {.generic = handle_bridge_vlans }, netdef_offset (bridge_params .vlans )},
2284+ {"vlan-filtering" , YAML_SCALAR_NODE , {.generic = handle_netdef_bool }, netdef_offset (bridge_params .vlan_filtering )},
22842285 {NULL }
22852286};
22862287
@@ -3772,6 +3773,7 @@ netplan_parser_load_yaml(NetplanParser* npp, const char* filename, GError** erro
37723773
37733774 if (!load_yaml (filename , doc , error ))
37743775 return FALSE;
3776+
37753777 return _netplan_parser_load_single_file (npp , filename , doc , error );
37763778}
37773779
0 commit comments