Esempio n. 1
0
static void
filter_ip(void *address, int ifa_flags, int ifa_scope, int preferred_time)
{
	bool deprecated = ifa_flags & IFA_F_DEPRECATED;
	bool temporary = ifa_flags & IFA_F_TEMPORARY;
	bool global = ifa_scope == RT_SCOPE_UNIVERSE;

	if (deprecated || temporary || !global) //filter old and temporary IPs
	{
		if(verbose_mode)
		{
			bool local = !global;
			log_ipv6(address);
			log(" rejected for being %s%s%s\n", STRBOOL(deprecated), STRBOOL(temporary), STRBOOL(local));
		}
		return;
	}
	else if (preferred_time <= 0)
	{
		if(verbose_mode)
		{
			log_ipv6(address);
			log(" rejected for not preferred (time expired: %d)\n", preferred_time);
		}
		return;
	}
	else //accept and process further
	{
		log_ipv6(address);
		if(verbose_mode) log("\n\tflags: dep: %d temp: %d global: %d pref: %d\n", deprecated, temporary, global, preferred_time);
		activate_ip(address);
	}
}
Esempio n. 2
0
void WriteIPv4Hdr(IPV4_HDR* hdr)
{
	struct sockaddr_in src, dest;
	src.sin_addr.s_addr = hdr->srcAddr;
	dest.sin_addr.s_addr = hdr->destAddr;

#ifdef FILE_LOG
	fprintf(pFile, "IP Header\n");
	LOG("|- IP Version: %u\n", hdr->version);
	LOG("|- IP Header Length: %u Octets\n", hdr->hdrLen * 4);
	LOG("|- Type of Service: %u\n", hdr->tos);
	LOG("|- IP Total Length: %u Octets(Size of packet)\n", ntohs(hdr->totalLen));
	LOG("|- Identifier: %u\n", ntohs(hdr->id));
	LOG("|- Don't Fragment: %s\n", STRBOOL(hdr->dontFragment));
	LOG("|- More Fragment: %s\n", STRBOOL(hdr->moreFragment));
	LOG("|- Time to Live: %u\n", hdr->ttl);
	LOG("|- Protocol: %u\n", hdr->proto);
	LOG("|- Checksum: %u\n", ntohs(hdr->checksum));
	LOG("|- Source IP: %s\n", inet_ntoa(src.sin_addr));
	LOG("|- Destination IP: %s\n", inet_ntoa(dest.sin_addr));
#endif
}