umbim: add "_proto_mbim_get_field" helper
Add a new helper to extract IP configuration from umbim output. This is required to extract fields which can possibly have multiple values, namely IP addresses and DNS servers, and get rid of primitive parser using 'eval' builtin without support for this. Signed-off-by: Lech Perczak <lech.perczak@gmail.com>
This commit is contained in:
		 Lech Perczak
					Lech Perczak
				
			
				
					committed by
					
						 Hauke Mehrtens
						Hauke Mehrtens
					
				
			
			
				
	
			
			
			 Hauke Mehrtens
						Hauke Mehrtens
					
				
			
						parent
						
							5f873df8d4
						
					
				
				
					commit
					f01fff63fb
				
			| @@ -26,6 +26,18 @@ proto_mbim_init_config() { | |||||||
| 	proto_config_add_defaults | 	proto_config_add_defaults | ||||||
| } | } | ||||||
|  |  | ||||||
|  | _proto_mbim_get_field() { | ||||||
|  |         local field="$1" | ||||||
|  |         shift | ||||||
|  |         local mbimconfig="$@" | ||||||
|  |         echo "$mbimconfig" | while read -r line; do | ||||||
|  |                 variable=${line%%:*} | ||||||
|  |                 [ "$variable" = "$field" ] || continue; | ||||||
|  |                 value=${line##* } | ||||||
|  |                 echo -n "$value " | ||||||
|  |         done | ||||||
|  | } | ||||||
|  |  | ||||||
| _proto_mbim_setup() { | _proto_mbim_setup() { | ||||||
| 	local interface="$1" | 	local interface="$1" | ||||||
| 	local tid=2 | 	local tid=2 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user