public HipPacket handleClose(byte[] src, byte[] dst, HipPacket close,
			HipSadb sadb, SignatureAlgo sigAlgo, HostIdentityTag hit) {
		SaEntry __entry = null;
		HMACParameter __hmacParam = null;
		HipPacket __closeAck = null;
		SignatureParameter __sigParameter = null;
		byte[] __signature = null;
		byte[] __hmac = null;
		byte[] __opaque = new byte[4];

		EchoRequestSigParameter __echoRequest = null;
		EchoResponseSigParameter __echoResponse = (EchoResponseSigParameter) HipParameterFactoryImpl
				.createHipParameter(EchoResponseSigParameter.TYPE_ECHO_SIG_RESPONSE);

		byte[] __hitR = null;
		byte[] __hitI = null;

		if (close == null)
			return null;

		__echoRequest = (EchoRequestSigParameter) close
				.getParameter(EchoRequestSigParameter.TYPE_ECHO_SIG_REQUEST);

		if (__echoRequest == null)
			return null;

		__echoRequest.getOpaque(__opaque);
		__echoResponse.setOpaque(__opaque);

		__hitR = new byte[HostIdentityTag.TAGLENGTH];
		__hitI = new byte[HostIdentityTag.TAGLENGTH];

		close.getSourceHit(__hitI);
		close.getDestinationHit(__hitR);

		if (!hit.equals(__hitR))
			return null;

		__entry = sadb.find(new HostIdentityTag(__hitI));

		if (__entry == null)
			return null; // process based on destination ip instead

		if (!HipPacket.verifyHMAC(close, __entry.getPeerHostID(),
				new HMACSHA1Digest(__entry.getAuthKeyIn()))) {
			System.out.println("HMAC VERIFICATION FAILED");
			return null;
		}

		if (!HipPacket.verifySignature(close, sigAlgo, __entry
				.getPeerPublicKey()))
			return null;

		IPPacket __packet = null;

		if (close.getIPVersion() == IPPacket.IP_VERSION4) {
			__packet = new IPPacket(DEFAULT_IPV4_LENGTH);
			// SET IP VERSION FIRST
			__packet.setIPVersion(IPPacket.IP_VERSION4);
			__packet.setIPHeaderLength(DEFAULT_IPV4_LENGTH / 4);
			__packet.setTTL(DEFAULT_TTL);
			__packet.setProtocol(HipPacket.HIP_PROTO);
			__packet.setSource(dst);
			__packet.setDestination(src);

		} else {
			// TODO: IPv6 ...
		}

		__closeAck = HipPacketFactoryImpl.getFactory().createCloseAckPacket(
				__packet, __hitI, __hitR, __echoResponse);

		__hmacParam = (HMACParameter) HipParameterFactoryImpl
				.createHipParameter(HMACParameter.TYPE_HMAC);
		__closeAck.setParameter(__hmacParam);
		__hmac = HipPacket.computeHMAC(__closeAck, __entry.getLocalHostID(),
				new HMACSHA1Digest(__entry.getAuthKeyOut()));
		__hmacParam.setHMAC(__hmac);
		__closeAck.setParameter(__hmacParam, true);

		__sigParameter = (SignatureParameter) HipParameterFactoryImpl
				.createHipParameter(SignatureParameter.TYPE_SIGNATURE);

		__closeAck.setParameter(__sigParameter);
		__signature = HipPacket.computeSignature(__closeAck, sigAlgo, __entry
				.getLocalPrivateKey());
		__sigParameter.setSignature(__signature);
		__sigParameter.setSigAlgo((byte) __entry.getSignatureAlgo());
		__closeAck.setParameter(__sigParameter, true);
		__closeAck.setHIPChecksum();

		__entry.setState(HipState.CLOSED);
		__entry.setTimer(System.currentTimeMillis());
		__entry.setRetransmitCounter(0);

		return __closeAck;
	}