ti->dataInfo[fieldNo].enterpriseNo = 0;
ti->dataInfo[fieldNo].typeX.eid = 0;
void processDataTemplateSet(SourceID sourceId, IpfixSetHeader* set) {	IpfixDataTemplateHeader* th = (IpfixDataTemplateHeader*)&set->data;	byte* endOfSet = (byte*)set + ntoh(set->length);	byte* record = (byte*)&th->data;	/* DataTemplateSets are >= 4 byte, so we stop processing when only 3 bytes are left */	while (record < endOfSet - 3) {		BufferedTemplate* bt = (BufferedTemplate*)malloc(sizeof(BufferedTemplate));		DataTemplateInfo* ti = (DataTemplateInfo*)malloc(sizeof(DataTemplateInfo));		bt->sourceID = sourceId;		bt->templateID = ntoh(th->templateId);		bt->recordLength = 0;		bt->setID = ntoh(set->id);		bt->dataTemplateInfo = ti;		bt->dataTemplateDestructionCallbackFunction = dataTemplateDestructionCallbackFunction;		ti->userData = 0;		ti->fieldCount = th->fieldCount;		ti->dataCount = th->dataCount;		ti->fieldInfo = (FieldInfo*)malloc(ti->fieldCount * sizeof(FieldInfo));		boolean lengthVarying = false;		uint16 fieldNo;		for (fieldNo = 0; fieldNo < ti->fieldCount; fieldNo++) {			ti->fieldInfo[fieldNo].type = ntoh(*(uint16*)((byte*)record+0));			ti->fieldInfo[fieldNo].length = ntoh(*(uint16*)((byte*)record+2));			ti->fieldInfo[fieldNo].offset = bt->recordLength; bt->recordLength+=ti->fieldInfo[fieldNo].length;			if (ti->fieldInfo[fieldNo].length == 65535) lengthVarying=true;			if (ti->fieldInfo[fieldNo].type & 0x80) {				ti->fieldInfo[fieldNo].enterpriseNo = ntoh(*(uint32*)((byte*)record+4));				record = (byte*)((byte*)record+8);				} else {				ti->fieldInfo[fieldNo].enterpriseNo = 0;				record = (byte*)((byte*)record+4);				}			}		if (lengthVarying) {  			bt->recordLength = 65535;			for (fieldNo = 0; fieldNo < ti->fieldCount; fieldNo++) ti->fieldInfo[fieldNo].offset = 65535;  			}		ti->dataInfo = (FieldInfo*)malloc(ti->fieldCount * sizeof(FieldInfo));		for (fieldNo = 0; fieldNo < ti->dataCount; fieldNo++) {			ti->dataInfo[fieldNo].type = ntoh(*(uint16*)((byte*)record+0));			ti->dataInfo[fieldNo].length = ntoh(*(uint16*)((byte*)record+2));			if (ti->dataInfo[fieldNo].type & 0x80) {				ti->dataInfo[fieldNo].enterpriseNo = ntoh(*(uint32*)((byte*)record+4));				record = (byte*)((byte*)record+8);				} else {				ti->dataInfo[fieldNo].enterpriseNo = 0;				record = (byte*)((byte*)record+4);				}			ti->dataInfo[fieldNo].offset = (record - &th->data);			if (ti->dataInfo[fieldNo].length == 65535) {				if (*(byte*)record < 255) {					ti->dataInfo[fieldNo].length = *(byte*)record;					} else {					ti->dataInfo[fieldNo].length = *(uint16*)(record+1);					}				}			record = record + ti->dataInfo[fieldNo].length;			}		// Copy fixed data block		int dataLength = (record - &th->data);		ti->data = (byte*)malloc(dataLength);		memcpy(ti->data,&th->data,dataLength);		bufferTemplate(bt); bt->expires = time(0) + TEMPLATE_EXPIRE_SECS;		if (dataTemplateCallbackFunction != 0) {			dataTemplateCallbackFunction(sourceId, ti);			}  		}	}