/* * Pack the record 'rwrec' into an array of bytes 'ar' */ static int ipv6ioRecordPack_V1( skstream_t *rwIOS, const rwGenericRec_V5 *rwrec, uint8_t *ar) { uint32_t ip; rwRecMemGetStartTime(rwrec, &ar[0]); rwRecMemGetElapsed(rwrec, &ar[8]); rwRecMemGetSPort(rwrec, &ar[12]); rwRecMemGetDPort(rwrec, &ar[14]); rwRecMemGetProto(rwrec, &ar[16]); rwRecMemGetFlowType(rwrec, &ar[17]); rwRecMemGetSensor(rwrec, &ar[18]); rwRecMemGetFlags(rwrec, &ar[20]); rwRecMemGetInitFlags(rwrec, &ar[21]); rwRecMemGetRestFlags(rwrec, &ar[22]); rwRecMemGetTcpState(rwrec, &ar[23]); rwRecMemGetApplication(rwrec, &ar[24]); rwRecMemGetMemo(rwrec, &ar[26]); rwRecMemGetPkts(rwrec, &ar[28]); rwRecMemGetBytes(rwrec, &ar[32]); if (rwRecIsIPv6(rwrec)) { /* Record is IPv6 */ #if !SK_ENABLE_IPV6 return SKSTREAM_ERR_UNSUPPORT_IPV6; #else ar[23] |= 0x80; rwRecMemGetSIPv6(rwrec, &ar[36]); rwRecMemGetDIPv6(rwrec, &ar[52]); #endif /* SK_ENABLE_IPV6 */ } else { /* Record is IPv4, but encode as IPv6 */ /* sIP */ ip = htonl(rwRecGetSIPv4(rwrec)); memcpy(&ar[36], IP4in6_prefix, sizeof(IP4in6_prefix)); memcpy(&ar[48], &ip, sizeof(ip)); /* dIP */ ip = htonl(rwRecGetDIPv4(rwrec)); memcpy(&ar[52], IP4in6_prefix, sizeof(IP4in6_prefix)); memcpy(&ar[64], &ip, sizeof(ip)); } /* swap if required */ if (rwIOS->swapFlag) { ipv6ioRecordSwap_V1(ar); } return SKSTREAM_OK; }
/* * Pack the record 'rwrec' into an array of bytes 'ar' */ static int genericioRecordPack_V5( skstream_t *rwIOS, const rwGenericRec_V5 *rwrec, uint8_t *ar) { #if !SK_ENABLE_IPV6 memcpy(ar, rwrec, RECLEN_RWGENERIC_V5); #else rwRecMemGetStartTime(rwrec, &ar[0]); rwRecMemGetElapsed(rwrec, &ar[8]); rwRecMemGetSPort(rwrec, &ar[12]); rwRecMemGetDPort(rwrec, &ar[14]); rwRecMemGetProto(rwrec, &ar[16]); rwRecMemGetFlowType(rwrec, &ar[17]); rwRecMemGetSensor(rwrec, &ar[18]); rwRecMemGetFlags(rwrec, &ar[20]); rwRecMemGetInitFlags(rwrec, &ar[21]); rwRecMemGetRestFlags(rwrec, &ar[22]); rwRecMemGetTcpState(rwrec, &ar[23]); rwRecMemGetApplication(rwrec, &ar[24]); rwRecMemGetMemo(rwrec, &ar[26]); rwRecMemGetInput(rwrec, &ar[28]); rwRecMemGetOutput(rwrec, &ar[30]); rwRecMemGetPkts(rwrec, &ar[32]); rwRecMemGetBytes(rwrec, &ar[36]); rwRecMemGetSIPv4(rwrec, &ar[40]); rwRecMemGetDIPv4(rwrec, &ar[44]); rwRecMemGetNhIPv4(rwrec, &ar[48]); #endif /* swap if required */ if (rwIOS->swapFlag) { genericioRecordSwap_V5(ar); } return SKSTREAM_OK; }
/* * Pack the record 'rwrec' into an array of bytes 'ar' */ static int ipv6routingioRecordPack_V3( skstream_t *stream, const rwRec *rwrec, uint8_t *ar) { uint32_t u32; uint64_t u64; rwRecMemGetStartTime(rwrec, &ar[0]); rwRecMemGetElapsed(rwrec, &ar[8]); rwRecMemGetSPort(rwrec, &ar[12]); rwRecMemGetDPort(rwrec, &ar[14]); rwRecMemGetProto(rwrec, &ar[16]); rwRecMemGetFlowType(rwrec, &ar[17]); rwRecMemGetSensor(rwrec, &ar[18]); rwRecMemGetFlags(rwrec, &ar[20]); rwRecMemGetInitFlags(rwrec, &ar[21]); rwRecMemGetRestFlags(rwrec, &ar[22]); rwRecMemGetTcpState(rwrec, &ar[23]); rwRecMemGetApplication(rwrec, &ar[24]); rwRecMemGetMemo(rwrec, &ar[26]); u32 = rwRecGetInput(rwrec); memcpy(&ar[28], &u32, sizeof(u32)); u64 = rwRecGetPkts(rwrec); memcpy(&ar[32], &u64, sizeof(u64)); u64 = rwRecGetBytes(rwrec); memcpy(&ar[40], &u64, sizeof(u64)); u32 = rwRecGetOutput(rwrec); memcpy(&ar[96], &u32, sizeof(u32)); if (rwRecIsIPv6(rwrec)) { /* Record is IPv6 */ #if !SK_ENABLE_IPV6 return SKSTREAM_ERR_UNSUPPORT_IPV6; #else ar[23] |= 0x80; rwRecMemGetSIPv6(rwrec, &ar[48]); rwRecMemGetDIPv6(rwrec, &ar[64]); rwRecMemGetNhIPv6(rwrec, &ar[80]); #endif /* SK_ENABLE_IPV6 */ } else { /* Record is IPv4, but encode as IPv6 */ uint32_t ip; /* sIP */ ip = htonl(rwRecGetSIPv4(rwrec)); memcpy(&ar[48], IP4in6_prefix, sizeof(IP4in6_prefix)); memcpy(&ar[60], &ip, sizeof(ip)); /* dIP */ ip = htonl(rwRecGetDIPv4(rwrec)); memcpy(&ar[64], IP4in6_prefix, sizeof(IP4in6_prefix)); memcpy(&ar[76], &ip, sizeof(ip)); /* nhIP */ ip = htonl(rwRecGetNhIPv4(rwrec)); memcpy(&ar[80], IP4in6_prefix, sizeof(IP4in6_prefix)); memcpy(&ar[92], &ip, sizeof(ip)); } /* swap if required */ if (stream->swapFlag) { ipv6routingioRecordSwap_V3(ar); } return SKSTREAM_OK; }