ns-allinone-2.35/olsr/OLSR.cc
void
OLSR::recv(Packet* p, Handler* h) {
	struct hdr_cmn* ch	= HDR_CMN(p);
	struct hdr_ip* ih	= HDR_IP(p);
	
	if (ih->saddr() == ra_addr()) {
		// If there exists a loop, must drop the packet
		if (ch->num_forwards() > 0) {
			drop(p, DROP_RTR_ROUTE_LOOP);
			return;
		}
		// else if this is a packet I am originating, must add IP header
		else if (ch->num_forwards() == 0)
			ch->size() += IP_HDR_LEN;
	}
	
	// If it is an OLSR packet, must process it
	if (ch->ptype() == PT_OLSR)
		recv_olsr(p);
	// Otherwise, must forward the packet (unless TTL has reached zero)
	else {
		ih->ttl_--;
		if (ih->ttl_ == 0) {
			drop(p, DROP_RTR_TTL);
			return;
		}
		forward_data(p);
	}
}
///
/// \brief	This function is called whenever a packet is received. It identifies
///		the type of the received packet and process it accordingly.
///
/// If it is an %OLSR packet then it is processed. In other case, if it is a data packet
/// then it is forwarded.
///
/// \param	p the received packet.
/// \param	h a handler (not used).
///
\brief This function is called whenever a packet is received. It identifies
the type of the received packet and process it accordingly.

If it is an %OLSR packet then it is processed. In other case, if it is a data packet
then it is forwarded.

\param p the received packet.
\param h a handler (not used).
\ brief This function is called whenever a packet is received . It identifies the type of the received packet and process it accordingly . If it is an %OLSR packet then it is processed . In other case if it is a data packet then it is forwarded . \ param p the received packet . \ param h a handler ( not used ) .
void
OLSR::recv(Packet* p, Handler* h) {
	struct hdr_cmn* ch	= HDR_CMN(p);
	struct hdr_ip* ih	= HDR_IP(p);
	if (ih->saddr() == ra_addr()) {
		if (ch->num_forwards() > 0) {
			drop(p, DROP_RTR_ROUTE_LOOP);
			return;
		}
		else if (ch->num_forwards() == 0)
			ch->size() += IP_HDR_LEN;
	}
	if (ch->ptype() == PT_OLSR)
		recv_olsr(p);
	else {
		ih->ttl_--;
		if (ih->ttl_ == 0) {
			drop(p, DROP_RTR_TTL);
			return;
		}
		forward_data(p);
	}
}
void OLSR :: recv ( Packet * p , Handler * h ) { struct hdr_cmn * ch = HDR_CMN ( p ) ; struct hdr_ip * ih = HDR_IP ( p ) ; if ( ih -> saddr ( ) == ra_addr ( ) ) { if ( ch -> num_forwards ( ) > 0 ) { drop ( p , DROP_RTR_ROUTE_LOOP ) ; return ; } else if ( ch -> num_forwards ( ) == 0 ) ch -> size ( ) += IP_HDR_LEN ; } if ( ch -> ptype ( ) == PT_OLSR ) recv_olsr ( p ) ; else { ih -> ttl_ -- ; if ( ih -> ttl_ == 0 ) { drop ( p , DROP_RTR_TTL ) ; return ; } forward_data ( p ) ; } }
\brief This function is called whenever a packet is received.
\ brief This function is called whenever a packet is received .
// If there exists a loop, must drop the packet // else if this is a packet I am originating, must add IP header // If it is an OLSR packet, must process it // Otherwise, must forward the packet (unless TTL has reached zero)