util: Add a function to render timestamp type
TLV_PORT_PROPERTIES_NP carries, among other attributes, a timestamp type used for that port. In order to make it possible to format the value for user consumption, introduce a new function ts_str(). Signed-off-by: Petr Machata <petrm@mellanox.com>
This commit is contained in:
		
							parent
							
								
									48e605ef01
								
							
						
					
					
						commit
						f9f00d8fe8
					
				
							
								
								
									
										18
									
								
								util.c
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								util.c
									
									
									
									
									
								
							@ -70,6 +70,24 @@ const char *ev_str[] = {
 | 
				
			|||||||
	"RS_PASSIVE",
 | 
						"RS_PASSIVE",
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const char *ts_str(enum timestamp_type ts)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						switch (ts) {
 | 
				
			||||||
 | 
						case TS_SOFTWARE:
 | 
				
			||||||
 | 
							return "SOFTWARE";
 | 
				
			||||||
 | 
						case TS_HARDWARE:
 | 
				
			||||||
 | 
							return "HARDWARE";
 | 
				
			||||||
 | 
						case TS_LEGACY_HW:
 | 
				
			||||||
 | 
							return "LEGACY_HW";
 | 
				
			||||||
 | 
						case TS_ONESTEP:
 | 
				
			||||||
 | 
							return "ONESTEP";
 | 
				
			||||||
 | 
						case TS_P2P1STEP:
 | 
				
			||||||
 | 
							return "P2P1STEP";
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return "???";
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int addreq(enum transport_type type, struct address *a, struct address *b)
 | 
					int addreq(enum transport_type type, struct address *a, struct address *b)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	void *bufa, *bufb;
 | 
						void *bufa, *bufb;
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										7
									
								
								util.h
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								util.h
									
									
									
									
									
								
							@ -41,6 +41,13 @@ extern const char *ps_str[];
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
extern const char *ev_str[];
 | 
					extern const char *ev_str[];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Gets a human-readable string for a given timestamp type.
 | 
				
			||||||
 | 
					 * @param ts    Timestamp type.
 | 
				
			||||||
 | 
					 * @return      Human-readable rendering if TS is valid, otherwise "???".
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					const char *ts_str(enum timestamp_type ts);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Compares two binary addresses for equality.
 | 
					 * Compares two binary addresses for equality.
 | 
				
			||||||
 * @param type  One of the enumerated transport types.
 | 
					 * @param type  One of the enumerated transport types.
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user