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