ipfix_put_template_data(exporter, my_template_id, dataTemplateInfo->data, dataLength);
char* data = (char*)malloc(dataLength); memcpy(data, dataTemplateInfo->data, dataLength); for (i = 0; i < dataTemplateInfo->fieldCount; i++) { FieldInfo* fi = &dataTemplateInfo->fieldInfo[i];   if ((fi->type.id == IPFIX_TYPEID_sourceIPv4Address) && (fi->type.length == 5)) { uint8_t* mask = (uint8_t*)(data + fi->offset + 4); *mask = 32 - *mask; } else if ((fi->type.id == IPFIX_TYPEID_destinationIPv4Address) && (fi->type.length == 5)) { uint8_t* mask = (uint8_t*)(data + fi->offset + 4); *mask = 32 - *mask; } else { }
int sndNewDataTemplate(DataTemplateInfo* dataTemplateInfo) {	uint16_t my_template_id = ++lastTemplateId;	/* put Template ID in Template's userData */	int* p = (int*)malloc(sizeof(int));	*p = htons(my_template_id);	dataTemplateInfo->userData = p;		int i;	/* Count number of IPv4 fields with length 5 */		int splitFields = 0;	for (i = 0; i < dataTemplateInfo->fieldCount; i++) {		FieldInfo* fi = &dataTemplateInfo->fieldInfo[i];		if ((fi->type.id == IPFIX_TYPEID_sourceIPv4Address) && (fi->type.length == 5)) {			splitFields++;			}		else if ((fi->type.id == IPFIX_TYPEID_destinationIPv4Address) && (fi->type.length == 5)) {			splitFields++;			}		}	/* Count number of IPv4 fields with length 5 */		int splitFixedfields = 0;	for (i = 0; i < dataTemplateInfo->dataCount; i++) {		FieldInfo* fi = &dataTemplateInfo->dataInfo[i];		if ((fi->type.id == IPFIX_TYPEID_sourceIPv4Address) && (fi->type.length == 5)) {			splitFixedfields++;			}		else if ((fi->type.id == IPFIX_TYPEID_destinationIPv4Address) && (fi->type.length == 5)) {			splitFixedfields++;			}		}							ipfix_start_datatemplate_set(exporter, my_template_id, dataTemplateInfo->fieldCount + splitFields, dataTemplateInfo->dataCount + splitFixedfields);	for (i = 0; i < dataTemplateInfo->fieldCount; i++) {		FieldInfo* fi = &dataTemplateInfo->fieldInfo[i];				/* Split IPv4 fields with length 5, i.e. fields with network mask attached */		if ((fi->type.id == IPFIX_TYPEID_sourceIPv4Address) && (fi->type.length == 5)) {			ipfix_put_template_field(exporter, my_template_id, IPFIX_TYPEID_sourceIPv4Address, 4, 0);			ipfix_put_template_field(exporter, my_template_id, IPFIX_TYPEID_sourceIPv4Mask, 1, 0);			}		else if ((fi->type.id == IPFIX_TYPEID_destinationIPv4Address) && (fi->type.length == 5)) {			ipfix_put_template_field(exporter, my_template_id, IPFIX_TYPEID_destinationIPv4Address, 4, 0);			ipfix_put_template_field(exporter, my_template_id, IPFIX_TYPEID_destinationIPv4Mask, 1, 0);			}		else {			ipfix_put_template_field(exporter, my_template_id, fi->type.id, fi->type.length, fi->type.eid);			}		}	debugf("%d data fields", dataTemplateInfo->dataCount);		int dataLength = 0;	for (i = 0; i < dataTemplateInfo->dataCount; i++) {		FieldInfo* fi = &dataTemplateInfo->dataInfo[i];				dataLength += fi->type.length;				/* Split IPv4 fields with length 5, i.e. fields with network mask attached */		if ((fi->type.id == IPFIX_TYPEID_sourceIPv4Address) && (fi->type.length == 5)) {			ipfix_put_template_fixedfield(exporter, my_template_id, IPFIX_TYPEID_sourceIPv4Address, 4, 0);			ipfix_put_template_fixedfield(exporter, my_template_id, IPFIX_TYPEID_sourceIPv4Mask, 1, 0);			}		else if ((fi->type.id == IPFIX_TYPEID_destinationIPv4Address) && (fi->type.length == 5)) {			ipfix_put_template_fixedfield(exporter, my_template_id, IPFIX_TYPEID_destinationIPv4Address, 4, 0);			ipfix_put_template_fixedfield(exporter, my_template_id, IPFIX_TYPEID_destinationIPv4Mask, 1, 0);			}		else {			ipfix_put_template_fixedfield(exporter, my_template_id, fi->type.id, fi->type.length, fi->type.eid);			}		}		debugf("%d data length", dataLength);	/* FIXME: split fixed fields */	ipfix_put_template_data(exporter, my_template_id, dataTemplateInfo->data, dataLength);			ipfix_end_template_set(exporter, my_template_id);	return 0;	}