msg: Introduce a TLV list.
In order to support multiple TLVs per message, a list is needed. This patch adds the list to the message structure. This list will eventually replace the 'last_tlv' field. Signed-off-by: Richard Cochran <richardcochran@gmail.com>
This commit is contained in:
		
							parent
							
								
									c8d9d05e7a
								
							
						
					
					
						commit
						22b894b687
					
				
							
								
								
									
										16
									
								
								msg.c
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								msg.c
									
									
									
									
									
								
							| @ -204,6 +204,7 @@ struct ptp_message *msg_allocate(void) | |||||||
| 	if (m) { | 	if (m) { | ||||||
| 		memset(m, 0, sizeof(*m)); | 		memset(m, 0, sizeof(*m)); | ||||||
| 		m->refcnt = 1; | 		m->refcnt = 1; | ||||||
|  | 		TAILQ_INIT(&m->tlv_list); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return m; | 	return m; | ||||||
| @ -447,12 +448,19 @@ void msg_print(struct ptp_message *m, FILE *fp) | |||||||
| 
 | 
 | ||||||
| void msg_put(struct ptp_message *m) | void msg_put(struct ptp_message *m) | ||||||
| { | { | ||||||
|  | 	struct tlv_extra *extra; | ||||||
|  | 
 | ||||||
| 	m->refcnt--; | 	m->refcnt--; | ||||||
| 	if (!m->refcnt) { | 	if (m->refcnt) { | ||||||
| 		pool_stats.count++; | 		return; | ||||||
| 		pool_debug("recycle", m); |  | ||||||
| 		TAILQ_INSERT_HEAD(&msg_pool, m, list); |  | ||||||
| 	} | 	} | ||||||
|  | 	pool_stats.count++; | ||||||
|  | 	pool_debug("recycle", m); | ||||||
|  | 	while ((extra = TAILQ_FIRST(&m->tlv_list)) != NULL) { | ||||||
|  | 		TAILQ_REMOVE(&m->tlv_list, extra, list); | ||||||
|  | 		tlv_extra_recycle(extra); | ||||||
|  | 	} | ||||||
|  | 	TAILQ_INSERT_HEAD(&msg_pool, m, list); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int msg_sots_missing(struct ptp_message *m) | int msg_sots_missing(struct ptp_message *m) | ||||||
|  | |||||||
							
								
								
									
										5
									
								
								msg.h
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								msg.h
									
									
									
									
									
								
							| @ -219,6 +219,11 @@ struct ptp_message { | |||||||
| 	 * sent to. | 	 * sent to. | ||||||
| 	 */ | 	 */ | ||||||
| 	struct address address; | 	struct address address; | ||||||
|  | 	/**
 | ||||||
|  | 	 * List of TLV descriptors.  Each item in the list contains | ||||||
|  | 	 * pointers to the appended TLVs. | ||||||
|  | 	 */ | ||||||
|  | 	TAILQ_HEAD(tlv_list, tlv_extra) tlv_list; | ||||||
| 	/**
 | 	/**
 | ||||||
| 	 * Contains the number of TLVs in the suffix. | 	 * Contains the number of TLVs in the suffix. | ||||||
| 	 */ | 	 */ | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user