/* File IPX.C : Internet Packet Exchange Protocol functions */ /* Copyright (C) 1992 Indian Institute of Technology, Bombay Written by V. Srinivas and Vishwas Joglekar, Dept of Computer Science and Engineering. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "ipxwatch.h" #include "sap.h" #include "ipxrip.h" #include "yapcbr.h" /* Copyright (C) 1992 Indian Institute of Technology, Bombay Written by V. Srinivas and Nitin Kaulavkar, Dept of Computer Science and Engineering. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ extern char *novel_pkts[MAX_PKT_TYPES]; extern WORD getword(BYTE *); int proc_ipx_pkt(IPX_PKT *pkt,unsigned char *format,int bcast); /* determine the novell packet type, i.e. whether SAP/NCP/RIP ... by looking at the source and destination socket numbers and return the pkt type */ int proc_ipx_pkt(IPX_PKT *pkt,unsigned char *format,int bcast) { WORD src_sock, dest_sock; int len,pkt_type; BYTE checksum[] = {0xff,0xff}; src_sock = getword(pkt->header.source_node.socket); dest_sock = getword(pkt->header.dest_node.socket); len = getword(pkt->header.length); if(len < 30) return(NONE); pkt_type = pkt->header.packet_type; /* make sure it is really an ipx pkt, as ipx doesn't use checksum, on 802.3 networks the only way we can check is by looking at the checksum field which is set to ff,ff by ipx. Is there any other way ?. In our net we have 802.3 802.2 and ETHERNET_II running on the backbone. Also check the transport control field, if the packet has crossed more than 16 hops than drop it. This also acts as a validation check for ipx packets */ if((memcmp(pkt->header.checksum,checksum,2) != 0) || (pkt->header.transport_control > MAX_HOPS)) return(NONE); /* Determine the pkt type by looking at the source/destination socket numbers and/or packet type field */ /* is it an SPX packet ? */ if(pkt_type == 5){ sprintf(format,"%4s %4u %5.5d -> %5.5d ",novel_pkts[NOVLSPX],len,src_sock,dest_sock); prnt_hex(pkt->data,format+strlen(format),10); return(NOVLSPX); /* Netware SPX pkt */ } if((src_sock == NETCOREP_SOCK) || ( dest_sock == NETCOREP_SOCK)){ sprintf(format,"%4s %4u %5.5d -> %5.5d Req=",novel_pkts[NOVLNCP],len,src_sock,dest_sock); prnt_hex(pkt->data,format+strlen(format),2); sprintf(format+strlen(format),"Seq=%2.2X Conn No=%2.2X Task=%2.2X",pkt->data[2],pkt->data[3], pkt->data[3]); return(NOVLNCP); /* Netware Core Protocol pkt */ } if(((src_sock == SERVADP_SOCK)|| (dest_sock == SERVADP_SOCK)) &&(len < 576)){ sprintf(format,"%4s %4u " ,novel_pkts[NOVLSAP],len+14); proc_sap_pkt((SAP_PKT *)pkt,format+strlen(format),bcast,src_sock,dest_sock); /* upcall to sap */ return(NOVLSAP); /* Service Advertising Protocol pkt */ } if(((src_sock == ROUTEIPX_SOCK) || (dest_sock == ROUTEIPX_SOCK)) && (len <576)){ if(dest_sock == ROUTEIPX_SOCK){ sprintf(format,"%4s %4u " ,novel_pkts[NOVLRIP],len+14); proc_rip_pkt( (RIP_PKT *) pkt,format+strlen(format),bcast); /* upcall to rip */ } else sprintf(format,"%4s %4u %5.5d -> %5.5d",novel_pkts[NOVLRIP],len+14,src_sock,dest_sock); return(NOVLRIP); /* Routing Information Protocol pkt */ } if((src_sock == NETB_SOCK) || (dest_sock == NETB_SOCK)){ sprintf(format,"%4s %4u %5.5d -> %5.5d",novel_pkts[NOVLNB],len+14,src_sock,dest_sock); return(NOVLNB); /* NetBios pkt */ } if((src_sock == DIA_SOCK) || (dest_sock == DIA_SOCK)){ proc_diag_pkt(pkt); /* upcall to diag */ sprintf(format,"%4s %4u %5.5d -> %5.5d",novel_pkts[NOVLDIAG],len+14,src_sock,dest_sock); return(NOVLDIAG); /* Diagnostics pkt */ } if(pkt_type == 0 || pkt_type == 4){ sprintf(format,"%4s %4u %5.5d -> %5.5d",novel_pkts[NOVLIPX],len+14,src_sock,dest_sock); return(NOVLIPX); /* raw ipx pkt ? */ } /* are there any more packet types ? */ return(NONE); /* unknown pkt type */ }