ns-allinone-2.35/ns-2.35/emulate/arp.cc
void
ArpAgent::dispatch(int)
{
	double ts;
	sockaddr sa;
	int cc = net_->recv(rcv_buf_, base_size_, sa, ts);
	if (cc < int(base_size_ - sizeof(ether_header))) {
		if (cc == 0)
			return;
                fprintf(stderr,
                    "ArpAgent(%s): recv small pkt (%d) [base sz:%d]: %s\n",
                    name(), cc, base_size_, strerror(errno));
		return;
	}
	ether_arp* ea = (ether_arp*) rcv_buf_;
	int op = ntohs(ea->ea_hdr.ar_op);


	switch (op) {
	case ARPOP_REPLY:
		doreply(ea);
		break;
	case ARPOP_REQUEST:
		doreq(ea);
		break;
	default:
		fprintf(stderr,
		    "ArpAgent(%s): cannot interpret ARP op %d\n",
		    name(), op);
		return;
	}
	return;
}
/*
 * receive pkt from network:
 *	note that net->recv() gives us the pkt starting
 *	just BEYOND the frame header
 */
receive pkt from network:
note that net->recv() gives us the pkt starting
just BEYOND the frame header
receive pkt from network : note that net - > recv () gives us the pkt starting just BEYOND the frame header
void
ArpAgent::dispatch(int)
{
	double ts;
	sockaddr sa;
	int cc = net_->recv(rcv_buf_, base_size_, sa, ts);
	if (cc < int(base_size_ - sizeof(ether_header))) {
		if (cc == 0)
			return;
                fprintf(stderr,
                    "ArpAgent(%s): recv small pkt (%d) [base sz:%d]: %s\n",
                    name(), cc, base_size_, strerror(errno));
		return;
	}
	ether_arp* ea = (ether_arp*) rcv_buf_;
	int op = ntohs(ea->ea_hdr.ar_op);
	switch (op) {
	case ARPOP_REPLY:
		doreply(ea);
		break;
	case ARPOP_REQUEST:
		doreq(ea);
		break;
	default:
		fprintf(stderr,
		    "ArpAgent(%s): cannot interpret ARP op %d\n",
		    name(), op);
		return;
	}
	return;
}
void ArpAgent :: dispatch ( int ) { double ts ; sockaddr sa ; int cc = net_ -> recv ( rcv_buf_ , base_size_ , sa , ts ) ; if ( cc < int ( base_size_ - sizeof ( ether_header ) ) ) { if ( cc == 0 ) return ; fprintf ( stderr , " \n " , name ( ) , cc , base_size_ , strerror ( errno ) ) ; return ; } ether_arp * ea = ( ether_arp * ) rcv_buf_ ; int op = ntohs ( ea -> ea_hdr . ar_op ) ; switch ( op ) { case ARPOP_REPLY : doreply ( ea ) ; break ; case ARPOP_REQUEST : doreq ( ea ) ; break ; default : fprintf ( stderr , " \n " , name ( ) , op ) ; return ; } return ; }
receive pkt from network:
      note that net->recv() gives us the pkt starting
      just BEYOND the frame header
receive pkt from network : note that net - > recv () gives us the pkt starting just BEYOND the frame header