File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -173,15 +173,22 @@ function ip_in_network = {
173173 by structure_interface + 'subnet' which is the subnet number (result of applying the\
174174 mask to the address. `subnet` key is mandatory, 'netmask` defaults to 255.255.255.0.
175175 arg = ip address to test
176+ arg = boolean. When true, keep subnet parameter in return value. Default: false.
176177}
177178function get_subnet_params = {
178- if ( ARGC ! = 2 ) {
179- error (" get_subnet_params requires 2 arguments" );
179+ if ( ARGC < 2 || ARGC > 3 ) {
180+ error (" get_subnet_params requires 2 or 3 arguments" );
180181 };
181182
182183 subnet_list = ARGV[0];
183184 ipaddr = ARGV[1];
184185
186+ if ( ARGC == 3 ) {
187+ keep_subnet = ARGV[2];
188+ } else {
189+ keep_subnet = false;
190+ };
191+
185192 if ( ! is_list (subnet_list) ) {
186193 error (" get_subnet_params first argument must be a list" );
187194 };
@@ -217,7 +224,9 @@ function get_subnet_params = {
217224 };
218225
219226 if ( ip_in_network(ipaddr, params[' subnet' ], params[' netmask' ]) ) {
220- delete (params[" subnet" ]); # Suppress subnet key
227+ if (! keep_subnet) {
228+ delete (params[" subnet" ]); # Suppress subnet key
229+ };
221230 return (params);
222231 };
223232 };
You can’t perform that action at this time.
0 commit comments