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