Ipv6TypeEVExtFactory.HEADER_FIELD);
if (ipHeader != null) {
pseudoBlock = createV6PseudoHeader(cxt, (IContainerValue)value,
ipHeader, upperPrtlBytes, startOffset);
} else {
throw new EncodeException(targetTypeMeta,
MetaException.CODE.LOWER_LAYER_PROTOCOL_WRONG_ERROR,
"Ipv4Protocol or Ipv6Protocol");
}
}
//计算Checksum
byte[] checksum = FpbUtils.internetChecksum(pseudoBlock);
if (isUdp) {
buffer.position(startOffset + UDP_CHECKSUM_FIELD_OFFSET);
//UDP的特殊处理0x0000->0xFFFF
if (checksum[0] == 0 && checksum[1] == 0) {
checksum[0] = (byte)0xFF;
checksum[1] = (byte)0xFF;
}
} else {
buffer.position(startOffset + TCP_CHECKSUM_FIELD_OFFSET);
}
buffer.putByte(checksum);
} catch (BitBufferException e) {
throw new EncodeException(targetTypeMeta,
MetaException.CODE.BIT_BUFFER_EXCEPTION_ERROR, e);
}
//恢复Position
buffer.position(curPosition);
return result;