interface: Introduce a method to set the name.
The name field of the interface is set in different ways by different callers. In order to prevent users from open coding the logic that sets the name, this patch adds an appropriate method. Signed-off-by: Richard Cochran <richardcochran@gmail.com> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
This commit is contained in:
		
							parent
							
								
									a8df585e04
								
							
						
					
					
						commit
						47982fb8c8
					
				@ -27,3 +27,8 @@ const char *interface_name(struct interface *iface)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	return iface->name;
 | 
						return iface->name;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void interface_set_name(struct interface *iface, const char *name)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						strncpy(iface->name, name, MAX_IFNAME_SIZE);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -53,5 +53,11 @@ const char *interface_label(struct interface *iface);
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
const char *interface_name(struct interface *iface);
 | 
					const char *interface_name(struct interface *iface);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					/**
 | 
				
			||||||
 | 
					 * Set the name of a given interface.
 | 
				
			||||||
 | 
					 * @param iface  The interface of interest.
 | 
				
			||||||
 | 
					 * @param name   The desired name for the interface.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					void interface_set_name(struct interface *iface, const char *name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user