X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/89b3af67bb32e691275bf6fa803d1834b2284115..e2fac8b15b12a7979f72090454d850e612fc5b13:/bsd/netat/ddp.c?ds=sidebyside diff --git a/bsd/netat/ddp.c b/bsd/netat/ddp.c index 8b46b79eb..31467fa6b 100644 --- a/bsd/netat/ddp.c +++ b/bsd/netat/ddp.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * @@ -26,9 +26,6 @@ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ /* - * Copyright (c) 1987, 1988, 1989 Apple Computer, Inc. - * - * * Modified for MP, 1996 by Tuyen Nguyen * Added AURP support, April 8, 1996 by Tuyen Nguyen * Modified, March 17, 1997 by Tuyen Nguyen for MacOSX. @@ -57,13 +54,13 @@ #include #include +#include #include #include #include #include #include #include -#include #include #include #include @@ -72,13 +69,16 @@ #include #include #include +#include +#include + +#include /* globals */ /* Queue of LAP interfaces which have registered themselves with DDP */ struct at_ifQueueHd at_ifQueueHd; -extern at_state_t at_state; extern TAILQ_HEAD(name_registry, _nve_) name_registry; snmpStats_t snmpStats; /* snmp ddp & echo stats */ @@ -90,35 +90,35 @@ extern aarp_amt_array *aarp_table[]; extern at_ifaddr_t at_interfaces[]; /* routing mode special */ -void (*ddp_AURPsendx)(); +void (*ddp_AURPsendx)(void) = NULL; at_ifaddr_t *aurp_ifID = 0; -extern pktsIn,pktsOut; -int pktsDropped,pktsHome; + +int pktsIn = 0; +int pktsOut = 0; +int pktsDropped = 0; +int pktsHome = 0; extern int *atp_pidM; extern int *adsp_pidM; extern struct atpcb *atp_inputQ[]; extern CCB *adsp_inputQ[]; -at_ifaddr_t *forUs(at_ddp_t *); - -void ddp_input(), ddp_notify_nbp(); +static void fillin_pkt_chain(gbuf_t *); +static int ot_ddp_check_socket(unsigned char ,int pid); -extern void routing_needed(); -extern void ddp_brt_sweep(); struct { - void (*func)(); + ddp_handler_func func; } ddp_handler[256]; -void init_ddp_handler() +void init_ddp_handler(void) { bzero(ddp_handler, sizeof(ddp_handler)); } void add_ddp_handler(ddp_socket, input_func) u_char ddp_socket; - void (*input_func)(); + ddp_handler_func input_func; { ddp_handler[ddp_socket].func = input_func; } @@ -390,10 +390,8 @@ void ddp_rem_if(ifID) ifa->ifa_addr = NULL; ifnet_lock_done(ifID->aa_ifp); } - if (ifID->at_dl_tag) { -/* dlil_detach_protocol(ifID->at_dl_tag); */ - ether_detach_at(ifID->aa_ifp); - ifID->at_dl_tag = 0; + if (ifID->at_was_attached == 0 && ifID->aa_ifp != NULL) { + (void)proto_unplumb(PF_APPLETALK, ifID->aa_ifp); } /* un-do processing done in ddp_add_if() */ @@ -426,7 +424,7 @@ void ddp_rem_if(ifID) */ /* *** Do we still need to do this? *** */ -int ot_ddp_check_socket(socket, pid) +static int ot_ddp_check_socket(socket, pid) unsigned char socket; int pid; { @@ -446,12 +444,11 @@ int ot_ddp_check_socket(socket, pid) return(cnt); } -void ddp_notify_nbp(socket, pid, ddptype) - unsigned char socket; - int pid; - unsigned char ddptype; /* not used */ +void ddp_notify_nbp( + unsigned char socket, + int pid, + __unused unsigned char ddptype) { - extern int nve_lock; nve_entry_t *nve_entry, *nve_next; if (at_state.flags & AT_ST_STARTED) { @@ -525,7 +522,7 @@ int ddp_output(mp, src_socket, src_addr_included) { register at_ifaddr_t *ifID = ifID_home, *ifIDTmp = NULL; register at_ddp_t *ddp; - register ddp_brt_t *brt; + register ddp_brt_t *brt = NULL; register at_net_al dst_net; register int len; struct atalk_addr at_dest; @@ -533,7 +530,7 @@ int ddp_output(mp, src_socket, src_addr_included) int loop = 0; int error = 0; int addr_type; - u_char addr_flag; + u_char addr_flag = 0; char *addr = NULL; register gbuf_t *m; @@ -785,7 +782,8 @@ int ddp_output(mp, src_socket, src_addr_included) { /* begin block */ struct etalk_addr dest_addr; struct atalk_addr dest_at_addr; - int loop = TRUE; /* flag to aarp to loopback (default) */ + + loop = TRUE; /* flag to aarp to loopback (default) */ m = *mp; @@ -858,7 +856,7 @@ int ddp_output(mp, src_socket, src_addr_included) aarp_send_data(m,ifID, &dest_at_addr, loop); break; case ET_ADDR : - pat_output(ifID, m, &dest_addr, 0); + pat_output(ifID, m, (unsigned char *)&dest_addr, 0); break; } } /* end block */ @@ -941,7 +939,7 @@ void ddp_input(mp, ifID) len = DDPLEN_VALUE(ddp); if (msgsize != len) { - if ((unsigned) msgsize > len) { + if (msgsize > len) { if (len < DDP_X_HDR_SIZE) { dPrintf(D_M_DDP, D_L_ERROR, ("Length problems, ddp length %d, buffer length %d", @@ -1011,7 +1009,7 @@ void ddp_input(mp, ifID) for packets of this type on a raw DDP socket *** */ if (ddp_handler[socket].func) { dPrintf(D_M_DDP,D_L_INPUT, - ("ddp_input: skt %d hdnlr:0x%x\n", + ("ddp_input: skt %u hdnlr:0x%p\n", (u_int) socket, ddp_handler[socket].func)); pktsHome++; snmpStats.dd_inLocal++; @@ -1138,7 +1136,7 @@ int ddp_router_output(mp, ifID, addr_type, router_net, router_node, enet_addr) { register at_ddp_t *ddp; struct atalk_addr at_dest; - int addr_flag; + int addr_flag = 0; char *addr = NULL; register gbuf_t *m; @@ -1298,7 +1296,7 @@ int ddp_router_output(mp, ifID, addr_type, router_net, router_node, enet_addr) aarp_send_data(m,ifID,&dest_at_addr, loop); break; case ET_ADDR : - pat_output(ifID, m, &dest_addr, 0); + pat_output(ifID, m, (unsigned char *)&dest_addr, 0); break; } } /* end block */ @@ -1308,12 +1306,13 @@ int ddp_router_output(mp, ifID, addr_type, router_net, router_node, enet_addr) /*****************************************/ +#ifdef AURP_SUPPORT + void rt_delete(NetStop, NetStart) unsigned short NetStop; unsigned short NetStart; { RT_entry *found; - int s; if ((found = rt_bdelete(NetStop, NetStart)) != 0) { bzero(found, sizeof(RT_entry)); @@ -1322,14 +1321,11 @@ void rt_delete(NetStop, NetStart) } } -#ifdef AURP_SUPPORT int ddp_AURPfuncx(code, param, node) int code; void *param; unsigned char node; { - extern void rtmp_timeout(); - extern void rtmp_send_port(); at_ifaddr_t *ifID; int k;