MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sppp_fr_arp

Function sppp_fr_arp

freebsd/net/if_spppfr.c:403–512  ·  view source on GitHub ↗

* Process the frame relay Inverse ARP request. */

Source from the content-addressed store, hash-verified

401 * Process the frame relay Inverse ARP request.
402 */
403static void sppp_fr_arp (struct sppp *sp, struct arp_req *req,
404 u_short his_hardware_address)
405{
406 STDDCL;
407 struct mbuf *m;
408 struct arp_req *reply;
409 u_char *h;
410 u_short my_hardware_address;
411 u_long his_ip_address, my_ip_address;
412
413 if ((ntohs (req->htype) != ARPHRD_FRELAY ||
414 ntohs (req->htype) != 16) || /* for BayNetworks routers */
415 ntohs (req->ptype) != ETHERTYPE_IP) {
416 if (debug)
417 printf (SPP_FMT "Invalid ARP hardware/protocol type = 0x%x/0x%x\n",
418 SPP_ARGS(ifp),
419 ntohs (req->htype), ntohs (req->ptype));
420 return;
421 }
422 if (req->halen != 2 || req->palen != 4) {
423 if (debug)
424 printf (SPP_FMT "Invalid ARP hardware/protocol address length = %d/%d\n",
425 SPP_ARGS(ifp),
426 req->halen, req->palen);
427 return;
428 }
429 switch (ntohs (req->op)) {
430 default:
431 if (debug)
432 printf (SPP_FMT "Invalid ARP op = 0x%x\n",
433 SPP_ARGS(ifp), ntohs (req->op));
434 return;
435
436 case ARPOP_INVREPLY:
437 /* Ignore. */
438 return;
439
440 case ARPOP_INVREQUEST:
441 my_hardware_address = ntohs (req->htarget);
442 his_ip_address = ntohs (req->psource1) << 16 |
443 ntohs (req->psource2);
444 my_ip_address = ntohs (req->ptarget1) << 16 |
445 ntohs (req->ptarget2);
446 break;
447 }
448 if (debug)
449 printf (SPP_FMT "got ARP request, source=0x%04x/%d.%d.%d.%d, target=0x%04x/%d.%d.%d.%d\n",
450 SPP_ARGS(ifp), ntohs (req->hsource),
451 (unsigned char) (his_ip_address >> 24),
452 (unsigned char) (his_ip_address >> 16),
453 (unsigned char) (his_ip_address >> 8),
454 (unsigned char) his_ip_address,
455 my_hardware_address,
456 (unsigned char) (my_ip_address >> 24),
457 (unsigned char) (my_ip_address >> 16),
458 (unsigned char) (my_ip_address >> 8),
459 (unsigned char) my_ip_address);
460

Callers 1

sppp_fr_inputFunction · 0.85

Calls 3

sppp_get_ip_addrsFunction · 0.85
if_inc_counterFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected