memcpy(dstData, srcData, srcType->length); bzero(dstData + srcType->length, dstType->length - srcType->length);
if ((dstType->id == IPFIX_TYPEID_sourceIPv4Address) || (dstType->id == IPFIX_TYPEID_destinationIPv4Address)) {  bzero(dstData, dstType->length); memcpy(dstData, srcData, srcType->length); } else {  bzero(dstData, dstType->length); memcpy(dstData + dstType->length - srcType->length, srcData, srcType->length); }
void copyData(FieldType* dstType, FieldData* dstData, FieldType* srcType, FieldData* srcData, FieldModifier modifier) {	if ((dstType->id != srcType->id) || (dstType->eid != srcType->eid)) {		fatal("Tried to copy field to destination of different type");		return;		}		/* Copy data, care for length differences */	if (dstType->length == srcType->length) {		memcpy(dstData, srcData, srcType->length);		}	else if (dstType->length > srcType->length) {		/* TODO: We simply pad with zeroes - will this always be correct? */		memcpy(dstData, srcData, srcType->length);		bzero(dstData + srcType->length, dstType->length - srcType->length);		}	else {		fatalf("Target buffer too small. Buffer expected %s of length %d, got one with length %d", typeid2string(dstType->id), dstType->length, srcType->length);		return;		}	/* Apply modifier */		if (modifier == FIELD_MODIFIER_DISCARD) {		fatal("Tried to copy data w/ having field modifier set to discard");		return;		}	else if ((modifier == FIELD_MODIFIER_KEEP) || (modifier == FIELD_MODIFIER_AGGREGATE)) {		}	else if ((modifier >= FIELD_MODIFIER_MASK_START) && (modifier <= FIELD_MODIFIER_MASK_END)) {		if ((dstType->id != IPFIX_TYPEID_sourceIPv4Address) && (dstType->id != IPFIX_TYPEID_destinationIPv4Address)) {			fatalf("Tried to apply mask to %s field", typeid2string(dstType->id));			return;			}		if (dstType->length != 5) {			fatal("Destination data to short - no room to store mask");			return;			}					uint8_t imask = 32 - (modifier - FIELD_MODIFIER_MASK_START);		dstData[4] = imask; /* store the inverse network mask */				if (imask > 0) {			if (imask == 8) {				dstData[3] = 0x00;				}			else if (imask == 16) {				dstData[2] = 0x00;				dstData[3] = 0x00;				}			else if (imask == 24) {				dstData[1] = 0x00;				dstData[2] = 0x00;				dstData[3] = 0x00;				}			else if (imask == 32) {				dstData[0] = 0x00;				dstData[1] = 0x00;				dstData[2] = 0x00;				dstData[3] = 0x00;				}			else {				int pattern = 0;				int i;				for (i = 0; i < imask; i++) pattern |= (1 << i);				*(uint32_t*)dstData = htonl(ntohl(*(uint32_t*)(dstData)) & ~pattern);				}			}				}	else {		fatalf("Unhandled field modifier: %d", modifier);		return;		}	}