Question
make the code run and explain what you did and what have you changed The code is a demultiplexing code. The goal of this piece
make the code run
and explain what you did and what have you changed
The code is a demultiplexing code. The goal of this piece of code is to analyze incoming packets. It breaks the packets into the type field in order to determine which protocol software will the packet.
#include
#include
#include
#include
Int arp_in(struct netif *,struct ep *);
Int rarp_in(struct netif *,struct ep *);
Int ip_in(struct netif *,struct ep *);
/*-----------------------------------------------------------------------------------------------------------------------------
* ni_in - network interface input function
*------------------------------------------------------------------------------------------------------------------------------
*/
Int
ni_in(struct netif *pni, struct ep *pep, unsigned len)
{
int rv;
pep->ep_ifn = pni - &nif[0]; /*record originating intf # */
pni->ni_ioctwts += len;
If (!memcmp(pni->ni_hwa.ha_addr , pep->ep_dst, EP_ALEN))
pni->ni_iucast++;
Else
pni->ni_iucast++;
Switch (pep->ep_type) {
Case EPT_ARP: rv = arp_in(pni , pep); break;
Case EPT_RARP: rv = rarp_in(pni , pep); break;
Case EPT_IP: rv = ip_in(pni , pep); break;
Default:
pni->ni_iunkproto++;
Freebuf (pep);
rv = OK;
}
Return rv;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started