1/* 2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. The rights granted to you under the License 10 * may not be used to create, or enable the creation or redistribution of, 11 * unlawful or unlicensed copies of an Apple operating system, or to 12 * circumvent, violate, or enable the circumvention or violation of, any 13 * terms of an Apple operating system software license agreement. 14 * 15 * Please obtain a copy of the License at 16 * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 * 18 * The Original Code and all software distributed under the License are 19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 * Please see the License for the specific language governing rights and 24 * limitations under the License. 25 * 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 */ 28/* 29 * Copyright (c) 1997-1998 Apple Computer, Inc. 30 * All Rights Reserved. 31 */ 32 33/* 34 * Modified, March 17, 1997 by Tuyen Nguyen for MacOSX. 35 */ 36#include <sys/errno.h> 37#include <sys/types.h> 38#include <sys/param.h> 39#include <machine/spl.h> 40#include <sys/systm.h> 41#include <sys/kernel.h> 42#include <sys/proc.h> 43#include <sys/filedesc.h> 44#include <sys/fcntl.h> 45#include <sys/mbuf.h> 46#include <sys/socket.h> 47#include <sys/socketvar.h> 48 49#include <net/if.h> 50 51#include <netat/sysglue.h> 52#include <netat/appletalk.h> 53#include <netat/ep.h> 54#include <netat/ddp.h> 55#include <netat/debug.h> 56#include <netat/at_snmp.h> 57#include <netat/at_pcb.h> 58#include <netat/at_var.h> 59 60extern snmpStats_t snmpStats; 61 62/****************************************************************/ 63/* */ 64/* */ 65/* Echo Protocol */ 66/* */ 67/* */ 68/****************************************************************/ 69 70void ep_input (mp, ifID) 71 gbuf_t *mp; 72 register at_ifaddr_t *ifID; 73{ 74 register at_ddp_t *ddp; 75 76 snmpStats.ec_echoReq++; 77 ddp = (at_ddp_t *)gbuf_rptr(mp); 78 79 /* ep packets that have a source broadcast can cause 80 * possible broadcast storms, prevent that here 81 */ 82 if ( NET_VALUE(ddp->src_net) == 0 || ddp->src_node == 255) { 83 gbuf_freem(mp); 84 return; 85 } 86 87 /* 88 * Check if this AEP message is for us or need to be forwarded 89 */ 90 if (!ROUTING_MODE || 91 ((ifID->ifThisNode.s_net == NET_VALUE(ddp->dst_net)) 92 && (ifID->ifThisNode.s_node == ddp->dst_node))) { 93 94 dPrintf(D_M_AEP, D_L_INFO, ("aep_input: received for this port from %d:%d\n", 95 NET_VALUE(ddp->src_net), ddp->src_node)); 96 97 if (ddp->type == DDP_ECHO && 98 ddp->data[0] == EP_REQUEST) { 99 ddp->data[0] = EP_REPLY; 100 NET_NET(ddp->dst_net, ddp->src_net); 101 ddp->dst_node = ddp->src_node; 102 ddp->dst_socket = ddp->src_socket; 103 /* send the packet out.... */ 104 snmpStats.ec_echoReply++; 105 (void)ddp_output(&mp, (at_socket)EP_SOCKET, FALSE); 106 } else 107 gbuf_freem(mp); 108 } 109 else { 110 dPrintf(D_M_AEP, D_L_INFO, 111 ("aep_input: calling routing needed from %d:%d to %d:%d\n", 112 NET_VALUE(ddp->src_net), ddp->src_node, NET_VALUE(ddp->dst_net), 113 ddp->dst_node)); 114 routing_needed(mp, ifID, TRUE); 115 } 116 117 return; 118} 119