public HipPacket handleI1(byte[] src, byte[] dst, HipPacket i1,
			HipSadb sadb, HostIdentityTag hit, HostIdentity hi, PrivateKey key,
			CacheEntry cache) {
		SaEntry __entry = null;

		byte[] __hitR = null;
		byte[] __hitI = null;
		long now = System.nanoTime();
		long sigvertime = 0;
		long siggentime = 0;
		long dhgentime = 0;
		long __rand = new SecureRandom().nextLong();
		PuzzleParameter __puzzleParameter = null;
		HostIDParameter __ourHiParam = null;
		if (i1 == null)
			return null;
		__hitR = new byte[HostIdentityTag.TAGLENGTH];
		__hitI = new byte[HostIdentityTag.TAGLENGTH];
		i1.getSourceHit(__hitI);
		i1.getDestinationHit(__hitR);

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

		if (__entry != null
				&& __entry.getState() == SaEntry.HipState.ESTABLISHED)
			return null; // we need to return more information to the caller,
		// TODO: change to exception instead

		if (__entry != null && __entry.getState() == SaEntry.HipState.I1_SENT) {
			if (hit.compare(__hitI) < 0) { // sender's hit is greater
				return null;// drop I1 and stay in I1_SENT; again more
				// informative response needed
			}
		}

		__puzzleParameter = (PuzzleParameter) cache.__r1
				.getParameter(PuzzleParameter.TYPE_PUZZLE);
		__puzzleParameter.setPuzzle(__rand);
		cache.__r1.setParameter(__puzzleParameter, true);

		__ourHiParam = (HostIDParameter) HipParameterFactoryImpl
				.createHipParameter(HostIDParameter.TYPE_HOST_ID);
		__ourHiParam.setHI(hi.getBytes());
		__ourHiParam.setHostIDLength(hi.getBytes().length);

		if (i1.getIPVersion() == IPPacket.IP_VERSION4) {
			cache.__r1.setSource(dst);
			cache.__r1.setDestination(src);
		} else {
			return null;
		}
		
		cache.__r1.setDestinationHit(__hitI);

		cache.__r1.setHIPChecksum();

		if (__entry == null) {
			try {
				__entry = new HipSadb.SaEntry();
				__entry.setDHKeyPair(cache.__dh);
				__entry.setInnerSrc(new HostIdentityTag(__hitR).getAsAddress());
				__entry.setInnerDst(new HostIdentityTag(__hitI).getAsAddress());
				__entry.setOuterSrc(i1.getDestinationAsInetAddress());
				__entry.setOuterDst(i1.getSourceAsInetAddress());
				__entry.setRandom(__rand);
				__entry.setState(HipState.UNASSOCIATED);
				__entry.setLocalHostID(__ourHiParam);
				__entry.setLocalPrivateKey(key);
				__entry.setSignatureAlgo(hi.getAlgo());
				__entry.setLastPacket(cache.__r1);
				__entry.setTimer(System.currentTimeMillis());
				__entry.setRetransmitCounter(0);
				sadb.add(__entry);
			} catch (Exception e) {
				e.printStackTrace();
				return null;
			}
		}
		return cache.__r1;
	}