FreeBSD/sys/netinet/ip_ecn.c
/*
 * modify inner ECN (TOS) field on egress operation (tunnel decapsulation).
 * the caller should drop the packet if the return value is 0.
 */
modify inner ECN (TOS) field on egress operation (tunnel decapsulation).
the caller should drop the packet if the return value is 0.
modify inner ECN ( TOS ) field on egress operation ( tunnel decapsulation ) . the caller should drop the packet if the return value is 0 .
int
ip_ecn_egress(int mode, const u_int8_t *outer, u_int8_t *inner)
{
	if (!outer || !inner)
		panic("NULL pointer passed to ip_ecn_egress");
	switch (mode) {
	case ECN_ALLOWED:
		if ((*outer & IPTOS_ECN_MASK) == IPTOS_ECN_CE) {
			if ((*inner & IPTOS_ECN_MASK) == IPTOS_ECN_NOTECT)
				return (0);
			*inner |= IPTOS_ECN_CE;
		}
		break;
	case ECN_FORBIDDEN:		
		if ((*outer & IPTOS_ECN_MASK) == IPTOS_ECN_CE)
			return (0);
		break;
	case ECN_NOCARE:	
		break;
	}
	return (1);
}
int ip_ecn_egress ( int mode , const u_int8_t * outer , u_int8_t * inner ) { if ( ! outer || ! inner ) panic ( " " ) ; switch ( mode ) { case ECN_ALLOWED : if ( ( * outer & IPTOS_ECN_MASK ) == IPTOS_ECN_CE ) { if ( ( * inner & IPTOS_ECN_MASK ) == IPTOS_ECN_NOTECT ) return ( 0 ) ; * inner |= IPTOS_ECN_CE ; } break ; case ECN_FORBIDDEN : if ( ( * outer & IPTOS_ECN_MASK ) == IPTOS_ECN_CE ) return ( 0 ) ; break ; case ECN_NOCARE : break ; } return ( 1 ) ; }
modify inner ECN (TOS) field on egress operation (tunnel decapsulation).
modify inner ECN ( TOS ) field on egress operation ( tunnel decapsulation ) .
/*
		 * full-functionality: if the outer is CE and the inner is
		 * not-ECT, should drop it.  otherwise, copy CE.
		 */ /* ECN forbidden */ /*
		 * limited-functionality: if the outer is CE, should drop it.
		 * otherwise, leave the inner.
		 */ /* no consideration to ECN */