├── HOWTO-MicroVAX-II.md ├── Makefile ├── README ├── README.md ├── common ├── Makefile ├── VERSION ├── cmp.c ├── cmp.h ├── common.h ├── device.c ├── device.h ├── dl.c ├── dl.h ├── file.c ├── file.h ├── get.c ├── get.h ├── loop-bsd.c ├── loop-linux2.c ├── mopdef.c ├── mopdef.h ├── nma.c ├── nma.h ├── nmadef.h ├── os.h ├── pf-linux2.c ├── pf.c ├── pf.h ├── print.c ├── print.h ├── put.c ├── put.h ├── rc.c └── rc.h ├── mopa.out ├── Makefile ├── mopa.out.1 └── mopa.out.c ├── mopchk ├── Makefile ├── mopchk.1 └── mopchk.c ├── mopd ├── Makefile ├── TODO ├── mopd.8 ├── mopd.c ├── process.c └── process.h ├── mopprobe ├── Makefile ├── mopprobe.1 └── mopprobe.c └── moptrace ├── Makefile ├── moptrace.1 └── moptrace.c /HOWTO-MicroVAX-II.md: -------------------------------------------------------------------------------- 1 | How to netboot a MicroVAX II from a Linux boot server 2 | ===================================================== 3 | 4 | 5 | October, 2012. 6 | 7 | The NetBSD distribution used was 1.4.1. 8 | 9 | 10 | ### MicroVAX II configuration 11 | 12 | 7606 AF KA630 MicroVAX II CPU (incl 1MB) 13 | 7609 AH MS630 8MB parity RAM 14 | 9047 grant continuity 15 | 7516YM DELQA Ethernet (MAC 08002B13F87D) 16 | 3104 DHV11 17 | 7164 \ KDA50 1/2 18 | 7165 / KDA50 2/2 19 | 7555 RQDX3 20 | 7546 TUK50 21 | 22 | 23 | ### My network 24 | 25 | For reference, I have used these addresses on my LAN. 26 | 27 | 10.0.0.3 pc # linux server 28 | 10.0.0.5 gateway 29 | 10.0.0.63 mvii # the client MicroVAX II 30 | 31 | 32 | ### Enable multicast in linux kernel 33 | 34 | # grep MULTIC /usr/src/linux/.config 35 | CONFIG_IP_MULTICAST=y 36 | 37 | 38 | ### Enable multicast on Ethernet 39 | 40 | # ifconfig eth0 allmulti 41 | # ifconfig 42 | eth0 Link encap:Ethernet HWaddr 00:30:1b:b5:5d:49 43 | inet addr:10.0.0.3 Bcast:10.0.0.255 Mask:255.255.255.0 44 | UP BROADCAST RUNNING ALLMULTI MULTICAST MTU:1500 Metric:1 45 | RX packets:1459 errors:0 dropped:0 overruns:0 frame:0 46 | TX packets:1149 errors:0 dropped:0 overruns:0 carrier:0 47 | collisions:0 txqueuelen:1000 48 | RX bytes:136386 (133.1 KiB) TX bytes:157410 (153.7 KiB) 49 | Interrupt:19 50 | 51 | 52 | ### Check out and build mopd 53 | 54 | From [this repository](https://github.com/qu1j0t3/mopd/). 55 | 56 | 57 | ### tftpd must be running 58 | 59 | # emerge tftp-hpa 60 | # cat /etc/conf.d/in.tftpd 61 | # Path to server files from 62 | # Depending on your application you may have to change this. 63 | # This is commented out to force you to look at the file! 64 | #INTFTPD_PATH="/var/tftp/" 65 | INTFTPD_PATH="/tftpboot/mop" 66 | #INTFTPD_PATH="/tftproot/" 67 | 68 | # For more options, see in.tftpd(8) 69 | # -R 4096:32767 solves problems with ARC firmware, and obsoletes 70 | # the /proc/sys/net/ipv4/ip_local_port_range hack. 71 | # -s causes $INTFTPD_PATH to be the root of the TFTP tree. 72 | # -l is passed by the init script in addition to these options. 73 | INTFTPD_OPTS="-l -R 4096:32767 -s ${INTFTPD_PATH}" 74 | 75 | Note that these must not be symlinks (or tftpd won't serve them): 76 | 77 | # mkdir -p /tftpboot/mop/ 78 | # cd /tftpboot/mop/ 79 | # cp ~toby/NetBSD-1.4.1/vax/installation/netboot/boot.mop MOPBOOT.SYS 80 | # cp ~toby/NetBSD-1.4.1/vax/installation/netboot/boot.mop 08002b13f87d.SYS 81 | 82 | # ls -lR /tftpboot/ 83 | /tftpboot/: 84 | total 0 85 | drwxr-xr-x 2 root root 112 Oct 5 21:41 mop 86 | 87 | /tftpboot/mop: 88 | total 144 89 | -rw-r--r-- 2 root root 72192 Oct 5 21:40 08002b13f87d.SYS 90 | -rw-r--r-- 2 root root 72192 Oct 5 21:40 MOPBOOT.SYS 91 | 92 | # /etc/init.d/in.tftpd start 93 | 94 | 95 | ### nfs server must be running 96 | 97 | Follow the diskless setup instructions here: 98 | http://www.netbsd.org/docs/network/netboot/intro.vax.html 99 | 100 | # cd /export/client/root 101 | # tar --numeric-owner -xpzf ~toby/NetBSD-1.4.1/vax/binary/sets/kern.tgz 102 | # mknod /export/client/root/dev/console c 0 0 103 | 104 | # cat /etc/exports 105 | /export/client/root mvii(rw,no_root_squash,no_subtree_check) 106 | /export/client/swap mvii(rw,no_root_squash,no_subtree_check) 107 | /export/client/usr mvii(rw,root_squash,no_subtree_check) 108 | /export/client/home mvii(rw,root_squash,no_subtree_check) 109 | 110 | # cat /export/client/root/etc/fstab 111 | 10.0.0.3:/export/client/swap none swap sw,nfsmntpt=/swap 112 | 10.0.0.3:/export/client/root / nfs rw 0 0 113 | 10.0.0.3:/export/client/usr /usr nfs rw 0 0 114 | 10.0.0.3:/export/client/home /home nfs rw 0 0 115 | 116 | # diff /export/client/root/etc/rc.conf.orig /export/client/root/etc/rc.conf 117 | 12c12 118 | < rc_configured=NO 119 | --- 120 | > rc_configured=YES 121 | 20c20 122 | < hostname="" # if blank, use /etc/myname 123 | --- 124 | > hostname="mvii" # if blank, use /etc/myname 125 | 24c24,25 126 | < defaultroute="" # if blank, use /etc/mygate 127 | --- 128 | > ifconfig_qe0="inet 10.0.0.63 netmask 255.255.255.0" 129 | > defaultroute="10.0.0.5" # if blank, use /etc/mygate 130 | 52c53 131 | < auto_ifconfig=YES # config all avail. interfaces 132 | --- 133 | > auto_ifconfig=NO # config all avail. interfaces 134 | 97c98 135 | < nfs_client=NO # enable client daemons 136 | --- 137 | > nfs_client=YES # enable client daemons 138 | 118a120 139 | > 140 | 141 | Filesystems after installing some sets: 142 | 143 | # du -sh /export/client/* 144 | 41M /export/client/home 145 | 9.7M /export/client/root 146 | 17M /export/client/swap 147 | 0 /export/client/sys 148 | 52M /export/client/usr 149 | 152K /export/client/var 150 | 151 | 152 | ### mopd must be running 153 | 154 | Successful boot log shown. 155 | 156 | # mopd/mopd -d eth0 157 | mopd: not running as daemon, -d given. 158 | MOP DL 8:0:2b:13:f8:7d > ab:0:0:1:0:0 len 11 code 08 RPR 159 | MOP DL 0:30:1b:b5:5d:49 > 8:0:2b:13:f8:7d len 1 code 03 ASV 160 | MOP DL 8:0:2b:13:f8:7d > 0:30:1b:b5:5d:49 len 11 code 08 RPR 161 | Native Image (VAX) 162 | Header Block Count: 1 163 | Image Size: 00011800 164 | Load Address: 00000000 165 | Transfer Address: 00000000 166 | MOP DL 0:30:1b:b5:5d:49 > 8:0:2b:13:f8:7d len 1006 code 02 MLD 167 | MOP DL 8:0:2b:13:f8:7d > 0:30:1b:b5:5d:49 len 3 code 0a RML 168 | ... 169 | MOP DL 0:30:1b:b5:5d:49 > 8:0:2b:13:f8:7d len 686 code 02 MLD 170 | MOP DL 8:0:2b:13:f8:7d > 0:30:1b:b5:5d:49 len 3 code 0a RML 171 | MOP DL 0:30:1b:b5:5d:49 > 8:0:2b:13:f8:7d len 32 code 14 PLT 172 | MOP DL 8:0:2b:13:f8:7d > 0:30:1b:b5:5d:49 len 3 code 0a RML 173 | 174 | And the following is logged in syslog: 175 | 176 | Oct 6 20:25:53 localhost mopd[8125]: 8:0:2b:13:f8:7d (1) Do you have 08002b13f87d? (Yes) 177 | Oct 6 20:25:53 localhost mopd[8125]: 8:0:2b:13:f8:7d Send me 08002b13f87d 178 | Oct 6 20:25:53 localhost mopd[8125]: hostname: [ipc] len: 3 179 | Oct 6 20:25:53 localhost mopd[8125]: 8:0:2b:13:f8:7d Load completed 180 | 181 | 182 | ### bootpd must be running 183 | 184 | # emerge -av netkit-bootpd 185 | 186 | (Note, /tftpboot/boot.netbsd doesn't actually exist, and isn't part of 187 | NetBSD. This setting seems to be ignored?) 188 | 189 | # cat /etc/bootptab 190 | mvii:\ 191 | :ht=ether:\ 192 | :ha=08002B13F87D:\ 193 | :ip=10.0.0.63:\ 194 | :bf=/tftpboot/boot.netbsd:\ 195 | :rp=/export/client/root/: 196 | 197 | I was not able to get this to work via xinetd, so I started the daemon 198 | standalone, manually. 199 | 200 | Successful boot log shown. 201 | 202 | # bootpd -d 9 -s 203 | bootpd: info(6): bootptab mtime: Sat Oct 6 19:31:29 2012 204 | bootpd: info(6): reading "/etc/bootptab" 205 | bootpd: info(6): read 1 entries (1 hosts) from "/etc/bootptab" 206 | bootpd: info(6): recvd pkt from IP addr 0.0.0.0 207 | bootpd: info(6): bootptab mtime: Sat Oct 6 19:31:29 2012 208 | bootpd: info(6): request from Ethernet address 08:00:2B:13:F8:7D 209 | bootpd: info(6): found 10.0.0.63 (mvii) 210 | bootpd: info(6): bootfile="/tftpboot/boot.netbsd" 211 | bootpd: info(6): vendor magic field is 99.130.83.99 212 | bootpd: info(6): request message length=548 213 | bootpd: info(6): extended reply, length=548, options=312 214 | bootpd: info(6): sending reply (with RFC1048 options) 215 | bootpd: info(6): setarp 10.0.0.63 - 08:00:2B:13:F8:7D 216 | ..pause.. 217 | bootpd: info(6): recvd pkt from IP addr 0.0.0.0 218 | bootpd: info(6): bootptab mtime: Sat Oct 6 19:31:29 2012 219 | bootpd: info(6): request from Ethernet address 08:00:2B:13:F8:7D 220 | bootpd: info(6): found 10.0.0.63 (mvii) 221 | bootpd: info(6): bootfile="/tftpboot/boot.netbsd" 222 | bootpd: info(6): vendor magic field is 99.130.83.99 223 | bootpd: info(6): request message length=548 224 | bootpd: info(6): extended reply, length=548, options=312 225 | bootpd: info(6): sending reply (with RFC1048 options) 226 | bootpd: info(6): setarp 10.0.0.63 - 08:00:2B:13:F8:7D 227 | 228 | 229 | ### Serial console on MicroVAX II 230 | 231 | KA630-A.V1.3 232 | 233 | Performing normal system tests. 234 | 235 | 7..6..5..4..3.. 236 | 237 | Tests completed. 238 | 239 | 240 | >>> b xqa0 241 | 242 | 2..1..0.. 243 | 244 | 245 | >> NetBSD/vax boot [Aug 13 1999 20:18:28] << 246 | >> Press any key to abort autoboot 247 | > boot netbsd 248 | Trying BOOTP 249 | Using IP address: 10.0.0.63 250 | myip: (10.0.0.63), mask: 255.0.0.0 251 | root addr=10.0.0.3 path=/export/client/root/ 252 | 841724+43856+159808+[64440+72748] total=0x120b78 253 | Copyright (c) 1996, 1997, 1998, 1999 254 | The NetBSD Foundation, Inc. All rights reserved. 255 | Copyright (c) 1982, 1986, 1989, 1991, 1993 256 | The Regents of the University of California. All rights reserved. 257 | 258 | NetBSD 1.4.1 (GENERIC) #13: Fri Aug 13 05:35:08 PDT 1999 259 | root@futplex:/usr/src/sys/arch/vax/compile/GENERIC 260 | 261 | MicroVAX II 262 | realmem = 9428992 263 | avail mem = 6565888 264 | Using 115 buffers containing 471040 bytes of memory. 265 | mainbus0 (root) 266 | cpu0 at mainbus0: KA630 267 | uba0 at mainbus0: Q22 268 | mtc0 at uba0 csr 174500 vec 774 ipl 17 269 | mscpbus0 at mtc0: version 4 model 3 270 | mscpbus0: DMA burst size set to 4 271 | mt0 at mscpbus0 drive 0: TK50 272 | uda0 at uba0 csr 172150 vec 770 ipl 17 273 | mscpbus1 at uda0: version 4 model 3 274 | mscpbus1: DMA burst size set to 4 275 | uda1 at uba0 csr 160334 vec 764 ipl 17 276 | mscpbus2 at uda1: version 8 model 13 277 | mscpbus2: DMA burst size set to 4 278 | qe0 at uba0 csr 174440 vec 760 ipl 17 279 | qe0: delqa, hardware address 08:00:2b:13:f8:7d 280 | boot device: qe0 281 | nfs_boot: trying DHCP/BOOTP 282 | nfs_boot: BOOTP server: 0xa000003 283 | nfs_boot: my_addr=0xa00003f 284 | nfs_boot: my_mask=0xff000000 285 | root on deepthought:/export/client/root/ 286 | Clock has lost 15609 day(s) - CHECK AND RESET THE DATE. 287 | root file system type: nfs 288 | Automatic boot in progress: starting file system checks. 289 | setting tty flags 290 | starting network 291 | hostname: mvii 292 | configuring network interfaces:. 293 | add net default: gateway 10.0.0.5 294 | swapctl: adding 10.0.0.3:/export/client/swap as swap device at priority 0 295 | starting system logger 296 | checking for core dump... 297 | savecore: no core dump (no dumpdev) 298 | starting rpc daemons: portmap. 299 | starting nfs daemons: nfsiod. 300 | creating runtime link editor directory cache. 301 | ldconfig: /usr/pkg/lib: No such file or directory 302 | ldconfig: /usr/X11R6/lib: No such file or directory 303 | setting securelevel: kern.securelevel: 0 -> 1 304 | checking quotas: done. 305 | building databases... 306 | clearing /tmp 307 | updating motd. 308 | standard daemons: update cron. 309 | starting network daemons: inetd. 310 | starting local daemons:. 311 | Sat Jan 10 12:19:41 PST 1970 312 | 313 | NetBSD/vax (mvii) (console) 314 | 315 | login: 316 | 317 | 318 | ### Troubleshooting 319 | 320 | $ telnet mvii 321 | Trying 10.0.0.63... 322 | Connected to mvii. 323 | Escape character is '^]'. 324 | telnetd: All network ports in use. 325 | Connection closed by foreign host. 326 | 327 | This occurs if you did not run `MAKEDEV all` earlier, per instructions: 328 | http://www.netbsd.org/docs/network/netboot/files.html 329 | 330 | Fix: 331 | 332 | mvii# cd /dev 333 | mvii# ./MAKEDEV pty0 334 | or 335 | mvii# ./MAKEDEV all 336 | 337 | ### Other information 338 | 339 | * http://lakesdev.blogspot.co.uk/2009/04/netbsd-bbs-and-vaxen.html 340 | * NetBSD installation: http://mirror.planetunix.net/pub/NetBSD/NetBSD-archive/NetBSD-1.4.1/vax/INSTALL.html -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | # uncomment this to send the correct hostname to the client 3 | # otherwise 'DEFAULT_HOSTNAME' will be sent 4 | # REAL_HOSTNAME = "-DSEND_REAL_HOSTNAME" 5 | REAL_HOSTNAME ="" 6 | DEFAULT_HOSTNAME="-DDEFAULT_HOSTNAME=\\\"ipc\\\"" 7 | 8 | # this is the path mopd will look for files in 9 | MOP_PATH="-DMOP_FILE_PATH=\\\"/tftpboot/mop\\\"" 10 | 11 | # compiling on Alpha Linux 2.2.17 i needed the following: 12 | # AOUT_SUPPORT="-DNOAOUT" 13 | AOUT_SUPPORT="" 14 | 15 | CFLAGS="-g ${AOUT_SUPPORT} ${MOP_PATH} ${DEFAULT_HOSTNAME} ${REAL_HOSTNAME}" 16 | 17 | #make file to build linux-mopd 18 | SUBDIRS=common mopd mopchk mopprobe moptrace 19 | 20 | all: 21 | for dir in ${SUBDIRS}; \ 22 | do \ 23 | echo making $$dir; \ 24 | (cd $$dir; make CFLAGS=$(CFLAGS) ) ; \ 25 | done 26 | 27 | 28 | clean: 29 | for dir in ${SUBDIRS} ; \ 30 | do \ 31 | (cd $$dir ; make clean); \ 32 | done 33 | 34 | 35 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | mopd-linux-20000808 2 | 3 | This is the Linux version of Mats Jansens' Mopd. 4 | 5 | The sources here are taken from the NetBSD version of mopd 2.5.3/4 6 | in CVS, plus some bits from the OpenBSD port, and the security 7 | fixes reported on BUGTRAQ on 08 Aug 2000. 8 | 9 | I had to rewrite the Makefiles, and hack things about a bit to compile 10 | under Linux, So if this version doesnt work for you, send email to the 11 | Linux/VAX list detailing the problem. 12 | 13 | The mopa.out program does not work. The a.out structures have different 14 | names under NetBSD and Linux (see /usr/include/a.out.h), and so the 15 | code needs re-writing. 16 | 17 | atp@pergamentum.com 8/Aug/2000 18 | 19 | Patches from John Nall added for Alpha/Linux 20 | 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | mopd 2 | ==== 3 | 4 | mopd-linux-20000808 5 | 6 | This is the Linux version of Mats Jansens' Mopd. 7 | 8 | The sources here are taken from the NetBSD version of mopd 2.5.3/4 9 | in CVS, plus some bits from the OpenBSD port, and the security 10 | fixes reported on BUGTRAQ on 08 Aug 2000. 11 | 12 | I had to rewrite the Makefiles, and hack things about a bit to compile 13 | under Linux, So if this version doesnt work for you, send email to the 14 | Linux/VAX list detailing the problem. 15 | 16 | The mopa.out program does not work. The a.out structures have different 17 | names under NetBSD and Linux (see /usr/include/a.out.h), and so the 18 | code needs re-writing. 19 | 20 | atp@pergamentum.com 8/Aug/2000 21 | 22 | Patches from John Nall added for Alpha/Linux 23 | 24 | 25 | 26 | 27 | Cloned from http://linux-vax.sourceforge.net/download/mopd-linux.tar.gz 28 | 29 | Version at http://www.stacken.kth.se/~moj/mopd.html is currently inaccessible. 30 | -------------------------------------------------------------------------------- /common/Makefile: -------------------------------------------------------------------------------- 1 | #simple make file for linux 2 | 3 | 4 | OBJS=cmp.o dl.o get.o mopdef.o pf-linux2.o put.o device.o file.o loop-linux2.o nma.o print.o rc.o 5 | 6 | libcommon.a: ${OBJS} 7 | ar -rs libcommon.a ${OBJS} 8 | 9 | .c.o: .o 10 | cc -c $(CFLAGS) $< 11 | 12 | clean: 13 | rm -f *.o *.a *~ 14 | 15 | -------------------------------------------------------------------------------- /common/VERSION: -------------------------------------------------------------------------------- 1 | 2.5.3 2 | -------------------------------------------------------------------------------- /common/cmp.c: -------------------------------------------------------------------------------- 1 | /* $NetBSD: cmp.c,v 1.2 1997/03/25 03:07:02 thorpej Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1993-95 Mats O Jansson. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by Mats O Jansson. 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | #ifndef lint 34 | static char rcsid[]="$NetBSD: cmp.c,v 1.2 1997/03/25 03:07:02 thorpej Exp $"; 35 | #endif 36 | 37 | #include "os.h" 38 | #include "cmp.h" 39 | 40 | int 41 | mopCmpEAddr(addr1, addr2) 42 | u_char *addr1, *addr2; 43 | { 44 | return(memcmp((char *)addr1, (char *)addr2, 6)); 45 | } 46 | -------------------------------------------------------------------------------- /common/cmp.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: cmp.h,v 1.2 1997/03/25 03:07:04 thorpej Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1993-95 Mats O Jansson. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by Mats O Jansson. 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | * $NetBSD: cmp.h,v 1.2 1997/03/25 03:07:04 thorpej Exp $ 32 | * 33 | */ 34 | 35 | #ifndef _CMP_H_ 36 | #define _CMP_H_ 37 | 38 | __BEGIN_DECLS 39 | int mopCmpEAddr __P((u_char *, u_char *)); 40 | __END_DECLS 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /common/common.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: common.h,v 1.3 1997/10/16 23:24:26 lukem Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1993-95 Mats O Jansson. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by Mats O Jansson. 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | * $NetBSD: common.h,v 1.3 1997/10/16 23:24:26 lukem Exp $ 32 | * 33 | */ 34 | 35 | #ifndef _COMMON_H_ 36 | #define _COMMON_H_ 37 | 38 | #define MAXDL 16 /* maximum number concurrent load */ 39 | #define IFNAME_SIZE 32 /* maximum size if interface name */ 40 | #define BUFSIZE 1600 /* main receive buffer size */ 41 | #define HDRSIZ 22 /* room for 803.2 header */ 42 | 43 | #ifndef DEFAULT_HOSTNAME 44 | #define DEFAULT_HOSTNAME "ipc" 45 | #endif 46 | 47 | #ifndef MOP_FILE_PATH 48 | #define MOP_FILE_PATH "/tftpboot/mop" 49 | #endif 50 | 51 | #define DEBUG_ONELINE 1 52 | #define DEBUG_HEADER 2 53 | #define DEBUG_INFO 3 54 | 55 | /* 56 | * structure per interface 57 | * 58 | */ 59 | 60 | struct if_info { 61 | int fd; /* File Descriptor */ 62 | int trans; /* Transport type Ethernet/802.3 */ 63 | u_char eaddr[6]; /* Ethernet addr of this interface */ 64 | char if_name[IFNAME_SIZE]; /* Interface Name */ 65 | int (*iopen) __P((char *, int, u_short, int)); 66 | /* Interface Open Routine */ 67 | int (*write) __P((int, u_char *, int, int)); 68 | /* Interface Write Routine */ 69 | void (*read) __P((void)); /* Interface Read Routine */ 70 | struct if_info *next; /* Next Interface */ 71 | }; 72 | 73 | #define DL_STATUS_FREE 0 74 | #define DL_STATUS_READ_IMGHDR 1 75 | #define DL_STATUS_SENT_MLD 2 76 | #define DL_STATUS_SENT_PLT 3 77 | 78 | struct dllist { 79 | u_char status; /* Status byte */ 80 | struct if_info *ii; /* interface pointer */ 81 | u_char eaddr[6]; /* targets ethernet addres */ 82 | int ldfd; /* filedescriptor for loadfile */ 83 | u_short dl_bsz; /* Data Link Buffer Size */ 84 | int timeout; /* Timeout counter */ 85 | u_char count; /* Packet Counter */ 86 | u_int32_t loadaddr; /* Load Address */ 87 | u_int32_t xferaddr; /* Transfer Address */ 88 | u_int32_t nloadaddr; /* Next Load Address */ 89 | off_t lseek; /* Seek before last read */ 90 | int aout; /* Is it an a.out file */ 91 | u_int32_t a_text; /* Size of text segment */ 92 | u_int32_t a_text_fill; /* Size of text segment fill */ 93 | u_int32_t a_data; /* Size of data segment */ 94 | u_int32_t a_data_fill; /* Size of data segment fill */ 95 | u_int32_t a_bss; /* Size of bss segment */ 96 | u_int32_t a_bss_fill; /* Size of bss segment fill */ 97 | off_t a_lseek; /* Keep track of pos in newfile */ 98 | }; 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /common/device.c: -------------------------------------------------------------------------------- 1 | /* $NetBSD: device.c,v 1.2 1997/03/25 03:07:06 thorpej Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1993-95 Mats O Jansson. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by Mats O Jansson. 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | #ifndef lint 34 | static char rcsid[]="$NetBSD: device.c,v 1.2 1997/03/25 03:07:06 thorpej Exp $"; 35 | #endif 36 | 37 | #include "os.h" 38 | #include "common.h" 39 | #include "device.h" 40 | #include "mopdef.h" 41 | #include "pf.h" 42 | 43 | struct if_info *iflist; /* Interface List */ 44 | 45 | void deviceOpen __P((char *, u_short, int)); 46 | 47 | /* 48 | * Return ethernet adress for interface 49 | */ 50 | 51 | void 52 | deviceEthAddr(ifname, eaddr) 53 | char *ifname; 54 | u_char *eaddr; 55 | { 56 | char inbuf[8192]; 57 | struct ifconf ifc; 58 | struct ifreq *ifr; 59 | struct sockaddr_dl *sdl; 60 | int fd; 61 | int i, len; 62 | 63 | #ifdef DEV_NEW_CONF 64 | /* We cannot use SIOCGIFADDR on the BPF descriptor. 65 | We must instead get all the interfaces with SIOCGIFCONF 66 | and find the right one. */ 67 | 68 | /* Use datagram socket to get Ethernet address. */ 69 | if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { 70 | syslog(LOG_ERR, "deviceEthAddr: socket: %m"); 71 | exit(1); 72 | } 73 | 74 | ifc.ifc_len = sizeof(inbuf); 75 | ifc.ifc_buf = inbuf; 76 | if (ioctl(fd, SIOCGIFCONF, (caddr_t)&ifc) < 0 || 77 | ifc.ifc_len < sizeof(struct ifreq)) { 78 | syslog(LOG_ERR, "deviceEthAddr: SIOGIFCONF: %m"); 79 | (void) close(fd); 80 | exit(1); 81 | } 82 | ifr = ifc.ifc_req; 83 | for (i = 0; i < ifc.ifc_len; 84 | i += len, ifr = (struct ifreq *)((caddr_t)ifr + len)) { 85 | len = sizeof(ifr->ifr_name) + ifr->ifr_addr.sa_len; 86 | sdl = (struct sockaddr_dl *)&ifr->ifr_addr; 87 | if (sdl->sdl_family != AF_LINK || sdl->sdl_type != IFT_ETHER || 88 | sdl->sdl_alen != 6) 89 | continue; 90 | if (!strncmp(ifr->ifr_name, ifname, sizeof(ifr->ifr_name))) { 91 | memmove((caddr_t)eaddr, (caddr_t)LLADDR(sdl), 6); 92 | (void) close(fd); 93 | return; 94 | } 95 | } 96 | 97 | syslog(LOG_ERR, "deviceEthAddr: Never saw interface `%s'!", ifname); 98 | (void) close(fd); 99 | exit(1); 100 | 101 | #else 102 | int j = 0; 103 | 104 | if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { 105 | syslog(LOG_ERR, "deviceEthAddr: old socket: %m"); 106 | exit(1); 107 | } 108 | ifc.ifc_len = sizeof inbuf; 109 | ifc.ifc_buf = (caddr_t)inbuf; 110 | if (ioctl(fd, SIOCGIFCONF, (char *)&ifc) < 0 || 111 | ifc.ifc_len < sizeof(struct ifreq)) { 112 | syslog(LOG_ERR, "deviceEthAddr: old SIOCGIFCONF: %m"); 113 | (void) close(fd); 114 | exit(1); 115 | } 116 | 117 | ifr = ifc.ifc_req; 118 | for(i=0;i<(ifc.ifc_len / sizeof(struct ifreq));i++,ifr++){ 119 | if (ioctl(fd, SIOCGIFHWADDR, (char *)ifr) < 0) { 120 | syslog(LOG_ERR,"deviceEthAddr: SIOGIFHWADDR failed. ERRNO: %d\n",errno); 121 | continue; 122 | } 123 | if (!strncmp(ifr->ifr_name, ifname, sizeof(ifr->ifr_name))) { 124 | if(memmove((caddr_t)eaddr, (caddr_t)ifr->ifr_hwaddr.sa_data, 6) == NULL){ 125 | syslog(LOG_ERR, "deviceEthAddr: memmove returned NULL: %m"); 126 | (void) close(fd); 127 | exit(1); 128 | } 129 | } 130 | } 131 | 132 | (void) close(fd); 133 | return; 134 | #endif 135 | } 136 | 137 | void 138 | deviceOpen(ifname, proto, trans) 139 | char *ifname; 140 | u_short proto; 141 | int trans; 142 | { 143 | struct if_info *p, tmp; 144 | 145 | strcpy(tmp.if_name,ifname); 146 | tmp.iopen = pfInit; 147 | 148 | switch (proto) { 149 | case MOP_K_PROTO_RC: 150 | tmp.read = mopReadRC; 151 | tmp.fd = mopOpenRC(&tmp, trans); 152 | break; 153 | case MOP_K_PROTO_DL: 154 | tmp.read = mopReadDL; 155 | tmp.fd = mopOpenDL(&tmp, trans); 156 | break; 157 | default: 158 | break; 159 | } 160 | 161 | if (tmp.fd != -1) { 162 | 163 | p = (struct if_info *)malloc(sizeof(*p)); 164 | if (p == 0) { 165 | syslog(LOG_ERR, "deviceOpen: malloc: %m"); 166 | exit(1); 167 | } 168 | 169 | p->next = iflist; 170 | iflist = p; 171 | 172 | strcpy(p->if_name,tmp.if_name); 173 | p->iopen = tmp.iopen; 174 | p->write = pfWrite; 175 | p->read = tmp.read; 176 | memset((char *)p->eaddr, 0, sizeof(p->eaddr)); 177 | p->fd = tmp.fd; 178 | 179 | deviceEthAddr(p->if_name,&p->eaddr[0]); 180 | } 181 | } 182 | 183 | void 184 | deviceInitOne(ifname) 185 | char *ifname; 186 | { 187 | char interface[IFNAME_SIZE]; 188 | struct if_info *p; 189 | int trans; 190 | #ifdef _AIX 191 | char dev[IFNAME_SIZE]; 192 | int unit,j; 193 | 194 | unit = 0; 195 | for (j = 0; j < strlen(ifname); j++) { 196 | if (isalpha(ifname[j])) { 197 | dev[j] = ifname[j]; 198 | } else { 199 | if (isdigit(ifname[j])) { 200 | unit = unit*10 + ifname[j] - '0'; 201 | dev[j] = '\0'; 202 | } 203 | } 204 | } 205 | 206 | if ((strlen(dev) == 2) && 207 | (dev[0] == 'e') && 208 | ((dev[1] == 'n') || (dev[1] == 't'))) { 209 | sprintf(interface,"ent%d\0",unit); 210 | } else { 211 | sprintf(interface,"%s%d\0",dev,unit); 212 | } 213 | #else 214 | sprintf(interface,"%s",ifname); 215 | #endif 216 | 217 | /* Ok, init it just once */ 218 | 219 | p = iflist; 220 | for (p = iflist; p; p = p->next) { 221 | if (strcmp(p->if_name,interface) == 0) { 222 | return; 223 | } 224 | } 225 | 226 | syslog(LOG_INFO, "Initialized %s", interface); 227 | 228 | /* Ok, get transport information */ 229 | 230 | trans = pfTrans(interface); 231 | 232 | #ifndef NORC 233 | /* Start with MOP Remote Console */ 234 | 235 | switch (trans) { 236 | case TRANS_ETHER: 237 | deviceOpen(interface,MOP_K_PROTO_RC,TRANS_ETHER); 238 | break; 239 | case TRANS_8023: 240 | deviceOpen(interface,MOP_K_PROTO_RC,TRANS_8023); 241 | break; 242 | case TRANS_ETHER+TRANS_8023: 243 | deviceOpen(interface,MOP_K_PROTO_RC,TRANS_ETHER); 244 | deviceOpen(interface,MOP_K_PROTO_RC,TRANS_8023); 245 | break; 246 | case TRANS_ETHER+TRANS_8023+TRANS_AND: 247 | deviceOpen(interface,MOP_K_PROTO_RC,TRANS_ETHER+TRANS_8023); 248 | break; 249 | } 250 | #endif 251 | 252 | #ifndef NODL 253 | /* and next MOP Dump/Load */ 254 | 255 | switch (trans) { 256 | case TRANS_ETHER: 257 | deviceOpen(interface,MOP_K_PROTO_DL,TRANS_ETHER); 258 | break; 259 | case TRANS_8023: 260 | deviceOpen(interface,MOP_K_PROTO_DL,TRANS_8023); 261 | break; 262 | case TRANS_ETHER+TRANS_8023: 263 | deviceOpen(interface,MOP_K_PROTO_DL,TRANS_ETHER); 264 | deviceOpen(interface,MOP_K_PROTO_DL,TRANS_8023); 265 | break; 266 | case TRANS_ETHER+TRANS_8023+TRANS_AND: 267 | deviceOpen(interface,MOP_K_PROTO_DL,TRANS_ETHER+TRANS_8023); 268 | break; 269 | } 270 | #endif 271 | 272 | } 273 | 274 | /* 275 | * Initialize all "candidate" interfaces that are in the system 276 | * configuration list. A "candidate" is up, not loopback and not 277 | * point to point. 278 | */ 279 | void 280 | deviceInitAll() 281 | { 282 | #ifdef DEV_NEW_CONF 283 | char inbuf[8192]; 284 | struct ifconf ifc; 285 | struct ifreq *ifr; 286 | struct sockaddr_dl *sdl; 287 | int fd; 288 | int i, len; 289 | 290 | if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { 291 | syslog(LOG_ERR, "deviceInitAll: socket: %m"); 292 | exit(1); 293 | } 294 | 295 | ifc.ifc_len = sizeof(inbuf); 296 | ifc.ifc_buf = inbuf; 297 | if (ioctl(fd, SIOCGIFCONF, (caddr_t)&ifc) < 0 || 298 | ifc.ifc_len < sizeof(struct ifreq)) { 299 | syslog(LOG_ERR, "deviceInitAll: SIOCGIFCONF: %m"); 300 | exit(1); 301 | } 302 | ifr = ifc.ifc_req; 303 | for (i = 0; i < ifc.ifc_len; 304 | i += len, ifr = (struct ifreq *)((caddr_t)ifr + len)) { 305 | len = sizeof(ifr->ifr_name) + ifr->ifr_addr.sa_len; 306 | sdl = (struct sockaddr_dl *)&ifr->ifr_addr; 307 | if (sdl->sdl_family != AF_LINK || sdl->sdl_type != IFT_ETHER || 308 | sdl->sdl_alen != 6) 309 | continue; 310 | if (ioctl(fd, SIOCGIFFLAGS, (caddr_t)ifr) < 0) { 311 | syslog(LOG_ERR, "deviceInitAll: SIOCGIFFLAGS: %m"); 312 | continue; 313 | } 314 | if ((ifr->ifr_flags & 315 | (IFF_UP | IFF_LOOPBACK | IFF_POINTOPOINT)) != IFF_UP) 316 | continue; 317 | deviceInitOne(ifr->ifr_name); 318 | } 319 | (void) close(fd); 320 | #else 321 | int fd; 322 | int n; 323 | struct ifreq ibuf[8], *ifrp; 324 | struct ifconf ifc; 325 | 326 | if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { 327 | syslog(LOG_ERR, "deviceInitAll: old socket: %m"); 328 | exit(1); 329 | } 330 | ifc.ifc_len = sizeof ibuf; 331 | ifc.ifc_buf = (caddr_t)ibuf; 332 | if (ioctl(fd, SIOCGIFCONF, (char *)&ifc) < 0 || 333 | ifc.ifc_len < sizeof(struct ifreq)) { 334 | syslog(LOG_ERR, "deviceInitAll: old SIOCGIFCONF: %m"); 335 | exit(1); 336 | } 337 | ifrp = ibuf; 338 | n = ifc.ifc_len / sizeof(*ifrp); 339 | for (; --n >= 0; ++ifrp) { 340 | if (ioctl(fd, SIOCGIFFLAGS, (char *)ifrp) < 0) { 341 | continue; 342 | } 343 | if (/*(ifrp->ifr_flags & IFF_UP) == 0 ||*/ 344 | ifrp->ifr_flags & IFF_LOOPBACK || 345 | ifrp->ifr_flags & IFF_POINTOPOINT) 346 | continue; 347 | deviceInitOne(ifrp->ifr_name); 348 | } 349 | 350 | (void) close(fd); 351 | #endif 352 | } 353 | -------------------------------------------------------------------------------- /common/device.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: device.h,v 1.2 1997/03/25 03:07:07 thorpej Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1993-95 Mats O Jansson. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by Mats O Jansson. 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | * $NetBSD: device.h,v 1.2 1997/03/25 03:07:07 thorpej Exp $ 32 | * 33 | */ 34 | 35 | #ifndef _DEVICE_H_ 36 | #define _DEVICE_H_ 37 | 38 | __BEGIN_DECLS 39 | #ifdef DEV_NEW_CONF 40 | void deviceEthAddr __P((char *, u_char *)); 41 | #endif 42 | void deviceInitOne __P((char *)); 43 | void deviceInitAll __P((void)); 44 | 45 | /* from loop-bsd.c */ 46 | void Loop __P((void)); 47 | int mopOpenDL __P((struct if_info *, int)); 48 | int mopOpenRC __P((struct if_info *, int)); 49 | void mopReadDL __P((void)); 50 | void mopReadRC __P((void)); 51 | __END_DECLS 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /common/dl.c: -------------------------------------------------------------------------------- 1 | /* $NetBSD: dl.c,v 1.3 1997/10/16 23:24:31 lukem Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1993-95 Mats O Jansson. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by Mats O Jansson. 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | #ifndef lint 34 | static char rcsid[]="$NetBSD: dl.c,v 1.3 1997/10/16 23:24:31 lukem Exp $"; 35 | #endif 36 | 37 | #include "os.h" 38 | #include "dl.h" 39 | #include "get.h" 40 | #include "mopdef.h" 41 | #include "print.h" 42 | 43 | void 44 | mopDumpDL(fd, pkt, trans) 45 | FILE *fd; 46 | u_char *pkt; 47 | int trans; 48 | { 49 | int i,index = 0; 50 | u_int32_t tmpl; 51 | u_char tmpc,c,program[257],code,*ucp; 52 | u_short len,tmps,moplen; 53 | 54 | len = mopGetLength(pkt, trans); 55 | 56 | switch (trans) { 57 | case TRANS_8023: 58 | index = 22; 59 | moplen = len - 8; 60 | break; 61 | default: 62 | index = 16; 63 | moplen = len; 64 | } 65 | code = mopGetChar(pkt,&index); 66 | 67 | /* see above, if (len < 8) then moplen ends up around 65535 */ 68 | if (moplen > len) moplen = len; 69 | 70 | switch (code) { 71 | case MOP_K_CODE_MLT: 72 | 73 | tmpc = mopGetChar(pkt,&index); /* Load Number */ 74 | (void)fprintf(fd,"Load Number : %02x\n",tmpc); 75 | 76 | if (moplen > 6) { 77 | tmpl = mopGetLong(pkt,&index);/* Load Address */ 78 | (void)fprintf(fd,"Load Address : %08x\n", tmpl); 79 | } 80 | 81 | if (moplen > 10) { 82 | #ifndef SHORT_PRINT 83 | for (i = 0; i < (moplen - 10); i++) { 84 | if ((i % 16) == 0) { 85 | if ((i / 16) == 0) { 86 | (void)fprintf(fd, 87 | "Image Data : %04x ", 88 | moplen-10); 89 | } else { 90 | (void)fprintf(fd, 91 | " "); 92 | } 93 | } 94 | 95 | (void)fprintf(fd, "%02x ", 96 | mopGetChar(pkt,&index)); 97 | if ((i % 16) == 15) 98 | (void)fprintf(fd,"\n"); 99 | } 100 | 101 | if ((i % 16) != 15) 102 | (void)fprintf(fd,"\n"); 103 | #else 104 | index = index + moplen - 10; 105 | #endif 106 | } 107 | 108 | tmpl = mopGetLong(pkt,&index); /* Load Address */ 109 | (void)fprintf(fd,"Xfer Address : %08x\n", tmpl); 110 | 111 | break; 112 | case MOP_K_CODE_DCM: 113 | 114 | /* Empty Message */ 115 | 116 | break; 117 | case MOP_K_CODE_MLD: 118 | 119 | tmpc = mopGetChar(pkt,&index); /* Load Number */ 120 | (void)fprintf(fd,"Load Number : %02x\n",tmpc); 121 | 122 | tmpl = mopGetLong(pkt,&index); /* Load Address */ 123 | (void)fprintf(fd,"Load Address : %08x\n", tmpl); 124 | 125 | if (moplen > 6) { 126 | #ifndef SHORT_PRINT 127 | for (i = 0; i < (moplen - 6); i++) { 128 | if ((i % 16) == 0) { 129 | if ((i / 16) == 0) { 130 | (void)fprintf(fd, 131 | "Image Data : %04x ", 132 | moplen-6); 133 | } else { 134 | (void)fprintf(fd, 135 | " "); 136 | } 137 | } 138 | (void)fprintf(fd,"%02x ", 139 | mopGetChar(pkt,&index)); 140 | if ((i % 16) == 15) 141 | (void)fprintf(fd,"\n"); 142 | } 143 | 144 | if ((i % 16) != 15) 145 | (void)fprintf(fd,"\n"); 146 | #else 147 | index = index + moplen - 6; 148 | #endif 149 | } 150 | 151 | break; 152 | case MOP_K_CODE_ASV: 153 | 154 | /* Empty Message */ 155 | 156 | break; 157 | case MOP_K_CODE_RMD: 158 | 159 | tmpl = mopGetLong(pkt,&index); /* Memory Address */ 160 | (void)fprintf(fd,"Mem Address : %08x\n", tmpl); 161 | 162 | tmps = mopGetShort(pkt,&index); /* Count */ 163 | (void)fprintf(fd,"Count : %04x (%d)\n",tmps,tmps); 164 | 165 | break; 166 | case MOP_K_CODE_RPR: 167 | 168 | tmpc = mopGetChar(pkt,&index); /* Device Type */ 169 | (void)fprintf(fd, "Device Type : %02x ",tmpc); 170 | mopPrintDevice(fd, tmpc); (void)fprintf(fd, "\n"); 171 | 172 | tmpc = mopGetChar(pkt,&index); /* Format Version */ 173 | (void)fprintf(fd,"Format : %02x\n",tmpc); 174 | 175 | tmpc = mopGetChar(pkt,&index); /* Program Type */ 176 | (void)fprintf(fd,"Program Type : %02x ",tmpc); 177 | mopPrintPGTY(fd, tmpc); (void)fprintf(fd, "\n"); 178 | 179 | program[0] = 0; 180 | tmpc = mopGetChar(pkt,&index); /* Software ID Len */ 181 | for (i = 0; i < tmpc; i++) { 182 | program[i] = mopGetChar(pkt,&index); 183 | program[i+1] = '\0'; 184 | } 185 | 186 | (void)fprintf(fd,"Software : %02x '%s'\n",tmpc,program); 187 | 188 | tmpc = mopGetChar(pkt,&index); /* Processor */ 189 | (void)fprintf(fd,"Processor : %02x ",tmpc); 190 | mopPrintBPTY(fd, tmpc); (void)fprintf(fd, "\n"); 191 | 192 | mopPrintInfo(fd, pkt, &index, moplen, code, trans); 193 | 194 | break; 195 | case MOP_K_CODE_RML: 196 | 197 | tmpc = mopGetChar(pkt,&index); /* Load Number */ 198 | (void)fprintf(fd,"Load Number : %02x\n",tmpc); 199 | 200 | tmpc = mopGetChar(pkt,&index); /* Error */ 201 | (void)fprintf(fd,"Error : %02x (",tmpc); 202 | if ((tmpc == 0)) { 203 | (void)fprintf(fd,"no error)\n"); 204 | } else { 205 | (void)fprintf(fd,"error)\n"); 206 | } 207 | 208 | break; 209 | case MOP_K_CODE_RDS: 210 | 211 | tmpc = mopGetChar(pkt,&index); /* Device Type */ 212 | (void)fprintf(fd, "Device Type : %02x ",tmpc); 213 | mopPrintDevice(fd, tmpc); (void)fprintf(fd, "\n"); 214 | 215 | tmpc = mopGetChar(pkt,&index); /* Format Version */ 216 | (void)fprintf(fd,"Format : %02x\n",tmpc); 217 | 218 | tmpl = mopGetLong(pkt,&index); /* Memory Size */ 219 | (void)fprintf(fd,"Memory Size : %08x\n", tmpl); 220 | 221 | tmpc = mopGetChar(pkt,&index); /* Bits */ 222 | (void)fprintf(fd,"Bits : %02x\n",tmpc); 223 | 224 | mopPrintInfo(fd, pkt, &index, moplen, code, trans); 225 | 226 | break; 227 | case MOP_K_CODE_MDD: 228 | 229 | tmpl = mopGetLong(pkt,&index); /* Memory Address */ 230 | (void)fprintf(fd,"Mem Address : %08x\n", tmpl); 231 | 232 | if (moplen > 5) { 233 | #ifndef SHORT_PRINT 234 | for (i = 0; i < (moplen - 5); i++) { 235 | if ((i % 16) == 0) { 236 | if ((i / 16) == 0) { 237 | (void)fprintf(fd, 238 | "Image Data : %04x ", 239 | moplen-5); 240 | } else { 241 | (void)fprintf(fd, 242 | " "); 243 | } 244 | } 245 | (void)fprintf(fd,"%02x ", 246 | mopGetChar(pkt,&index)); 247 | if ((i % 16) == 15) 248 | (void)fprintf(fd,"\n"); 249 | } 250 | if ((i % 16) != 15) 251 | (void)fprintf(fd,"\n"); 252 | #else 253 | index = index + moplen - 5; 254 | #endif 255 | } 256 | 257 | break; 258 | case MOP_K_CODE_PLT: 259 | 260 | tmpc = mopGetChar(pkt,&index); /* Load Number */ 261 | (void)fprintf(fd,"Load Number : %02x\n",tmpc); 262 | 263 | tmpc = mopGetChar(pkt,&index); /* Parameter Type */ 264 | while (tmpc != MOP_K_PLTP_END) { 265 | c = mopGetChar(pkt,&index); /* Parameter Length */ 266 | switch(tmpc) { 267 | case MOP_K_PLTP_TSN: /* Target Name */ 268 | (void)fprintf(fd,"Target Name : %02x '", 269 | tmpc); 270 | for (i = 0; i < ((int) c); i++) { 271 | (void)fprintf(fd,"%c", 272 | mopGetChar(pkt,&index)); 273 | } 274 | (void)fprintf(fd,"'\n"); 275 | break; 276 | case MOP_K_PLTP_TSA: /* Target Address */ 277 | (void)fprintf(fd,"Target Addr : %02x ",c); 278 | for (i = 0; i < ((int) c); i++) { 279 | (void)fprintf(fd,"%02x ", 280 | mopGetChar(pkt,&index)); 281 | } 282 | (void)fprintf(fd,"\n"); 283 | break; 284 | case MOP_K_PLTP_HSN: /* Host Name */ 285 | (void)fprintf(fd,"Host Name : %02x '", 286 | tmpc); 287 | for (i = 0; i < ((int) c); i++) { 288 | (void)fprintf(fd,"%c", 289 | mopGetChar(pkt,&index)); 290 | } 291 | (void)fprintf(fd,"'\n"); 292 | break; 293 | case MOP_K_PLTP_HSA: /* Host Address */ 294 | (void)fprintf(fd,"Host Addr : %02x ",c); 295 | for (i = 0; i < ((int) c); i++) { 296 | (void)fprintf(fd,"%02x ", 297 | mopGetChar(pkt,&index)); 298 | } 299 | (void)fprintf(fd,"\n"); 300 | break; 301 | case MOP_K_PLTP_HST: /* Host Time */ 302 | ucp = pkt + index; index = index + 10; 303 | (void)fprintf(fd,"Host Time : "); 304 | mopPrintTime(fd, ucp); 305 | (void)fprintf(fd,"\n"); 306 | break; 307 | default: 308 | break; 309 | } 310 | tmpc = mopGetChar(pkt,&index);/* Parameter Type */ 311 | } 312 | 313 | tmpl = mopGetLong(pkt,&index); /* Transfer Address */ 314 | (void)fprintf(fd,"Transfer Addr: %08x\n", tmpl); 315 | 316 | break; 317 | default: 318 | break; 319 | } 320 | } 321 | 322 | 323 | -------------------------------------------------------------------------------- /common/dl.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: dl.h,v 1.2 1997/03/25 03:07:10 thorpej Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1993-95 Mats O Jansson. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by Mats O Jansson. 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | * $NetBSD: dl.h,v 1.2 1997/03/25 03:07:10 thorpej Exp $ 32 | * 33 | */ 34 | 35 | #ifndef _DL_H_ 36 | #define _DL_H_ 37 | 38 | __BEGIN_DECLS 39 | void mopDumpDL __P((FILE *, u_char *, int)); 40 | __END_DECLS 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /common/file.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: file.h,v 1.2 1997/03/25 03:07:13 thorpej Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1993-95 Mats O Jansson. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by Mats O Jansson. 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | * $NetBSD: file.h,v 1.2 1997/03/25 03:07:13 thorpej Exp $ 32 | * 33 | */ 34 | 35 | #ifndef _FILE_H_ 36 | #define _FILE_H_ 37 | 38 | __BEGIN_DECLS 39 | void mopFilePutLX __P((u_char *, int, u_int32_t, int)); 40 | void mopFilePutBX __P((u_char *, int, u_int32_t, int)); 41 | u_int32_t mopFileGetLX __P((u_char *, int, int)); 42 | u_int32_t mopFileGetBX __P((u_char *, int, int)); 43 | ssize_t mopFileRead __P((struct dllist *, u_char *)); 44 | void mopFileSwapX __P((u_char *, int, int)); 45 | int CheckMopFile __P((int)); 46 | int GetMopFileInfo __P((int, u_int32_t *, u_int32_t *)); 47 | int CheckAOutFile __P((int)); 48 | int GetAOutFileInfo __P((int, u_int32_t *, u_int32_t *, 49 | u_int32_t *, u_int32_t *, u_int32_t *, u_int32_t *, 50 | u_int32_t *, u_int32_t *, int *)); 51 | int GetFileInfo __P((int, u_int32_t *, u_int32_t *, int *, 52 | u_int32_t *, u_int32_t *, u_int32_t *, u_int32_t *, 53 | u_int32_t *, u_int32_t *)); 54 | __END_DECLS 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /common/get.c: -------------------------------------------------------------------------------- 1 | /* $NetBSD: get.c,v 1.2 1997/03/25 03:07:15 thorpej Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1993-95 Mats O Jansson. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by Mats O Jansson. 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | #ifndef lint 34 | static char rcsid[]="$NetBSD: get.c,v 1.2 1997/03/25 03:07:15 thorpej Exp $"; 35 | #endif 36 | 37 | #include "os.h" 38 | #include "get.h" 39 | #include "mopdef.h" 40 | 41 | u_char 42 | mopGetChar(pkt, index) 43 | u_char *pkt; 44 | int *index; 45 | { 46 | u_char ret; 47 | 48 | ret = pkt[*index]; 49 | *index = *index + 1; 50 | return(ret); 51 | } 52 | 53 | u_short 54 | mopGetShort(pkt, index) 55 | u_char *pkt; 56 | int *index; 57 | { 58 | u_short ret; 59 | 60 | ret = pkt[*index] + pkt[*index+1]*256; 61 | *index = *index + 2; 62 | return(ret); 63 | } 64 | 65 | u_int32_t 66 | mopGetLong(pkt, index) 67 | u_char *pkt; 68 | int *index; 69 | { 70 | u_int32_t ret; 71 | 72 | ret = pkt[*index] + 73 | pkt[*index+1]*0x100 + 74 | pkt[*index+2]*0x10000 + 75 | pkt[*index+3]*0x1000000; 76 | *index = *index + 4; 77 | return(ret); 78 | } 79 | 80 | void 81 | mopGetMulti(pkt, index, dest, size) 82 | u_char *pkt,*dest; 83 | int *index,size; 84 | { 85 | int i; 86 | 87 | for (i = 0; i < size; i++) { 88 | dest[i] = pkt[*index+i]; 89 | } 90 | *index = *index + size; 91 | 92 | } 93 | 94 | int 95 | mopGetTrans(pkt, trans) 96 | u_char *pkt; 97 | int trans; 98 | { 99 | u_short *ptype; 100 | 101 | if (trans == 0) { 102 | ptype = (u_short *)(pkt+12); 103 | if (ntohs(*ptype) < 1600) { 104 | trans = TRANS_8023; 105 | } else { 106 | trans = TRANS_ETHER; 107 | } 108 | } 109 | return(trans); 110 | } 111 | 112 | void 113 | mopGetHeader(pkt, index, dst, src, proto, len, trans) 114 | u_char *pkt, **dst, **src; 115 | int *index, *len, trans; 116 | u_short *proto; 117 | { 118 | *dst = pkt; 119 | *src = pkt + 6; 120 | *index = *index + 12; 121 | 122 | switch(trans) { 123 | case TRANS_ETHER: 124 | *proto = (u_short)(pkt[*index]*256 + pkt[*index+1]); 125 | *index = *index + 2; 126 | *len = (int)(pkt[*index+1]*256 + pkt[*index]); 127 | *index = *index + 2; 128 | break; 129 | case TRANS_8023: 130 | *len = (int)(pkt[*index]*256 + pkt[*index+1]); 131 | *index = *index + 8; 132 | *proto = (u_short)(pkt[*index]*256 + pkt[*index+1]); 133 | *index = *index + 2; 134 | break; 135 | } 136 | } 137 | 138 | u_short 139 | mopGetLength(pkt, trans) 140 | u_char *pkt; 141 | int trans; 142 | { 143 | switch(trans) { 144 | case TRANS_ETHER: 145 | return(pkt[15]*256 + pkt[14]); 146 | break; 147 | case TRANS_8023: 148 | return(pkt[12]*256 + pkt[13]); 149 | break; 150 | } 151 | return(0); 152 | } 153 | -------------------------------------------------------------------------------- /common/get.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: get.h,v 1.2 1997/03/25 03:07:16 thorpej Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1993-95 Mats O Jansson. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by Mats O Jansson. 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | * $NetBSD: get.h,v 1.2 1997/03/25 03:07:16 thorpej Exp $ 32 | * 33 | */ 34 | 35 | #ifndef _GET_H_ 36 | #define _GET_H_ 37 | 38 | __BEGIN_DECLS 39 | u_char mopGetChar __P((u_char *, int *)); 40 | u_short mopGetShort __P((u_char *, int *)); 41 | u_int32_t mopGetLong __P((u_char *, int *)); 42 | void mopGetMulti __P((u_char *, int *, u_char *, int)); 43 | int mopGetTrans __P((u_char *, int)); 44 | void mopGetHeader __P((u_char *, int *, u_char **, u_char **, 45 | u_short *, int *, int)); 46 | u_short mopGetLength __P((u_char *, int)); 47 | __END_DECLS 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /common/loop-bsd.c: -------------------------------------------------------------------------------- 1 | /* $NetBSD: loop-bsd.c,v 1.4 1998/02/03 04:51:29 perry Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1993-95 Mats O Jansson. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by Mats O Jansson. 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | #ifndef lint 34 | __RCSID("$NetBSD: loop-bsd.c,v 1.4 1998/02/03 04:51:29 perry Exp $"); 35 | #endif 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | #if defined(__bsdi__) || defined(__FreeBSD__) || defined(__NetBSD__) 42 | #include 43 | #endif 44 | #include 45 | #include 46 | 47 | #include "os.h" 48 | #include "common.h" 49 | #include "device.h" 50 | #include "mopdef.h" 51 | 52 | int 53 | mopOpenRC(p, trans) 54 | struct if_info *p; 55 | int trans; 56 | { 57 | #ifndef NORC 58 | return (*(p->iopen))(p->if_name, 59 | O_RDWR, 60 | MOP_K_PROTO_RC, 61 | trans); 62 | #else 63 | return -1; 64 | #endif 65 | } 66 | 67 | int 68 | mopOpenDL(p, trans) 69 | struct if_info *p; 70 | int trans; 71 | { 72 | #ifndef NODL 73 | return (*(p->iopen))(p->if_name, 74 | O_RDWR, 75 | MOP_K_PROTO_DL, 76 | trans); 77 | #else 78 | return -1; 79 | #endif 80 | } 81 | 82 | void 83 | mopReadRC() 84 | { 85 | } 86 | 87 | void 88 | mopReadDL() 89 | { 90 | } 91 | 92 | /* 93 | * The list of all interfaces that are being listened to. loop() 94 | * "selects" on the descriptors in this list. 95 | */ 96 | struct if_info *iflist; 97 | 98 | void mopProcess __P((struct if_info *, u_char *)); 99 | 100 | /* 101 | * Loop indefinitely listening for MOP requests on the 102 | * interfaces in 'iflist'. 103 | */ 104 | void 105 | Loop() 106 | { 107 | u_char *buf, *bp, *ep; 108 | int cc; 109 | fd_set fds, listeners; 110 | int bufsize, maxfd = 0; 111 | struct if_info *ii; 112 | 113 | if (iflist == 0) { 114 | syslog(LOG_ERR, "no interfaces"); 115 | exit(0); 116 | } 117 | if (iflist->fd != -1) { 118 | if (ioctl(iflist->fd, BIOCGBLEN, (caddr_t) & bufsize) < 0) { 119 | syslog(LOG_ERR, "BIOCGBLEN: %m"); 120 | exit(0); 121 | } 122 | } 123 | buf = (u_char *) malloc((unsigned) bufsize); 124 | if (buf == 0) { 125 | syslog(LOG_ERR, "malloc: %m"); 126 | exit(0); 127 | } 128 | /* 129 | * Find the highest numbered file descriptor for select(). 130 | * Initialize the set of descriptors to listen to. 131 | */ 132 | FD_ZERO(&fds); 133 | for (ii = iflist; ii; ii = ii->next) { 134 | if (ii->fd != -1) { 135 | FD_SET(ii->fd, &fds); 136 | if (ii->fd > maxfd) 137 | maxfd = ii->fd; 138 | } 139 | } 140 | while (1) { 141 | listeners = fds; 142 | if (select(maxfd + 1, &listeners, (struct fd_set *) 0, 143 | (struct fd_set *) 0, (struct timeval *) 0) < 0) { 144 | syslog(LOG_ERR, "select: %m"); 145 | exit(0); 146 | } 147 | for (ii = iflist; ii; ii = ii->next) { 148 | if (ii->fd != -1) { 149 | if (!FD_ISSET(ii->fd, &listeners)) 150 | continue; 151 | } 152 | again: 153 | cc = read(ii->fd, (char *) buf, bufsize); 154 | /* Don't choke when we get ptraced */ 155 | if (cc < 0 && errno == EINTR) 156 | goto again; 157 | /* Due to a SunOS bug, after 2^31 bytes, the file 158 | * offset overflows and read fails with EINVAL. The 159 | * lseek() to 0 will fix things. */ 160 | if (cc < 0) { 161 | if (errno == EINVAL && 162 | (lseek(ii->fd, 0, SEEK_CUR) + bufsize) < 0) { 163 | (void) lseek(ii->fd, 0, 0); 164 | goto again; 165 | } 166 | syslog(LOG_ERR, "read: %m"); 167 | exit(0); 168 | } 169 | /* Loop through the packet(s) */ 170 | #define bhp ((struct bpf_hdr *)bp) 171 | bp = buf; 172 | ep = bp + cc; 173 | while (bp < ep) { 174 | int caplen, hdrlen; 175 | 176 | caplen = bhp->bh_caplen; 177 | hdrlen = bhp->bh_hdrlen; 178 | mopProcess(ii, bp + hdrlen); 179 | bp += BPF_WORDALIGN(hdrlen + caplen); 180 | } 181 | } 182 | } 183 | } 184 | -------------------------------------------------------------------------------- /common/loop-linux2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993-95 Mats O Jansson. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. All advertising materials mentioning features or use of this software 13 | * must display the following acknowledgement: 14 | * This product includes software developed by Mats O Jansson. 15 | * 4. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #ifndef LINT 31 | static char rcsid[] = "$Id: loop-linux2.c,v 1.1.1.1 2001/06/24 19:33:53 atp Exp $"; 32 | #endif 33 | 34 | #include 35 | #include 36 | #include 37 | #if defined(__bsdi__) || defined(__FreeBSD__) 38 | #include 39 | #endif 40 | #include 41 | #include 42 | 43 | #include "os.h" 44 | #include "common.h" 45 | #include "mopdef.h" 46 | 47 | int 48 | mopOpenRC(p, trans) 49 | struct if_info *p; 50 | int trans; 51 | { 52 | #ifndef NORC 53 | return (*(p->iopen))(p->if_name, 54 | O_RDWR, 55 | MOP_K_PROTO_RC, 56 | trans); 57 | #else 58 | return -1; 59 | #endif 60 | } 61 | 62 | int 63 | mopOpenDL(p, trans) 64 | struct if_info *p; 65 | int trans; 66 | { 67 | #ifndef NODL 68 | return (*(p->iopen))(p->if_name, 69 | O_RDWR, 70 | MOP_K_PROTO_DL, 71 | trans); 72 | #else 73 | return -1; 74 | #endif 75 | } 76 | 77 | void 78 | mopReadRC() 79 | { 80 | } 81 | 82 | void 83 | mopReadDL() 84 | { 85 | } 86 | 87 | /* 88 | * The list of all interfaces that are being listened to. loop() 89 | * "selects" on the descriptors in this list. 90 | */ 91 | struct if_info *iflist; 92 | 93 | void mopProcess __P((struct if_info *, u_char *)); 94 | 95 | /* 96 | * Loop indefinitely listening for MOP requests on the 97 | * interfaces in 'iflist'. 98 | */ 99 | void 100 | Loop() 101 | { 102 | u_char *buf, *bp, *ep; 103 | int cc; 104 | fd_set fds, listeners; 105 | int bufsize = 1100, maxfd =0; 106 | struct if_info *ii; 107 | 108 | 109 | if (iflist == 0) { 110 | syslog(LOG_ERR, "no interfaces"); 111 | exit(0); 112 | } 113 | 114 | buf = (u_char *) malloc((unsigned) bufsize); 115 | 116 | if (buf == 0) { 117 | syslog(LOG_ERR, "malloc: %m"); 118 | exit(0); 119 | } 120 | /* 121 | * Find the highest numbered file descriptor for select(). 122 | * Initialize the set of descriptors to listen to. 123 | */ 124 | FD_ZERO(&fds); 125 | for (ii = iflist; ii; ii = ii->next) { 126 | if (ii->fd != -1) { 127 | FD_SET(ii->fd, &fds); 128 | if (ii->fd > maxfd) 129 | maxfd = ii->fd; 130 | } 131 | } 132 | while (1) { 133 | listeners = fds; 134 | if (select(maxfd + 1, &listeners, (fd_set *) 0, 135 | (fd_set *) 0, (struct timeval *) 0) < 0) { 136 | syslog(LOG_ERR, "select: %m"); 137 | exit(0); 138 | } 139 | for (ii = iflist; ii; ii = ii->next) { 140 | if (ii->fd != -1) { 141 | if (!FD_ISSET(ii->fd, &listeners)) 142 | continue; 143 | } 144 | again: 145 | cc = read(ii->fd, (char *) buf, bufsize); 146 | /* Don't choke when we get ptraced */ 147 | if (cc < 0 && errno == EINTR) 148 | goto again; 149 | 150 | bp = buf; 151 | ep = bp + cc; 152 | 153 | if(bp < ep) 154 | { 155 | mopProcess(ii,buf); 156 | } 157 | 158 | } 159 | 160 | } 161 | } 162 | 163 | -------------------------------------------------------------------------------- /common/mopdef.c: -------------------------------------------------------------------------------- 1 | /* $NetBSD: mopdef.c,v 1.2 1997/03/25 03:07:19 thorpej Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1995 Mats O Jansson. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by Mats O Jansson. 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | #ifndef lint 34 | static char rcsid[]="$NetBSD: mopdef.c,v 1.2 1997/03/25 03:07:19 thorpej Exp $"; 35 | #endif 36 | 37 | #define MOPDEF_SURPESS_EXTERN 38 | #include "mopdef.h" 39 | 40 | char dl_mcst[6] = MOP_DL_MULTICAST; /* Dump/Load Multicast */ 41 | char rc_mcst[6] = MOP_RC_MULTICAST; /* Remote Console Multicast */ 42 | char dl_802_proto[5] = MOP_K_PROTO_802_DL; /* MOP Dump/Load 802.2 */ 43 | char rc_802_proto[5] = MOP_K_PROTO_802_RC; /* MOP Remote Console 802.2 */ 44 | char lp_802_proto[5] = MOP_K_PROTO_802_LP; /* Loopback 802.2 */ 45 | 46 | #if 0 47 | int 48 | mopdef_dummy() 49 | { 50 | /* Just to keep them as variables */ 51 | return(dl_mcst[0]-rc_mcst[0]- 52 | lp_802_proto[1]-rc_802_proto[1]-lp_802_proto[1]); 53 | } 54 | #endif 55 | -------------------------------------------------------------------------------- /common/mopdef.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD$ */ 2 | 3 | /* 4 | * Copyright (c) 1993-95 Mats O Jansson. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by Mats O Jansson. 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | * $NetBSD: mopdef.h,v 1.1.1.1 1997/03/16 22:23:36 cjs Exp $ 32 | * 33 | */ 34 | 35 | #ifndef _MOPDEF_H_ 36 | #define _MOPDEF_H_ 37 | 38 | #define MOP_K_PROTO_DL 0x6001 /* MOP Load/Dump Protocol */ 39 | #define MOP_K_PROTO_RC 0x6002 /* MOP Remote Console Protocol */ 40 | #define MOP_K_PROTO_LP 0x9000 /* MOP Loopback Protocol */ 41 | 42 | #define MOP_K_PROTO_802_DL { 0x08, 0x00, 0x2b, 0x60, 0x01 } 43 | #define MOP_K_PROTO_802_RC { 0x08, 0x00, 0x2b, 0x60, 0x02 } 44 | #define MOP_K_PROTO_802_LP { 0x08, 0x00, 0x2b, 0x90, 0x00 } 45 | 46 | #define MOP_K_PROTO_802_DSAP 0xaa 47 | #define MOP_K_PROTO_802_SSAP 0xaa 48 | #define MOP_K_PROTO_802_CNTL 0x03 49 | 50 | #define TRANS_ETHER 1 /* Packet in Ethernet format */ 51 | #define TRANS_8023 2 /* Packet in 802.3 format */ 52 | #define TRANS_AND 0x1000 /* Both Ethernet and 802.3 */ 53 | 54 | /* The following constants are defined in module MOPDEF.SDL in MOM */ 55 | 56 | #define MOP_K_CODE_MIN 0 57 | #define MOP_K_CODE_MLT 0 /* Memory Load with transfer address */ 58 | #define MOP_K_CODE_DCM 1 /* Dump Complete */ 59 | #define MOP_K_CODE_MLD 2 /* Memory Load */ 60 | #define MOP_K_CODE_ASV 3 /* Assistance volunteer (NI only */ 61 | #define MOP_K_CODE_RMD 4 /* Request memory dump */ 62 | #define MOP_K_CODE_RID 5 /* Request ID */ 63 | #define MOP_K_CODE_BOT 6 /* Boot */ 64 | #define MOP_K_CODE_SID 7 /* System ID */ 65 | #define MOP_K_CODE_RPR 8 /* Request program */ 66 | #define MOP_K_CODE_RQC 9 /* Request Counters */ 67 | #define MOP_K_CODE_RML 10 /* Request memory load */ 68 | #define MOP_K_CODE_CNT 11 /* Counters */ 69 | #define MOP_K_CODE_RDS 12 /* Request Dump Service */ 70 | #define MOP_K_CODE_MMR 12 /* MOP Mode Running */ 71 | #define MOP_K_CODE_RVC 13 /* Reserve Console */ 72 | #define MOP_K_CODE_MDD 14 /* Memory dump data */ 73 | #define MOP_K_CODE_RLC 15 /* Release Console */ 74 | #define MOP_K_CODE_CCP 17 /* Console Command and Poll */ 75 | #define MOP_K_CODE_CRA 19 /* Console Response and Acknnowledge */ 76 | #define MOP_K_CODE_PLT 20 /* Parameter load with transfer address*/ 77 | #define MOP_K_CODE_ALD 24 /* Active loop data */ 78 | #define MOP_K_CODE_PLD 26 /* Passive looped data */ 79 | #define MOP_K_CODE_MAX 26 80 | 81 | #define MOP_K_PGTY_MIN 0 82 | #define MOP_K_PGTY_SECLDR 0 /* Secondary Loader */ 83 | #define MOP_K_PGTY_TERLDR 1 /* Tertiary Loader */ 84 | #define MOP_K_PGTY_OPRSYS 2 /* Operating System */ 85 | #define MOP_K_PGTY_MGNTFL 3 /* Management File */ 86 | #define MOP_K_PGTY_MAX 3 87 | 88 | #define MOP_K_BPTY_MIN 0 89 | #define MOP_K_BPTY_SYS 0 /* System Processor */ 90 | #define MOP_K_BPTY_COM 1 /* Communication Processor */ 91 | #define MOP_K_BPTY_MAX 1 92 | 93 | #define MOP_K_RML_ERROR_MIN 0 94 | #define MOP_K_RML_ERROR_NONE 0 /* None */ 95 | #define MOP_K_RML_ERROR_NO_LOAD 1 /* Image data not properly loaded */ 96 | #define MOP_K_RML_ERROR_MAX 1 97 | 98 | #define MOP_K_PLTP_MIN 0 99 | #define MOP_K_PLTP_END 0 /* End Mark */ 100 | #define MOP_K_PLTP_TSN 1 /* Target System Name */ 101 | #define MOP_K_PLTP_TSA 2 /* Target System Address */ 102 | #define MOP_K_PLTP_HSN 3 /* Host System Name */ 103 | #define MOP_K_PLTP_HSA 4 /* Host System Address */ 104 | #define MOP_K_PLTP_HST 5 /* Host System Time */ 105 | #define MOP_K_PLTP_MAX 5 106 | 107 | #define MOP_K_BOT_CNTL_MIN 0 108 | #define MOP_K_BOT_CNTL_SERVER 0 /* Boot-Server */ 109 | #define MOP_K_BOT_CNTL_DEVICE 1 /* Boot-Device */ 110 | #define MOP_K_BOT_CNTL_MAX 1 111 | 112 | #define MOP_K_INFO_VER 1 /* Maintenance Version */ 113 | #define MOP_K_INFO_MFCT 2 /* Maintenance Functions */ 114 | #define MOP_K_INFO_CNU 3 /* Console User */ 115 | #define MOP_K_INFO_RTM 4 /* Reservation Timer */ 116 | #define MOP_K_INFO_CSZ 5 /* Console Command Size */ 117 | #define MOP_K_INFO_RSZ 6 /* Console Response Size */ 118 | #define MOP_K_INFO_HWA 7 /* Hardware Address */ 119 | #define MOP_K_INFO_TIME 8 /* System Time */ 120 | #define MOP_K_INFO_SOFD 100 /* Communication Device */ 121 | #define MOP_K_INFO_SFID 200 /* Software ID */ 122 | #define MOP_K_INFO_PRTY 300 /* System Processor */ 123 | #define MOP_K_INFO_DLTY 400 /* Data Link Type */ 124 | #define MOP_K_INFO_DLBSZ 401 /* Data Link Buffer Size */ 125 | 126 | #define MOP_K_DLTY_MIN 1 127 | #define MOP_K_DLTY_NI 1 /* Ethernet */ 128 | #define MOP_K_DLTY_DDCMP 2 /* DDCMP */ 129 | #define MOP_K_DLTY_LAPB 3 /* LAPB (frame level of X.25) */ 130 | #define MOP_K_DLTY_MAX 3 131 | 132 | #define MOP_K_PRTY_MIN 0 133 | #define MOP_K_PRTY_11 1 /* PDP-11 (UNIBUS) */ 134 | #define MOP_K_PRTY_CMSV 2 /* Communication Server */ 135 | #define MOP_K_PRTY_PRO 3 /* Professional */ 136 | #define MOP_K_PRTY_SCO 4 /* Scorpio */ 137 | #define MOP_K_PRTY_AMB 5 /* Amber */ 138 | #define MOP_K_PRTY_BRI 6 /* XLII Bridge */ 139 | #define MOP_K_PRTY_MAX 6 140 | 141 | #define MOP_K_SFID_FORM_MIN -2 142 | #define MOP_K_SFID_FORM_MAINT -2 /* Maintenance System */ 143 | #define MOP_K_SFID_FORM_OPRSYS -1 /* Standard Operating System */ 144 | #define MOP_K_SFID_FORM_NONE 0 /* None */ 145 | #define MOP_K_SFID_FORM_MAX 0 146 | 147 | #define MOP_K_SFID_CUST 'CP' /* Customer product */ 148 | #define MOP_K_SFID_DEC 'DP' /* DEC product */ 149 | #define MOP_K_SFID_DELIM_ID '#' /* Delimiter identifier */ 150 | 151 | #define MOP_K_DLBSZ_DEFAULT 262 /* Buffersize */ 152 | 153 | #define MOP_K_NILOOP_REPLY 1 /* Response */ 154 | #define MOP_K_NILOOP_FORWARD 2 /* Forward Data */ 155 | 156 | #define MOP_DL_MULTICAST { 0xab, 0x00, 0x00, 0x01, 0x00, 0x00 } 157 | #define MOP_RC_MULTICAST { 0xab, 0x00, 0x00, 0x02, 0x00, 0x00 } 158 | #define MOP_LP_MULTICAST { 0xcf, 0x00, 0x00, 0x00, 0x00, 0x00 } 159 | 160 | #define MOP_K_RPR_FORMAT_V3 1 /* Format Version of RPR */ 161 | #define MOP_K_RPR_FORMAT 4 /* Format Version of RPR */ 162 | 163 | #define IHD_C_MINCODE -1 /* Low bound of ALIAS value */ 164 | #define IHD_C_NATIVE -1 /* Native mode image */ 165 | #define IHD_C_RSX 0 /* RSX image produced by TKB */ 166 | #define IHD_C_BPA 1 /* BASIC plus analog */ 167 | #define IHD_C_ALIAS 2 /* Last 126 bytes contains ASCIC of image to activate */ 168 | #define IHD_C_CLI 3 /* Image is CLI, run LOGINOUT */ 169 | #define IHD_C_PMAX 4 /* PMAX system image */ 170 | #define IHD_C_ALPHA 5 /* ALPHA system image */ 171 | #define IHD_C_MAXCODE 5 /* High bound of ALIAS value */ 172 | 173 | #define IHD_W_SIZE 0 174 | #define IHD_W_ACTIVOFF 2 175 | #define IHD_B_HDRBLKCNT 16 176 | #define IHD_W_ALIAS 510 177 | #define ISD_W_PAGCNT 2 178 | #define ISD_V_VPN 4 179 | #define ISD_M_VPN 0x1fffff 180 | #define IHA_L_TFRADR1 0 181 | #define EISD_L_SECSIZE 12 182 | #define EIHD_L_ISDOFF 12 183 | #define EIHD_L_HDRBLKCNT 76 184 | 185 | #define L_BSA 0x08 /* RSX base address */ 186 | #define L_BLDZ 0x0e /* RSX image size (* 64) */ 187 | #define L_BXFR 0xe8 /* RSX transfer address */ 188 | #define L_BBLK 0xf0 /* RSX header block count */ 189 | 190 | #ifndef MOPDEF_SUPRESS_EXTERN 191 | extern char dl_mcst[]; 192 | extern char rc_mcst[]; 193 | extern char dl_802_proto[]; 194 | extern char rc_802_proto[]; 195 | extern char lp_802_proto[]; 196 | #endif 197 | 198 | #endif 199 | -------------------------------------------------------------------------------- /common/nma.c: -------------------------------------------------------------------------------- 1 | /* $NetBSD: nma.c,v 1.2 1997/03/25 03:07:22 thorpej Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1995 Mats O Jansson. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by Mats O Jansson. 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | #ifndef lint 34 | static char rcsid[]="$NetBSD: nma.c,v 1.2 1997/03/25 03:07:22 thorpej Exp $"; 35 | #endif 36 | 37 | #include "os.h" 38 | #include "nma.h" 39 | #include "nmadef.h" 40 | 41 | struct commDev { 42 | int val; 43 | char *sname; 44 | char *name; 45 | }; 46 | 47 | struct commDev nmaCommDev[] = { 48 | { NMA_C_SOFD_DP , "DP ", "DP11-DA" }, 49 | { NMA_C_SOFD_UNA, "UNA", "DEUNA" }, 50 | { NMA_C_SOFD_DU , "DU ", "DU11-DA" }, 51 | { NMA_C_SOFD_CNA, "CNA", "DECNA" }, 52 | { NMA_C_SOFD_DL , "DL ", "DL11-C, -E, or -WA" }, 53 | { NMA_C_SOFD_QNA, "QNA", "DEQNA" }, 54 | { NMA_C_SOFD_DQ , "DQ ", "DQ11-DA" }, 55 | { NMA_C_SOFD_CI , "CI ", "Computer Interconnect" }, 56 | { NMA_C_SOFD_DA , "DA ", "DA11-B or -AL" }, 57 | { NMA_C_SOFD_PCL, "PCL", "PCL11-B" }, 58 | { NMA_C_SOFD_DUP, "DUP", "DUP11-DA" }, 59 | { NMA_C_SOFD_LUA, "LUA", "DELUA" }, 60 | { NMA_C_SOFD_DMC, "DMC", "DMC11-DA/AR, -FA/AR, -MA/AL or -MD/AL" }, 61 | { NMA_C_SOFD_LNA, "LNA", "MicroServer Lance" }, 62 | { NMA_C_SOFD_DN , "DN ", "DN11-BA or -AA" }, 63 | { NMA_C_SOFD_DLV, "DLV", "DLV11-E, -F, -J, MXV11-A or -B" }, 64 | { NMA_C_SOFD_LCS, "LCS", "DECServer 100" }, 65 | { NMA_C_SOFD_DMP, "DMP", "DMP11" }, 66 | { NMA_C_SOFD_AMB, "AMB", "AMBER" }, 67 | { NMA_C_SOFD_DTE, "DTE", "DTE20" }, 68 | { NMA_C_SOFD_DBT, "DBT", "DEBET" }, 69 | { NMA_C_SOFD_DV , "DV ", "DV11-AA/BA" }, 70 | { NMA_C_SOFD_BNA, "BNA", "DEBNA" }, 71 | { NMA_C_SOFD_BNT, "BNT", "DEBNT" }, 72 | { NMA_C_SOFD_DZ , "DZ ", "DZ11-A, -B, -C, -D" }, 73 | { NMA_C_SOFD_LPC, "LPC", "PCXX" }, 74 | { NMA_C_SOFD_DSV, "DSV", "DSV11" }, 75 | { NMA_C_SOFD_CEC, "CEC", "3-COM/IBM-PC" }, 76 | { NMA_C_SOFD_KDP, "KDP", "KMC11/DUP11-DA" }, 77 | { NMA_C_SOFD_IEC, "IEC", "Interlan/IBM-PC" }, 78 | { NMA_C_SOFD_KDZ, "KDZ", "KMC11/DZ11-A, -B, -C, or -D" }, 79 | { NMA_C_SOFD_UEC, "UEC", "Univation/RAINBOW-100" }, 80 | { NMA_C_SOFD_KL8, "KL8", "KL8-J" }, 81 | { NMA_C_SOFD_DS2, "DS2", "DECServer 200" }, 82 | { NMA_C_SOFD_DMV, "DMV", "DMV11" }, 83 | { NMA_C_SOFD_DS5, "DS5", "DECServer 500" }, 84 | { NMA_C_SOFD_DPV, "DPV", "DPV11" }, 85 | { NMA_C_SOFD_LQA, "LQA", "DELQA" }, 86 | { NMA_C_SOFD_DMF, "DMF", "DMF32" }, 87 | { NMA_C_SOFD_SVA, "SVA", "DESVA" }, 88 | { NMA_C_SOFD_DMR, "DMR", "DMR11-AA, -AB, -AC, or -AE" }, 89 | { NMA_C_SOFD_MUX, "MUX", "MUXserver" }, 90 | { NMA_C_SOFD_KMY, "KMY", "KMS11-PX" }, 91 | { NMA_C_SOFD_DEP, "DEP", "DEPCA PCSG/IBM-PC" }, 92 | { NMA_C_SOFD_KMX, "KMX", "KMS11-BD/BE" }, 93 | { NMA_C_SOFD_LTM, "LTM", "LTM Ethernet monitor" }, 94 | { NMA_C_SOFD_DMB, "DMB", "DMB-32" }, 95 | { NMA_C_SOFD_DES, "DES", "DESNC" }, 96 | { NMA_C_SOFD_KCP, "KCP", "KCP" }, 97 | { NMA_C_SOFD_MX3, "MX3", "MUXServer 300" }, 98 | { NMA_C_SOFD_SYN, "SYN", "MicroServer" }, 99 | { NMA_C_SOFD_MEB, "MEB", "DEMEB" }, 100 | { NMA_C_SOFD_DSB, "DSB", "DSB32" }, 101 | { NMA_C_SOFD_BAM, "BAM", "DEBAM LANBridge-200" }, 102 | { NMA_C_SOFD_DST, "DST", "DST-32 TEAMmate" }, 103 | { NMA_C_SOFD_FAT, "FAT", "DEFAT" }, 104 | { NMA_C_SOFD_RSM, "RSM", "DERSM - Remote Segment Monitor" }, 105 | { NMA_C_SOFD_RES, "RES", "DERES - Remote Environmental Sensor" }, 106 | { NMA_C_SOFD_3C2, "3C2", "3COM Etherlink II (3C503)" }, 107 | { NMA_C_SOFD_3CM, "3CM", "3COM Etherlink/MC (3C523)" }, 108 | { NMA_C_SOFD_DS3, "DS3", "DECServer 300" }, 109 | { NMA_C_SOFD_MF2, "MF2", "Mayfair-2" }, 110 | { NMA_C_SOFD_MMR, "MMR", "DEMMR" }, 111 | { NMA_C_SOFD_VIT, "VIT", "Vitalink TransLAN III/IV (NP3A) Bridge " }, 112 | { NMA_C_SOFD_VT5, "VT5", "Vitalink TransLAN 350 (NPC25) Bridge " }, 113 | { NMA_C_SOFD_BNI, "BNI", "DEBNI" }, 114 | { NMA_C_SOFD_MNA, "MNA", "DEMNA" }, 115 | { NMA_C_SOFD_PMX, "PMX", "PMAX (KN01)" }, 116 | { NMA_C_SOFD_NI5, "NI5", "Interlan NI5210-8" }, 117 | { NMA_C_SOFD_NI9, "NI9", "Interlan NI9210" }, 118 | { NMA_C_SOFD_KMK, "KMK", "KMS11-K" }, 119 | { NMA_C_SOFD_3CP, "3CP", "3COM Etherlink Plus (3C505) " }, 120 | { NMA_C_SOFD_DP2, "DP2", "DPNserver-200" }, 121 | { NMA_C_SOFD_ISA, "ISA", "SGEC" }, 122 | { NMA_C_SOFD_DIV, "DIV", "DIV-32 DEC WAN controller-100" }, 123 | { NMA_C_SOFD_QTA, "QTA", "DEQTA" }, 124 | { NMA_C_SOFD_B15, "B15", "LANbridge-150" }, 125 | { NMA_C_SOFD_WD8, "WD8", "WD8003 Family" }, 126 | { NMA_C_SOFD_ILA, "ILA", "BICC ISOLAN 4110-2" }, 127 | { NMA_C_SOFD_ILM, "ILM", "BICC ISOLAN 4110-3" }, 128 | { NMA_C_SOFD_APR, "APR", "Apricot Xen-S and Qi" }, 129 | { NMA_C_SOFD_ASN, "ASN", "AST EtherNode" }, 130 | { NMA_C_SOFD_ASE, "ASE", "AST Ethernet" }, 131 | { NMA_C_SOFD_TRW, "TRW", "TRW HC-2001" }, 132 | { NMA_C_SOFD_EDX, "EDX", "Ethernet-XT/AT" }, 133 | { NMA_C_SOFD_EDA, "EDA", "Ethernet-AT" }, 134 | { NMA_C_SOFD_DR2, "DR2", "DECrouter-250" }, 135 | { NMA_C_SOFD_SCC, "SCC", "DECrouter-250 DUSCC" }, 136 | { NMA_C_SOFD_DCA, "DCA", "DCA Series 300" }, 137 | { NMA_C_SOFD_TIA, "TIA", "LANcard/E" }, 138 | { NMA_C_SOFD_FBN, "FBN", "DEFEB DECbridge-500" }, 139 | { NMA_C_SOFD_FEB, "FEB", "DEFEB DECbridge-500 FDDI" }, 140 | { NMA_C_SOFD_FCN, "FCN", "DEFCN DECconcentrator-500" }, 141 | { NMA_C_SOFD_MFA, "MFA", "DEMFA" }, 142 | { NMA_C_SOFD_MXE, "MXE", "MIPS workstation family" }, 143 | { NMA_C_SOFD_CED, "CED", "Cabletron Ethernet Desktop" }, 144 | { NMA_C_SOFD_C20, "C20", "3Com CS/200" }, 145 | { NMA_C_SOFD_CS1, "CS1", "3Com CS/1" }, 146 | { NMA_C_SOFD_C2M, "C2M", "3Com CS/210, CS/2000, CS/2100" }, 147 | { NMA_C_SOFD_ACA, "ACA", "ACA/32000 system" }, 148 | { NMA_C_SOFD_GSM, "GSM", "Gandalf StarMaster" }, 149 | { NMA_C_SOFD_DSF, "DSF", "DSF32" }, 150 | { NMA_C_SOFD_CS5, "CS5", "3Com CS/50" }, 151 | { NMA_C_SOFD_XIR, "XIR", "XIRCOM PE10B2" }, 152 | { NMA_C_SOFD_KFE, "KFE", "KFE52" }, 153 | { NMA_C_SOFD_RT3, "RT3", "rtVAX-300" }, 154 | { NMA_C_SOFD_SPI, "SPI", "Spiderport M250" }, 155 | { NMA_C_SOFD_FOR, "FOR", "LAT gateway" }, 156 | { NMA_C_SOFD_MER, "MER", "Meridian" }, 157 | { NMA_C_SOFD_PER, "PER", "Persoft" }, 158 | { NMA_C_SOFD_STR, "STR", "AT&T StarLan-10" }, 159 | { NMA_C_SOFD_MPS, "MPS", "MIPSfair" }, 160 | { NMA_C_SOFD_L20, "L20", "LPS20 print server" }, 161 | { NMA_C_SOFD_VT2, "VT2", "Vitalink TransLAN 320 Bridge" }, 162 | { NMA_C_SOFD_DWT, "DWT", "VT-1000" }, 163 | { NMA_C_SOFD_WGB, "WGB", "DEWGB" }, 164 | { NMA_C_SOFD_ZEN, "ZEN", "Zenith Z-LAN4000, Z-LAN" }, 165 | { NMA_C_SOFD_TSS, "TSS", "Thursby Software Systems" }, 166 | { NMA_C_SOFD_MNE, "MNE", "3MIN (KN02-BA)" }, 167 | { NMA_C_SOFD_FZA, "FZA", "DEFZA" }, 168 | { NMA_C_SOFD_90L, "90L", "DS90L" }, 169 | { NMA_C_SOFD_CIS, "CIS", "Cisco Systems" }, 170 | { NMA_C_SOFD_STC, "STC", "STRTC" }, 171 | { NMA_C_SOFD_UBE, "UBE", "Ungermann-Bass PC2030, PC3030" }, 172 | { NMA_C_SOFD_DW2, "DW2", "DECwindows terminal II" }, 173 | { NMA_C_SOFD_FUE, "FUE", "Fujitsu Etherstar MB86950" }, 174 | { NMA_C_SOFD_M38, "M38", "MUXServer 380" }, 175 | { NMA_C_SOFD_NTI, "NTI", "NTI Group PC Ethernet Card" }, 176 | { NMA_C_SOFD_RAD, "RAD", "RADLINX LAN Gateway" }, 177 | { NMA_C_SOFD_INF, "INF", "Infotron Commix" }, 178 | { NMA_C_SOFD_XMX, "XMX", "Xyplex MAXserver" }, 179 | { NMA_C_SOFD_NDI, "NDI", "NDIS data link driver for MS/DOS systems" }, 180 | { NMA_C_SOFD_ND2, "ND2", "NDIS data link driver for OS/2 systems" }, 181 | { NMA_C_SOFD_TRN, "TRN", "DEC LANcontroller 520" }, 182 | { NMA_C_SOFD_DEV, "DEV", "Develcon Electronics Ltd. LAT gateway" }, 183 | { NMA_C_SOFD_ACE, "ACE", "Acer 5220, 5270 adapter" }, 184 | { NMA_C_SOFD_PNT, "PNT", "ProNet-4/18 #1390" }, 185 | { NMA_C_SOFD_ISE, "ISE", "Network Integration Server 600" }, 186 | { NMA_C_SOFD_IST, "IST", "Network Integration Server 600 T1" }, 187 | { NMA_C_SOFD_ISH, "ISH", "Network Integration Server 64 kb HDLC" }, 188 | { NMA_C_SOFD_ISF, "ISF", "Network Integration Server 600 FDDI" }, 189 | { NMA_C_SOFD_DSW, "DSW", "DSW-21" }, 190 | { NMA_C_SOFD_DW4, "DW4", "DSW-41/42" }, 191 | { NMA_C_SOFD_TRA, "TRA", "DETRA-AA" }, 192 | { 0, 0, 0 }, 193 | }; 194 | 195 | char * 196 | nmaGetShort(devno) 197 | int devno; 198 | { 199 | struct commDev *current; 200 | 201 | current = nmaCommDev; 202 | 203 | while (current->sname != NULL) { 204 | if (current->val == devno) 205 | break; 206 | current++; 207 | } 208 | 209 | return(current->sname); 210 | } 211 | 212 | char * 213 | nmaGetDevice(devno) 214 | int devno; 215 | { 216 | struct commDev *current; 217 | 218 | current = nmaCommDev; 219 | 220 | while (current->name != NULL) { 221 | if (current->val == devno) 222 | break; 223 | current++; 224 | } 225 | 226 | return(current->name); 227 | } 228 | -------------------------------------------------------------------------------- /common/nma.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: nma.h,v 1.2 1997/03/25 03:07:23 thorpej Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1995 Mats O Jansson. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by Mats O Jansson. 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | * $NetBSD: nma.h,v 1.2 1997/03/25 03:07:23 thorpej Exp $ 32 | * 33 | */ 34 | 35 | #ifndef _NMA_H_ 36 | #define _NMA_H_ 37 | 38 | __BEGIN_DECLS 39 | char *nmaGetShort __P((int)); 40 | char *nmaGetDevice __P((int)); 41 | __END_DECLS 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /common/nmadef.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD$ */ 2 | 3 | /* 4 | * Copyright (c) 1995 Mats O Jansson. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by Mats O Jansson. 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | * $NetBSD: nmadef.h,v 1.1.1.1 1997/03/16 22:23:37 cjs Exp $ 32 | * 33 | */ 34 | 35 | #ifndef _NMADEF_H_ 36 | #define _NMADEF_H_ 37 | 38 | #define NMA_C_SOFD_DP 0 /* DP11-DA */ 39 | #define NMA_C_SOFD_UNA 1 /* DEUNA */ 40 | #define NMA_C_SOFD_DU 2 /* DU11-DA */ 41 | #define NMA_C_SOFD_CNA 3 /* DECNA */ 42 | #define NMA_C_SOFD_DL 4 /* DL11-C, -E, or -WA */ 43 | #define NMA_C_SOFD_QNA 5 /* DEQNA */ 44 | #define NMA_C_SOFD_DQ 6 /* DQ11-DA */ 45 | #define NMA_C_SOFD_CI 7 /* Computer Interconnect */ 46 | #define NMA_C_SOFD_DA 8 /* DA11-B or -AL */ 47 | #define NMA_C_SOFD_PCL 9 /* PCL11-B */ 48 | #define NMA_C_SOFD_DUP 10 /* DUP11-DA */ 49 | #define NMA_C_SOFD_LUA 11 /* DELUA */ 50 | #define NMA_C_SOFD_DMC 12 /* DMC11-DA/AR, -FA/AR, -MA/AL or -MD/AL */ 51 | #define NMA_C_SOFD_LNA 13 /* MicroServer Lance */ 52 | #define NMA_C_SOFD_DN 14 /* DN11-BA or -AA */ 53 | #define NMA_C_SOFD_DLV 16 /* DLV11-E, -F, -J, MXV11-A or -B */ 54 | #define NMA_C_SOFD_LCS 17 /* DECServer 100 */ 55 | #define NMA_C_SOFD_DMP 18 /* DMP11 */ 56 | #define NMA_C_SOFD_AMB 19 /* AMBER */ 57 | #define NMA_C_SOFD_DTE 20 /* DTE20 */ 58 | #define NMA_C_SOFD_DBT 21 /* DEBET */ 59 | #define NMA_C_SOFD_DV 22 /* DV11-AA/BA */ 60 | #define NMA_C_SOFD_BNA 23 /* DEBNA */ 61 | #define NMA_C_SOFD_BNT 23 /* DEBNT */ 62 | #define NMA_C_SOFD_DZ 24 /* DZ11-A, -B, -C, -D */ 63 | #define NMA_C_SOFD_LPC 25 /* PCXX */ 64 | #define NMA_C_SOFD_DSV 26 /* DSV11 */ 65 | #define NMA_C_SOFD_CEC 27 /* 3-COM/IBM-PC */ 66 | #define NMA_C_SOFD_KDP 28 /* KMC11/DUP11-DA */ 67 | #define NMA_C_SOFD_IEC 29 /* Interlan/IBM-PC */ 68 | #define NMA_C_SOFD_KDZ 30 /* KMC11/DZ11-A, -B, -C, or -D */ 69 | #define NMA_C_SOFD_UEC 31 /* Univation/RAINBOW-100 */ 70 | #define NMA_C_SOFD_KL8 32 /* KL8-J */ 71 | #define NMA_C_SOFD_DS2 33 /* DECServer 200 */ 72 | #define NMA_C_SOFD_DMV 34 /* DMV11 */ 73 | #define NMA_C_SOFD_DS5 35 /* DECServer 500 */ 74 | #define NMA_C_SOFD_DPV 36 /* DPV11 */ 75 | #define NMA_C_SOFD_LQA 37 /* DELQA */ 76 | #define NMA_C_SOFD_DMF 38 /* DMF32 */ 77 | #define NMA_C_SOFD_SVA 39 /* DESVA */ 78 | #define NMA_C_SOFD_DMR 40 /* DMR11-AA, -AB, -AC, or -AE */ 79 | #define NMA_C_SOFD_MUX 41 /* MUXserver */ 80 | #define NMA_C_SOFD_KMY 42 /* KMS11-PX */ 81 | #define NMA_C_SOFD_DEP 43 /* DEPCA PCSG/IBM-PC */ 82 | #define NMA_C_SOFD_KMX 44 /* KMS11-BD/BE */ 83 | #define NMA_C_SOFD_LTM 45 /* LTM Ethernet monitor */ 84 | #define NMA_C_SOFD_DMB 46 /* DMB-32 */ 85 | #define NMA_C_SOFD_DES 47 /* DESNC */ 86 | #define NMA_C_SOFD_KCP 48 /* KCP */ 87 | #define NMA_C_SOFD_MX3 49 /* MUXServer 300 */ 88 | #define NMA_C_SOFD_SYN 50 /* MicroServer */ 89 | #define NMA_C_SOFD_MEB 51 /* DEMEB */ 90 | #define NMA_C_SOFD_DSB 52 /* DSB32 */ 91 | #define NMA_C_SOFD_BAM 53 /* DEBAM LANBridge-200 */ 92 | #define NMA_C_SOFD_DST 54 /* DST-32 TEAMmate */ 93 | #define NMA_C_SOFD_FAT 55 /* DEFAT */ 94 | #define NMA_C_SOFD_RSM 56 /* DERSM - Remote Segment Monitor */ 95 | #define NMA_C_SOFD_RES 57 /* DERES - Remote Environmental Sensor */ 96 | #define NMA_C_SOFD_3C2 58 /* 3COM Etherlink II (3C503) */ 97 | #define NMA_C_SOFD_3CM 59 /* 3COM Etherlink/MC (3C523) */ 98 | #define NMA_C_SOFD_DS3 60 /* DECServer 300 */ 99 | #define NMA_C_SOFD_MF2 61 /* Mayfair-2 */ 100 | #define NMA_C_SOFD_MMR 62 /* DEMMR */ 101 | #define NMA_C_SOFD_VIT 63 /* Vitalink TransLAN III/IV (NP3A) Bridge */ 102 | #define NMA_C_SOFD_VT5 64 /* Vitalink TransLAN 350 (NPC25) Bridge */ 103 | #define NMA_C_SOFD_BNI 65 /* DEBNI */ 104 | #define NMA_C_SOFD_MNA 66 /* DEMNA */ 105 | #define NMA_C_SOFD_PMX 67 /* PMAX (KN01) */ 106 | #define NMA_C_SOFD_NI5 68 /* Interlan NI5210-8 */ 107 | #define NMA_C_SOFD_NI9 69 /* Interlan NI9210 */ 108 | #define NMA_C_SOFD_KMK 70 /* KMS11-K */ 109 | #define NMA_C_SOFD_3CP 71 /* 3COM Etherlink Plus (3C505) */ 110 | #define NMA_C_SOFD_DP2 72 /* DPNserver-200 */ 111 | #define NMA_C_SOFD_ISA 73 /* SGEC */ 112 | #define NMA_C_SOFD_DIV 74 /* DIV-32 DEC WAN controller-100 */ 113 | #define NMA_C_SOFD_QTA 75 /* DEQTA */ 114 | #define NMA_C_SOFD_B15 76 /* LANbridge-150 */ 115 | #define NMA_C_SOFD_WD8 77 /* WD8003 Family */ 116 | #define NMA_C_SOFD_ILA 78 /* BICC ISOLAN 4110-2 */ 117 | #define NMA_C_SOFD_ILM 79 /* BICC ISOLAN 4110-3 */ 118 | #define NMA_C_SOFD_APR 80 /* Apricot Xen-S and Qi */ 119 | #define NMA_C_SOFD_ASN 81 /* AST EtherNode */ 120 | #define NMA_C_SOFD_ASE 82 /* AST Ethernet */ 121 | #define NMA_C_SOFD_TRW 83 /* TRW HC-2001 */ 122 | #define NMA_C_SOFD_EDX 84 /* Ethernet-XT/AT */ 123 | #define NMA_C_SOFD_EDA 85 /* Ethernet-AT */ 124 | #define NMA_C_SOFD_DR2 86 /* DECrouter-250 */ 125 | #define NMA_C_SOFD_SCC 87 /* DECrouter-250 DUSCC */ 126 | #define NMA_C_SOFD_DCA 88 /* DCA Series 300 */ 127 | #define NMA_C_SOFD_TIA 89 /* LANcard/E */ 128 | #define NMA_C_SOFD_FBN 90 /* DEFEB DECbridge-500 */ 129 | #define NMA_C_SOFD_FEB 91 /* DEFEB DECbridge-500 FDDI */ 130 | #define NMA_C_SOFD_FCN 92 /* DEFCN DECconcentrator-500 */ 131 | #define NMA_C_SOFD_MFA 93 /* DEMFA */ 132 | #define NMA_C_SOFD_MXE 94 /* MIPS workstation family */ 133 | #define NMA_C_SOFD_CED 95 /* Cabletron Ethernet Desktop */ 134 | #define NMA_C_SOFD_C20 96 /* 3Com CS/200 */ 135 | #define NMA_C_SOFD_CS1 97 /* 3Com CS/1 */ 136 | #define NMA_C_SOFD_C2M 98 /* 3Com CS/210, CS/2000, CS/2100 */ 137 | #define NMA_C_SOFD_ACA 99 /* ACA/32000 system */ 138 | #define NMA_C_SOFD_GSM 100 /* Gandalf StarMaster */ 139 | #define NMA_C_SOFD_DSF 101 /* DSF32 */ 140 | #define NMA_C_SOFD_CS5 102 /* 3Com CS/50 */ 141 | #define NMA_C_SOFD_XIR 103 /* XIRCOM PE10B2 */ 142 | #define NMA_C_SOFD_KFE 104 /* KFE52 */ 143 | #define NMA_C_SOFD_RT3 105 /* rtVAX-300 */ 144 | #define NMA_C_SOFD_SPI 106 /* Spiderport M250 */ 145 | #define NMA_C_SOFD_FOR 107 /* LAT gateway */ 146 | #define NMA_C_SOFD_MER 108 /* Meridian */ 147 | #define NMA_C_SOFD_PER 109 /* Persoft */ 148 | #define NMA_C_SOFD_STR 110 /* AT&T StarLan-10 */ 149 | #define NMA_C_SOFD_MPS 111 /* MIPSfair */ 150 | #define NMA_C_SOFD_L20 112 /* LPS20 print server */ 151 | #define NMA_C_SOFD_VT2 113 /* Vitalink TransLAN 320 Bridge */ 152 | #define NMA_C_SOFD_DWT 114 /* VT-1000 */ 153 | #define NMA_C_SOFD_WGB 115 /* DEWGB */ 154 | #define NMA_C_SOFD_ZEN 116 /* Zenith Z-LAN4000, Z-LAN */ 155 | #define NMA_C_SOFD_TSS 117 /* Thursby Software Systems */ 156 | #define NMA_C_SOFD_MNE 118 /* 3MIN (KN02-BA) */ 157 | #define NMA_C_SOFD_FZA 119 /* DEFZA */ 158 | #define NMA_C_SOFD_90L 120 /* DS90L */ 159 | #define NMA_C_SOFD_CIS 121 /* Cisco Systems */ 160 | #define NMA_C_SOFD_STC 122 /* STRTC */ 161 | #define NMA_C_SOFD_UBE 123 /* Ungermann-Bass PC2030, PC3030 */ 162 | #define NMA_C_SOFD_DW2 124 /* DECwindows terminal II */ 163 | #define NMA_C_SOFD_FUE 125 /* Fujitsu Etherstar MB86950 */ 164 | #define NMA_C_SOFD_M38 126 /* MUXServer 380 */ 165 | #define NMA_C_SOFD_NTI 127 /* NTI Group PC Ethernet Card */ 166 | #define NMA_C_SOFD_RAD 130 /* RADLINX LAN Gateway */ 167 | #define NMA_C_SOFD_INF 131 /* Infotron Commix */ 168 | #define NMA_C_SOFD_XMX 132 /* Xyplex MAXserver */ 169 | #define NMA_C_SOFD_NDI 133 /* NDIS data link driver for MS/DOS systems */ 170 | #define NMA_C_SOFD_ND2 134 /* NDIS data link driver for OS/2 systems */ 171 | #define NMA_C_SOFD_TRN 135 /* DEC LANcontroller 520 */ 172 | #define NMA_C_SOFD_DEV 136 /* Develcon Electronics Ltd. LAT gateway */ 173 | #define NMA_C_SOFD_ACE 137 /* Acer 5220, 5270 adapter */ 174 | #define NMA_C_SOFD_PNT 138 /* ProNet-4/18 #1390 */ 175 | #define NMA_C_SOFD_ISE 139 /* Network Integration Server 600 */ 176 | #define NMA_C_SOFD_IST 140 /* Network Integration Server 600 T1 */ 177 | #define NMA_C_SOFD_ISH 141 /* Network Integration Server 64 kb HDLC */ 178 | #define NMA_C_SOFD_ISF 142 /* Network Integration Server 600 FDDI */ 179 | #define NMA_C_SOFD_DSW 149 /* DSW-21 */ 180 | #define NMA_C_SOFD_DW4 150 /* DSW-41/42 */ 181 | #define NMA_C_SOFD_TRA 175 /* DETRA-AA */ 182 | 183 | #endif 184 | -------------------------------------------------------------------------------- /common/os.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: os-linux2.h,v 1.1 1999/03/27 14:31:22 maja Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1993-95 Mats O Jansson. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by Mats O Jansson. 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | * @(#) $OpenBSD: os-linux2.h,v 1.1 1999/03/27 14:31:22 maja Exp $ 32 | */ 33 | 34 | #include 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | 51 | #define LINUX2_PF 52 | #define SETPGRP_NOPARAM 53 | 54 | -------------------------------------------------------------------------------- /common/pf-linux2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * General Purpose AppleTalk Packet Filter Interface 3 | * 4 | * Copyright (c) 1992-1995, The University of Melbourne. 5 | * All Rights Reserved. Permission to redistribute or 6 | * use any part of this software for any purpose must 7 | * be obtained in writing from the copyright owner. 8 | * 9 | * This software is supplied "as is" without express 10 | * or implied warranty. 11 | * 12 | * djh@munnari.OZ.AU 13 | * 14 | * Supports: 15 | * Linux SOCK_PACKET 16 | * 17 | * $Author: atp $ 18 | * $Revision: 1.1.1.1 $ 19 | * 20 | * 21 | * Modified for use with the linux-mopd port by Karl Maftoum 22 | * u963870@student.canberra.edu.au 23 | * 24 | */ 25 | 26 | /* 27 | * include header files 28 | * 29 | */ 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | 44 | #define MOPDEF_SUPRESS_EXTERN 45 | #include "mopdef.h" 46 | 47 | /* 48 | * definitions 49 | * 50 | */ 51 | 52 | #define READBUFSIZ 4096 53 | #define NUMRDS 32 54 | 55 | struct RDS { 56 | u_short dataLen; 57 | u_char *dataPtr; 58 | }; 59 | 60 | /* 61 | * variables 62 | * 63 | */ 64 | 65 | struct socklist { 66 | int iflen; 67 | struct sockaddr sa; 68 | } socklist[32]; 69 | 70 | struct ifreq ifr; 71 | extern int errno; 72 | extern int promisc; 73 | 74 | struct RDS RDS[NUMRDS]; 75 | 76 | /* 77 | * Open and initialize packet filter 78 | * for a particular protocol type. 79 | * 80 | */ 81 | 82 | 83 | int 84 | pfInit(interface, mode, protocol, typ) 85 | char *interface; 86 | u_short protocol; 87 | int typ, mode; 88 | { 89 | int s; 90 | int ioarg; 91 | char device[64]; 92 | unsigned long if_flags; 93 | 94 | 95 | { u_short prot; 96 | 97 | prot = ((typ == TRANS_8023) ? htons(ETH_P_802_2) : htons(protocol)); 98 | if ((s = socket(AF_INET, SOCK_PACKET, prot)) < 0) { 99 | perror(interface); 100 | return(-1); 101 | } 102 | if (s >= 32) { 103 | close(s); 104 | return(-1); 105 | } 106 | } 107 | 108 | /* 109 | * set filter for protocol and type (IPTalk, Phase 1/2) 110 | * 111 | */ 112 | 113 | if (setup_pf(s, protocol, typ) < 0) 114 | return(-1); 115 | 116 | /* 117 | * set options, bind to underlying interface 118 | * 119 | */ 120 | 121 | strncpy(ifr.ifr_name, interface, sizeof(ifr.ifr_name)); 122 | 123 | /* record socket interface name and length */ 124 | strncpy(socklist[s].sa.sa_data, interface, sizeof(socklist[s].sa.sa_data)); 125 | socklist[s].iflen = strlen(interface); 126 | 127 | return(s); 128 | } 129 | 130 | /* 131 | * establish protocol filter 132 | * 133 | */ 134 | 135 | int 136 | setup_pf(s, prot, typ) 137 | int s, typ; 138 | u_short prot; 139 | { 140 | int ioarg; 141 | u_short offset; 142 | return(0); 143 | } 144 | 145 | /* 146 | * get the interface ethernet address 147 | * 148 | */ 149 | 150 | int 151 | pfEthAddr(s, interface, addr) 152 | int s; 153 | char *interface; 154 | u_char *addr; 155 | { 156 | strncpy(ifr.ifr_name, interface, sizeof (ifr.ifr_name) -1); 157 | ifr.ifr_name[sizeof(ifr.ifr_name)] = 0; 158 | ifr.ifr_addr.sa_family = AF_INET; 159 | if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) { 160 | perror("SIOCGIFHWADDR"); 161 | return(-1); 162 | } 163 | memcpy((char *)addr, ifr.ifr_hwaddr.sa_data, 6); 164 | return(0); 165 | } 166 | 167 | /* 168 | * add a multicast address to the interface 169 | * 170 | */ 171 | 172 | int 173 | pfAddMulti(s, interface, addr) 174 | int s; 175 | char *interface; 176 | u_char *addr; 177 | { 178 | int sock; 179 | 180 | strncpy(ifr.ifr_name, interface, sizeof (ifr.ifr_name) - 1); 181 | ifr.ifr_name[sizeof(ifr.ifr_name)] = 0; 182 | 183 | ifr.ifr_addr.sa_family = AF_UNSPEC; 184 | bcopy((char *)addr, ifr.ifr_addr.sa_data, 6); 185 | 186 | /* 187 | * open a socket, temporarily, to use for SIOC* ioctls 188 | * 189 | */ 190 | if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { 191 | perror("socket()"); 192 | return(-1); 193 | } 194 | if (ioctl(sock, SIOCADDMULTI, (caddr_t)&ifr) < 0) { 195 | perror("SIOCADDMULTI"); 196 | close(sock); 197 | return(-1); 198 | } 199 | close(sock); 200 | 201 | return(0); 202 | } 203 | 204 | /* 205 | * delete a multicast address from the interface 206 | * 207 | */ 208 | 209 | int 210 | pfDelMulti(s, interface, addr) 211 | int s; 212 | char *interface; 213 | u_char *addr; 214 | { 215 | int sock; 216 | 217 | strncpy(ifr.ifr_name, interface, sizeof (ifr.ifr_name) - 1); 218 | ifr.ifr_name[sizeof(ifr.ifr_name)] = 0; 219 | 220 | ifr.ifr_addr.sa_family = AF_UNSPEC; 221 | bcopy((char *)addr, ifr.ifr_addr.sa_data, 6); 222 | 223 | /* 224 | * open a socket, temporarily, to use for SIOC* ioctls 225 | * 226 | */ 227 | if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { 228 | perror("socket()"); 229 | return(-1); 230 | } 231 | if (ioctl(sock, SIOCDELMULTI, (caddr_t)&ifr) < 0) { 232 | perror("SIOCDELMULTI"); 233 | close(sock); 234 | return(-1); 235 | } 236 | close(sock); 237 | 238 | return(0); 239 | } 240 | 241 | /* 242 | * return 1 if ethernet interface capable of multiple opens 243 | * 244 | */ 245 | 246 | int 247 | eth_mopen(phase) 248 | int phase; 249 | { 250 | if (phase == 2) 251 | return(0); 252 | return(1); 253 | } 254 | 255 | /* 256 | * read a packet 257 | * Read Data Structure describes packet(s) received 258 | * 259 | */ 260 | 261 | 262 | 263 | 264 | int 265 | pfRead(fd, buf, len) 266 | int fd, len; 267 | u_char *buf; 268 | { 269 | int i, cc; 270 | 271 | int fromlen; 272 | struct sockaddr sa; 273 | 274 | RDS[0].dataLen = 0; 275 | fromlen = sizeof(struct sockaddr); 276 | 277 | if ((cc = recvfrom(fd, (char *)buf, len, 0, &sa, &fromlen)) <= 0) 278 | return(cc); 279 | 280 | /* check if from right interface */ 281 | for (i = socklist[fd].iflen-1; i >= 0; i--) 282 | if (sa.sa_data[i] != socklist[fd].sa.sa_data[i]) 283 | return(0); 284 | 285 | RDS[0].dataLen = cc; 286 | RDS[0].dataPtr = buf; 287 | RDS[1].dataLen = 0; 288 | 289 | return(cc); 290 | } 291 | 292 | /* 293 | * write a packet 294 | * 295 | */ 296 | 297 | int 298 | pfWrite(fd, buf, len) 299 | int fd, len; 300 | u_char *buf; 301 | { 302 | 303 | if (sendto(fd, buf, len, 0, &socklist[fd].sa, sizeof(struct sockaddr)) == len) 304 | return(len); 305 | 306 | return(-1); 307 | } 308 | 309 | /* 310 | * Return information to device.c how to open device. 311 | * In this case the driver can handle both Ethernet type II and 312 | * IEEE 802.3 frames (SNAP) in a single pfOpen. 313 | */ 314 | 315 | int 316 | pfTrans(interface) 317 | char *interface; 318 | { 319 | return TRANS_ETHER+TRANS_8023; 320 | } 321 | 322 | -------------------------------------------------------------------------------- /common/pf.c: -------------------------------------------------------------------------------- 1 | /* $NetBSD: pf.c,v 1.4 1997/10/16 23:24:55 lukem Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1993-95 Mats O Jansson. All rights reserved. 5 | * Copyright (c) 1990 The Regents of the University of California. 6 | * All rights reserved. 7 | * 8 | * This code is partly derived from rarpd. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 3. All advertising materials mentioning features or use of this software 19 | * must display the following acknowledgement: 20 | * This product includes software developed by Mats O Jansson. 21 | * 4. The name of the author may not be used to endorse or promote products 22 | * derived from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 25 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 26 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 27 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 29 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 30 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 31 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 33 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #include 37 | #ifndef lint 38 | __RCSID("$NetBSD: pf.c,v 1.4 1997/10/16 23:24:55 lukem Exp $"); 39 | #endif 40 | 41 | #include "os.h" 42 | 43 | #include 44 | #include 45 | 46 | #include "mopdef.h" 47 | #include "pf.h" 48 | 49 | /* 50 | * Variables 51 | */ 52 | 53 | extern int promisc; 54 | 55 | /* 56 | * Return information to device.c how to open device. 57 | * In this case the driver can handle both Ethernet type II and 58 | * IEEE 802.3 frames (SNAP) in a single pfOpen. 59 | */ 60 | 61 | int 62 | pfTrans(interface) 63 | char *interface; 64 | { 65 | return TRANS_ETHER+TRANS_8023+TRANS_AND; 66 | } 67 | 68 | /* 69 | * Open and initialize packet filter. 70 | */ 71 | 72 | int 73 | pfInit(interface, mode, protocol, typ) 74 | char *interface; 75 | u_short protocol; 76 | int typ, mode; 77 | { 78 | int fd; 79 | int n = 0; 80 | char device[sizeof "/dev/bpf000"]; 81 | struct ifreq ifr; 82 | u_int dlt; 83 | int immediate; 84 | 85 | static struct bpf_insn insns[] = { 86 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 12), 87 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x4711, 4, 0), 88 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 20), 89 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x4711, 0, 3), 90 | BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 14), 91 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0xaaaa, 0, 1), 92 | BPF_STMT(BPF_RET | BPF_K, 1520), 93 | BPF_STMT(BPF_RET | BPF_K, 0), 94 | }; 95 | static struct bpf_program filter = { 96 | sizeof insns / sizeof(insns[0]), 97 | insns 98 | }; 99 | 100 | /* Go through all the minors and find one that isn't in use. */ 101 | do { 102 | (void) sprintf(device, "/dev/bpf%d", n++); 103 | fd = open(device, mode); 104 | } while (fd < 0 && errno == EBUSY); 105 | 106 | if (fd < 0) { 107 | syslog(LOG_ERR,"pfInit: open %s: %m", device); 108 | return(-1); 109 | } 110 | 111 | /* Set immediate mode so packets are processed as they arrive. */ 112 | immediate = 1; 113 | if (ioctl(fd, BIOCIMMEDIATE, &immediate) < 0) { 114 | syslog(LOG_ERR,"pfInit: BIOCIMMEDIATE: %m"); 115 | return(-1); 116 | } 117 | (void) strncpy(ifr.ifr_name, interface, sizeof ifr.ifr_name); 118 | if (ioctl(fd, BIOCSETIF, (caddr_t) & ifr) < 0) { 119 | syslog(LOG_ERR,"pfInit: BIOCSETIF: %m"); 120 | return(-1); 121 | } 122 | /* Check that the data link layer is an Ethernet; this code won't work 123 | * with anything else. */ 124 | if (ioctl(fd, BIOCGDLT, (caddr_t) & dlt) < 0) { 125 | syslog(LOG_ERR,"pfInit: BIOCGDLT: %m"); 126 | return(-1); 127 | } 128 | if (dlt != DLT_EN10MB) { 129 | syslog(LOG_ERR,"pfInit: %s is not ethernet", device); 130 | return(-1); 131 | } 132 | if (promisc) { 133 | /* Set promiscuous mode. */ 134 | if (ioctl(fd, BIOCPROMISC, (caddr_t)0) < 0) { 135 | syslog(LOG_ERR,"pfInit: BIOCPROMISC: %m"); 136 | return(-1); 137 | } 138 | } 139 | /* Set filter program. */ 140 | insns[1].k = protocol; 141 | insns[3].k = protocol; 142 | 143 | if (ioctl(fd, BIOCSETF, (caddr_t) & filter) < 0) { 144 | syslog(LOG_ERR,"pfInit: BIOCSETF: %m"); 145 | return(-1); 146 | } 147 | return(fd); 148 | } 149 | 150 | /* 151 | * Add a Multicast address to the interface 152 | */ 153 | 154 | int 155 | pfAddMulti(s, interface, addr) 156 | int s; 157 | char *interface, *addr; 158 | { 159 | struct ifreq ifr; 160 | int fd; 161 | 162 | strcpy(ifr.ifr_name, interface); 163 | 164 | ifr.ifr_addr.sa_family = AF_UNSPEC; 165 | memmove(ifr.ifr_addr.sa_data, addr, 6); 166 | 167 | /* 168 | * open a socket, temporarily, to use for SIOC* ioctls 169 | * 170 | */ 171 | if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { 172 | syslog(LOG_ERR, "pfAddMulti: socket: %m"); 173 | return(-1); 174 | } 175 | if (ioctl(fd, SIOCADDMULTI, (caddr_t)&ifr) < 0) { 176 | syslog(LOG_ERR, "pfAddMulti: SIOCADDMULTI: %m"); 177 | close(fd); 178 | return(-1); 179 | } 180 | close(fd); 181 | 182 | return(0); 183 | } 184 | 185 | /* 186 | * Delete a Multicast address from the interface 187 | */ 188 | 189 | int 190 | pfDelMulti(s, interface, addr) 191 | int s; 192 | char *interface, *addr; 193 | { 194 | struct ifreq ifr; 195 | int fd; 196 | 197 | strcpy(ifr.ifr_name, interface); 198 | 199 | ifr.ifr_addr.sa_family = AF_UNSPEC; 200 | memmove(ifr.ifr_addr.sa_data, addr, 6); 201 | 202 | /* 203 | * open a socket, temporarily, to use for SIOC* ioctls 204 | * 205 | */ 206 | if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { 207 | syslog(LOG_ERR, "pfDelMulti: socket: %m"); 208 | return(-1); 209 | } 210 | if (ioctl(fd, SIOCDELMULTI, (caddr_t)&ifr) < 0) { 211 | syslog(LOG_ERR, "pfAddMulti: SIOCDELMULTI: %m"); 212 | close(fd); 213 | return(-1); 214 | } 215 | close(fd); 216 | 217 | return(0); 218 | } 219 | 220 | /* 221 | * read a packet 222 | */ 223 | 224 | int 225 | pfRead(fd, buf, len) 226 | int fd, len; 227 | u_char *buf; 228 | { 229 | return(read(fd, buf, len)); 230 | } 231 | 232 | /* 233 | * write a packet 234 | */ 235 | 236 | int 237 | pfWrite(fd, buf, len, trans) 238 | int fd, len, trans; 239 | u_char *buf; 240 | { 241 | 242 | struct iovec iov[2]; 243 | 244 | switch (trans) { 245 | case TRANS_8023: 246 | iov[0].iov_base = (caddr_t)buf; 247 | iov[0].iov_len = 22; 248 | iov[1].iov_base = (caddr_t)buf+22; 249 | iov[1].iov_len = len-22; 250 | break; 251 | default: 252 | iov[0].iov_base = (caddr_t)buf; 253 | iov[0].iov_len = 14; 254 | iov[1].iov_base = (caddr_t)buf+14; 255 | iov[1].iov_len = len-14; 256 | break; 257 | } 258 | 259 | if (writev(fd, iov, 2) == len) 260 | return(len); 261 | 262 | return(-1); 263 | } 264 | 265 | -------------------------------------------------------------------------------- /common/pf.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: pf.h,v 1.2 1997/03/25 03:07:29 thorpej Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1993-95 Mats O Jansson. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by Mats O Jansson. 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | * $NetBSD: pf.h,v 1.2 1997/03/25 03:07:29 thorpej Exp $ 32 | * 33 | */ 34 | 35 | #ifndef _PF_H_ 36 | #define _PF_H_ 37 | 38 | __BEGIN_DECLS 39 | int pfTrans __P((char *)); 40 | int pfInit __P((char *, int, u_short, int)); 41 | int pfEthAddr __P((int, u_char *)); 42 | int pfAddMulti __P((int, char *, char *)); 43 | int pfDelMulti __P((int, char *, char *)); 44 | int pfRead __P((int, u_char *, int)); 45 | int pfWrite __P((int, u_char *, int, int)); 46 | __END_DECLS 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /common/print.c: -------------------------------------------------------------------------------- 1 | /* $NetBSD: print.c,v 1.2 1997/03/25 03:07:30 thorpej Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1993-96 Mats O Jansson. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by Mats O Jansson. 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | #ifndef lint 34 | static char rcsid[]="$NetBSD: print.c,v 1.2 1997/03/25 03:07:30 thorpej Exp $"; 35 | #endif 36 | 37 | #include 38 | #include 39 | 40 | #include "os.h" 41 | #include "cmp.h" 42 | #include "get.h" 43 | #include "mopdef.h" 44 | #include "nma.h" 45 | #include "nmadef.h" 46 | #include "print.h" 47 | 48 | #define SHORT_PRINT 49 | 50 | void 51 | mopPrintHWA(fd, ap) 52 | FILE *fd; 53 | u_char *ap; 54 | { 55 | (void)fprintf(fd, "%x:%x:%x:%x:%x:%x", 56 | ap[0],ap[1],ap[2],ap[3],ap[4],ap[5]); 57 | if (ap[0] < 10) (void)fprintf(fd, " "); 58 | if (ap[1] < 10) (void)fprintf(fd, " "); 59 | if (ap[2] < 10) (void)fprintf(fd, " "); 60 | if (ap[3] < 10) (void)fprintf(fd, " "); 61 | if (ap[4] < 10) (void)fprintf(fd, " "); 62 | if (ap[5] < 10) (void)fprintf(fd, " "); 63 | } 64 | 65 | void 66 | mopPrintBPTY(fd, bpty) 67 | FILE *fd; 68 | u_char bpty; 69 | { 70 | switch(bpty) { 71 | case MOP_K_BPTY_SYS: 72 | (void)fprintf(fd, "System Processor"); 73 | break; 74 | case MOP_K_BPTY_COM: 75 | (void)fprintf(fd, "Communication Processor"); 76 | break; 77 | default: 78 | (void)fprintf(fd, "Unknown"); 79 | break; 80 | }; 81 | }; 82 | 83 | void 84 | mopPrintPGTY(fd, pgty) 85 | FILE *fd; 86 | u_char pgty; 87 | { 88 | switch(pgty) { 89 | case MOP_K_PGTY_SECLDR: 90 | (void)fprintf(fd, "Secondary Loader"); 91 | break; 92 | case MOP_K_PGTY_TERLDR: 93 | (void)fprintf(fd, "Tertiary Loader"); 94 | break; 95 | case MOP_K_PGTY_OPRSYS: 96 | (void)fprintf(fd, "Operating System"); 97 | break; 98 | case MOP_K_PGTY_MGNTFL: 99 | (void)fprintf(fd, "Management File"); 100 | break; 101 | default: 102 | (void)fprintf(fd, "Unknown"); 103 | break; 104 | }; 105 | } 106 | 107 | void 108 | mopPrintOneline(fd, pkt, trans) 109 | FILE *fd; 110 | u_char *pkt; 111 | int trans; 112 | { 113 | int index = 0; 114 | u_char *dst, *src, code; 115 | u_short proto; 116 | int len; 117 | 118 | trans = mopGetTrans(pkt, trans); 119 | mopGetHeader(pkt, &index, &dst, &src, &proto, &len, trans); 120 | code = mopGetChar(pkt, &index); 121 | 122 | switch (proto) { 123 | case MOP_K_PROTO_DL: 124 | (void)fprintf(fd, "MOP DL "); 125 | break; 126 | case MOP_K_PROTO_RC: 127 | (void)fprintf(fd, "MOP RC "); 128 | break; 129 | case MOP_K_PROTO_LP: 130 | (void)fprintf(fd, "MOP LP "); 131 | break; 132 | default: 133 | switch((proto % 256)*256 + (proto / 256)) { 134 | case MOP_K_PROTO_DL: 135 | (void)fprintf(fd, "MOP DL "); 136 | proto = MOP_K_PROTO_DL; 137 | break; 138 | case MOP_K_PROTO_RC: 139 | (void)fprintf(fd, "MOP RC "); 140 | proto = MOP_K_PROTO_RC; 141 | break; 142 | case MOP_K_PROTO_LP: 143 | (void)fprintf(fd, "MOP LP "); 144 | proto = MOP_K_PROTO_LP; 145 | break; 146 | default: 147 | (void)fprintf(fd, "MOP ?? "); 148 | break; 149 | } 150 | } 151 | 152 | if (trans == TRANS_8023) { 153 | (void)fprintf(fd, "802.3 "); 154 | } 155 | 156 | mopPrintHWA(fd, src); (void)fprintf(fd," > "); 157 | mopPrintHWA(fd, dst); 158 | if (len < 1600) { 159 | (void)fprintf(fd, " len %4d code %02x ",len,code); 160 | } else { 161 | (void)fprintf(fd, " len %4d code %02x ", 162 | (len % 256)*256 + (len /256), code); 163 | } 164 | 165 | switch (proto) { 166 | case MOP_K_PROTO_DL: 167 | switch (code) { 168 | case MOP_K_CODE_MLT: 169 | (void)fprintf(fd, "MLT "); 170 | break; 171 | case MOP_K_CODE_DCM: 172 | (void)fprintf(fd, "DCM "); 173 | break; 174 | case MOP_K_CODE_MLD: 175 | (void)fprintf(fd, "MLD "); 176 | break; 177 | case MOP_K_CODE_ASV: 178 | (void)fprintf(fd, "ASV "); 179 | break; 180 | case MOP_K_CODE_RMD: 181 | (void)fprintf(fd, "RMD "); 182 | break; 183 | case MOP_K_CODE_RPR: 184 | (void)fprintf(fd, "RPR "); 185 | break; 186 | case MOP_K_CODE_RML: 187 | (void)fprintf(fd, "RML "); 188 | break; 189 | case MOP_K_CODE_RDS: 190 | (void)fprintf(fd, "RDS "); 191 | break; 192 | case MOP_K_CODE_MDD: 193 | (void)fprintf(fd, "MDD "); 194 | break; 195 | case MOP_K_CODE_PLT: 196 | (void)fprintf(fd, "PLT "); 197 | break; 198 | default: 199 | (void)fprintf(fd, "??? "); 200 | break; 201 | } 202 | break; 203 | case MOP_K_PROTO_RC: 204 | switch (code) { 205 | case MOP_K_CODE_RID: 206 | (void)fprintf(fd, "RID "); 207 | break; 208 | case MOP_K_CODE_BOT: 209 | (void)fprintf(fd, "BOT "); 210 | break; 211 | case MOP_K_CODE_SID: 212 | (void)fprintf(fd, "SID "); 213 | break; 214 | case MOP_K_CODE_RQC: 215 | (void)fprintf(fd, "RQC "); 216 | break; 217 | case MOP_K_CODE_CNT: 218 | (void)fprintf(fd, "CNT "); 219 | break; 220 | case MOP_K_CODE_RVC: 221 | (void)fprintf(fd, "RVC "); 222 | break; 223 | case MOP_K_CODE_RLC: 224 | (void)fprintf(fd, "RLC "); 225 | break; 226 | case MOP_K_CODE_CCP: 227 | (void)fprintf(fd, "CCP "); 228 | break; 229 | case MOP_K_CODE_CRA: 230 | (void)fprintf(fd, "CRA "); 231 | break; 232 | default: 233 | (void)fprintf(fd, "??? "); 234 | break; 235 | } 236 | break; 237 | case MOP_K_PROTO_LP: 238 | switch (code) { 239 | case MOP_K_CODE_ALD: 240 | (void)fprintf(fd, "ALD "); 241 | break; 242 | case MOP_K_CODE_PLD: 243 | (void)fprintf(fd, "PLD "); 244 | break; 245 | default: 246 | (void)fprintf(fd, "??? "); 247 | break; 248 | } 249 | break; 250 | default: 251 | (void)fprintf(fd, "??? "); 252 | break; 253 | } 254 | (void)fprintf(fd, "\n"); 255 | } 256 | 257 | void 258 | mopPrintHeader(fd, pkt, trans) 259 | FILE *fd; 260 | u_char *pkt; 261 | int trans; 262 | { 263 | u_char *dst, *src; 264 | u_short proto; 265 | int len, index = 0; 266 | 267 | trans = mopGetTrans(pkt, trans); 268 | mopGetHeader(pkt, &index, &dst, &src, &proto, &len, trans); 269 | 270 | (void)fprintf(fd,"\nDst : "); 271 | mopPrintHWA(fd, dst); 272 | if (mopCmpEAddr(dl_mcst,dst) == 0) { 273 | (void)fprintf(fd," MOP Dump/Load Multicast"); 274 | }; 275 | if (mopCmpEAddr(rc_mcst,dst) == 0) { 276 | (void)fprintf(fd," MOP Remote Console Multicast"); 277 | }; 278 | (void)fprintf(fd,"\n"); 279 | 280 | (void)fprintf(fd,"Src : "); 281 | mopPrintHWA(fd, src); 282 | (void)fprintf(fd,"\n"); 283 | (void)fprintf(fd,"Proto : %04x ",proto); 284 | switch (proto) { 285 | case MOP_K_PROTO_DL: 286 | switch (trans) { 287 | case TRANS_8023: 288 | (void)fprintf(fd, "MOP Dump/Load (802.3)\n"); 289 | break; 290 | default: 291 | (void)fprintf(fd, "MOP Dump/Load\n"); 292 | } 293 | break; 294 | case MOP_K_PROTO_RC: 295 | switch (trans) { 296 | case TRANS_8023: 297 | (void)fprintf(fd, "MOP Remote Console (802.3)\n"); 298 | break; 299 | default: 300 | (void)fprintf(fd, "MOP Remote Console\n"); 301 | } 302 | break; 303 | case MOP_K_PROTO_LP: 304 | switch (trans) { 305 | case TRANS_8023: 306 | (void)fprintf(fd, "MOP Loopback (802.3)\n"); 307 | break; 308 | default: 309 | (void)fprintf(fd, "MOP Loopback\n"); 310 | } 311 | break; 312 | default: 313 | (void)fprintf(fd, "\n"); 314 | break; 315 | } 316 | 317 | 318 | (void)fprintf(fd,"Length : %04x (%d)\n",len,len); 319 | } 320 | 321 | void 322 | mopPrintMopHeader(fd, pkt, trans) 323 | FILE *fd; 324 | u_char *pkt; 325 | int trans; 326 | { 327 | u_char *dst, *src; 328 | u_short proto; 329 | int len, index = 0; 330 | u_char code; 331 | 332 | trans = mopGetTrans(pkt, trans); 333 | mopGetHeader(pkt, &index, &dst, &src, &proto, &len, trans); 334 | 335 | code = mopGetChar(pkt, &index); 336 | 337 | (void)fprintf(fd, "Code : %02x ",code); 338 | 339 | switch (proto) { 340 | case MOP_K_PROTO_DL: 341 | switch (code) { 342 | case MOP_K_CODE_MLT: 343 | (void)fprintf(fd, 344 | "Memory Load with transfer address\n"); 345 | break; 346 | case MOP_K_CODE_DCM: 347 | (void)fprintf(fd, "Dump Complete\n"); 348 | break; 349 | case MOP_K_CODE_MLD: 350 | (void)fprintf(fd, "Memory Load\n"); 351 | break; 352 | case MOP_K_CODE_ASV: 353 | (void)fprintf(fd, "Assistance volunteer\n"); 354 | break; 355 | case MOP_K_CODE_RMD: 356 | (void)fprintf(fd, "Request memory dump\n"); 357 | break; 358 | case MOP_K_CODE_RPR: 359 | (void)fprintf(fd, "Request program\n"); 360 | break; 361 | case MOP_K_CODE_RML: 362 | (void)fprintf(fd, "Request memory load\n"); 363 | break; 364 | case MOP_K_CODE_RDS: 365 | (void)fprintf(fd, "Request Dump Service\n"); 366 | break; 367 | case MOP_K_CODE_MDD: 368 | (void)fprintf(fd, "Memory dump data\n"); 369 | break; 370 | case MOP_K_CODE_PLT: 371 | (void)fprintf(fd, 372 | "Parameter load with transfer addres\n"); 373 | break; 374 | default: 375 | (void)fprintf(fd, "(unknown)\n"); 376 | break; 377 | } 378 | break; 379 | case MOP_K_PROTO_RC: 380 | switch (code) { 381 | case MOP_K_CODE_RID: 382 | (void)fprintf(fd, "Request ID\n"); 383 | break; 384 | case MOP_K_CODE_BOT: 385 | (void)fprintf(fd, "Boot\n"); 386 | break; 387 | case MOP_K_CODE_SID: 388 | (void)fprintf(fd, "System ID\n"); 389 | break; 390 | case MOP_K_CODE_RQC: 391 | (void)fprintf(fd, "Request Counters\n"); 392 | break; 393 | case MOP_K_CODE_CNT: 394 | (void)fprintf(fd, "Counters\n"); 395 | break; 396 | case MOP_K_CODE_RVC: 397 | (void)fprintf(fd, "Reserve Console\n"); 398 | break; 399 | case MOP_K_CODE_RLC: 400 | (void)fprintf(fd, "Release Console\n"); 401 | break; 402 | case MOP_K_CODE_CCP: 403 | (void)fprintf(fd, "Console Command and Poll\n"); 404 | break; 405 | case MOP_K_CODE_CRA: 406 | (void)fprintf(fd, 407 | "Console Response and Acknnowledge\n"); 408 | break; 409 | default: 410 | (void)fprintf(fd, "(unknown)\n"); 411 | break; 412 | } 413 | break; 414 | case MOP_K_PROTO_LP: 415 | switch (code) { 416 | case MOP_K_CODE_ALD: 417 | (void)fprintf(fd, "Active loop data\n"); 418 | break; 419 | case MOP_K_CODE_PLD: 420 | (void)fprintf(fd, "Passive looped data\n"); 421 | break; 422 | default: 423 | (void)fprintf(fd, "(unknown)\n"); 424 | break; 425 | } 426 | break; 427 | default: 428 | (void)fprintf(fd, "(unknown)\n"); 429 | break; 430 | } 431 | } 432 | 433 | void 434 | mopPrintDevice(fd, device) 435 | FILE *fd; 436 | u_char device; 437 | { 438 | char *sname, *name; 439 | 440 | sname = nmaGetShort((int) device); 441 | name = nmaGetDevice((int) device); 442 | 443 | (void)fprintf(fd, "%s '%s'",sname,name); 444 | } 445 | 446 | void 447 | mopPrintTime(fd, ap) 448 | FILE *fd; 449 | u_char *ap; 450 | { 451 | (void)fprintf(fd, 452 | "%04d-%02d-%02d %02d:%02d:%02d.%02d %d:%02d", 453 | ap[0]*100 + ap[1], 454 | ap[2],ap[3],ap[4],ap[5],ap[6],ap[7],ap[8],ap[9]); 455 | } 456 | 457 | void 458 | mopPrintInfo(fd, pkt, index, moplen, mopcode, trans) 459 | FILE *fd; 460 | u_char *pkt, mopcode; 461 | int *index, trans; 462 | u_short moplen; 463 | { 464 | u_short itype,tmps; 465 | u_char ilen ,tmpc,device; 466 | u_char uc1,uc2,uc3,*ucp; 467 | int i; 468 | 469 | device = 0; 470 | 471 | switch(trans) { 472 | case TRANS_ETHER: 473 | moplen = moplen + 16; 474 | break; 475 | case TRANS_8023: 476 | moplen = moplen + 14; 477 | break; 478 | } 479 | 480 | itype = mopGetShort(pkt,index); 481 | 482 | while (*index < (int)(moplen + 2)) { 483 | ilen = mopGetChar(pkt,index); 484 | switch (itype) { 485 | case 0: 486 | tmpc = mopGetChar(pkt,index); 487 | *index = *index + tmpc; 488 | break; 489 | case MOP_K_INFO_VER: 490 | uc1 = mopGetChar(pkt,index); 491 | uc2 = mopGetChar(pkt,index); 492 | uc3 = mopGetChar(pkt,index); 493 | (void)fprintf(fd,"Maint Version: %d.%d.%d\n", 494 | uc1,uc2,uc3); 495 | break; 496 | case MOP_K_INFO_MFCT: 497 | tmps = mopGetShort(pkt,index); 498 | (void)fprintf(fd,"Maint Funcion: %04x ( ",tmps); 499 | if (tmps & 1) (void)fprintf(fd, "Loop "); 500 | if (tmps & 2) (void)fprintf(fd, "Dump "); 501 | if (tmps & 4) (void)fprintf(fd, "Pldr "); 502 | if (tmps & 8) (void)fprintf(fd, "MLdr "); 503 | if (tmps & 16) (void)fprintf(fd, "Boot "); 504 | if (tmps & 32) (void)fprintf(fd, "CC "); 505 | if (tmps & 64) (void)fprintf(fd, "DLC "); 506 | if (tmps & 128) (void)fprintf(fd, "CCR "); 507 | (void)fprintf(fd, ")\n"); 508 | break; 509 | case MOP_K_INFO_CNU: 510 | ucp = pkt + *index; *index = *index + 6; 511 | (void)fprintf(fd,"Console User : "); 512 | mopPrintHWA(fd, ucp); 513 | (void)fprintf(fd, "\n"); 514 | break; 515 | case MOP_K_INFO_RTM: 516 | tmps = mopGetShort(pkt,index); 517 | (void)fprintf(fd,"Reserv Timer : %04x (%d)\n", 518 | tmps,tmps); 519 | break; 520 | case MOP_K_INFO_CSZ: 521 | tmps = mopGetShort(pkt,index); 522 | (void)fprintf(fd,"Cons Cmd Size: %04x (%d)\n", 523 | tmps,tmps); 524 | break; 525 | case MOP_K_INFO_RSZ: 526 | tmps = mopGetShort(pkt,index); 527 | (void)fprintf(fd,"Cons Res Size: %04x (%d)\n", 528 | tmps,tmps); 529 | break; 530 | case MOP_K_INFO_HWA: 531 | ucp = pkt + *index; *index = *index + 6; 532 | (void)fprintf(fd,"Hardware Addr: "); 533 | mopPrintHWA(fd, ucp); 534 | (void)fprintf(fd, "\n"); 535 | break; 536 | case MOP_K_INFO_TIME: 537 | ucp = pkt + *index; *index = *index + 10; 538 | (void)fprintf(fd,"System Time: "); 539 | mopPrintTime(fd, ucp); 540 | (void)fprintf(fd,"\n"); 541 | break; 542 | case MOP_K_INFO_SOFD: 543 | device = mopGetChar(pkt,index); 544 | (void)fprintf(fd,"Comm Device : %02x ",device); 545 | mopPrintDevice(fd, device); 546 | (void)fprintf(fd, "\n"); 547 | break; 548 | case MOP_K_INFO_SFID: 549 | tmpc = mopGetChar(pkt,index); 550 | (void)fprintf(fd,"Software ID : %02x ",tmpc); 551 | if ((tmpc == 0)) { 552 | (void)fprintf(fd,"No software id"); 553 | } 554 | if ((tmpc == 254)) { 555 | (void)fprintf(fd,"Maintenance system"); 556 | tmpc = 0; 557 | } 558 | if ((tmpc == 255)) { 559 | (void)fprintf(fd,"Standard operating system"); 560 | tmpc = 0; 561 | } 562 | if ((tmpc > 0)) { 563 | (void)fprintf(fd,"'"); 564 | for (i = 0; i < ((int) tmpc); i++) { 565 | (void)fprintf(fd,"%c", 566 | mopGetChar(pkt,index)); 567 | } 568 | (void)fprintf(fd,"'"); 569 | } 570 | (void)fprintf(fd,"\n"); 571 | break; 572 | case MOP_K_INFO_PRTY: 573 | tmpc = mopGetChar(pkt,index); 574 | (void)fprintf(fd,"System Proc : %02x ",tmpc); 575 | switch (tmpc) { 576 | case MOP_K_PRTY_11: 577 | (void)fprintf(fd, "PDP-11\n"); 578 | break; 579 | case MOP_K_PRTY_CMSV: 580 | (void)fprintf(fd, 581 | "Communication Server\n"); 582 | break; 583 | case MOP_K_PRTY_PRO: 584 | (void)fprintf(fd, "Professional\n"); 585 | break; 586 | case MOP_K_PRTY_SCO: 587 | (void)fprintf(fd, "Scorpio\n"); 588 | break; 589 | case MOP_K_PRTY_AMB: 590 | (void)fprintf(fd, "Amber\n"); 591 | break; 592 | case MOP_K_PRTY_BRI: 593 | (void)fprintf(fd, "XLII Bridge\n"); 594 | break; 595 | default: 596 | (void)fprintf(fd, "Unknown\n"); 597 | break; 598 | }; 599 | break; 600 | case MOP_K_INFO_DLTY: 601 | tmpc = mopGetChar(pkt,index); 602 | (void)fprintf(fd,"Data Link Typ: %02x ",tmpc); 603 | switch (tmpc) { 604 | case MOP_K_DLTY_NI: 605 | (void)fprintf(fd, "Ethernet\n"); 606 | break; 607 | case MOP_K_DLTY_DDCMP: 608 | (void)fprintf(fd, "DDCMP\n"); 609 | break; 610 | case MOP_K_DLTY_LAPB: 611 | (void)fprintf(fd, "LAPB (X.25)\n"); 612 | break; 613 | default: 614 | (void)fprintf(fd, "Unknown\n"); 615 | break; 616 | }; 617 | break; 618 | case MOP_K_INFO_DLBSZ: 619 | tmps = mopGetShort(pkt,index); 620 | (void)fprintf(fd,"DL Buff Size : %04x (%d)\n", 621 | tmps,tmps); 622 | break; 623 | default: 624 | if (((device = NMA_C_SOFD_LCS) || /* DECserver 100 */ 625 | (device = NMA_C_SOFD_DS2) || /* DECserver 200 */ 626 | (device = NMA_C_SOFD_DP2) || /* DECserver 250 */ 627 | (device = NMA_C_SOFD_DS3)) && /* DECserver 300 */ 628 | ((itype > 101) && (itype < 107))) 629 | { 630 | switch (itype) { 631 | case 102: 632 | ucp = pkt + *index; 633 | *index = *index + ilen; 634 | (void)fprintf(fd, 635 | "ROM Sftwr Ver: %02x '", 636 | ilen); 637 | for (i = 0; i < ilen; i++) { 638 | (void)fprintf(fd,"%c",ucp[i]); 639 | } 640 | (void)fprintf(fd, "'\n"); 641 | break; 642 | case 103: 643 | ucp = pkt + *index; 644 | *index = *index + ilen; 645 | (void)fprintf(fd, 646 | "Software Ver : %02x '", 647 | ilen); 648 | for (i = 0; i < ilen; i++) { 649 | (void)fprintf(fd, "%c",ucp[i]); 650 | } 651 | (void)fprintf(fd, "'\n"); 652 | break; 653 | case 104: 654 | tmps = mopGetShort(pkt,index); 655 | (void)fprintf(fd, 656 | "DECnet Addr : %d.%d (%d)\n", 657 | tmps / 1024, 658 | tmps % 1024, 659 | tmps); 660 | break; 661 | case 105: 662 | ucp = pkt + *index; 663 | *index = *index + ilen; 664 | (void)fprintf(fd, 665 | "Node Name : %02x '", 666 | ilen); 667 | for (i = 0; i < ilen; i++) { 668 | (void)fprintf(fd, "%c",ucp[i]); 669 | } 670 | (void)fprintf(fd, "'\n"); 671 | break; 672 | case 106: 673 | ucp = pkt + *index; 674 | *index = *index + ilen; 675 | (void)fprintf(fd, 676 | "Node Ident : %02x '", 677 | ilen); 678 | for (i = 0; i < ilen; i++) { 679 | (void)fprintf(fd, "%c",ucp[i]); 680 | } 681 | (void)fprintf(fd, "'\n"); 682 | break; 683 | }; 684 | } else { 685 | ucp = pkt + *index; *index = *index + ilen; 686 | (void)fprintf(fd, "Info Type : %04x (%d)\n", 687 | itype, 688 | itype); 689 | (void)fprintf(fd, "Info Data : %02x ", 690 | ilen); 691 | for (i = 0; i < ilen; i++) { 692 | if ((i % 16) == 0) { 693 | if ((i / 16) == 0) { 694 | } else { 695 | (void)fprintf(fd, 696 | "\n "); 697 | }; 698 | }; 699 | (void)fprintf(fd, "%02x ",ucp[i]); 700 | } 701 | (void)fprintf(fd, "\n"); 702 | }; 703 | } 704 | itype = mopGetShort(pkt,index); 705 | } 706 | } 707 | 708 | -------------------------------------------------------------------------------- /common/print.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: print.h,v 1.2 1997/03/25 03:07:31 thorpej Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1993-95 Mats O Jansson. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by Mats O Jansson. 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | * $NetBSD: print.h,v 1.2 1997/03/25 03:07:31 thorpej Exp $ 32 | * 33 | */ 34 | 35 | #ifndef _PRINT_H_ 36 | #define _PRINT_H_ 37 | 38 | __BEGIN_DECLS 39 | void mopPrintHWA __P((FILE *, u_char *)); 40 | void mopPrintBPTY __P((FILE *, u_char)); 41 | void mopPrintPGTY __P((FILE *, u_char)); 42 | void mopPrintOneline __P((FILE *, u_char *, int)); 43 | void mopPrintHeader __P((FILE *, u_char *, int)); 44 | void mopPrintMopHeader __P((FILE *, u_char *, int)); 45 | void mopPrintDevice __P((FILE *, u_char)); 46 | void mopPrintTime __P((FILE *, u_char *)); 47 | void mopPrintInfo __P((FILE *, u_char *, int *, u_short, 48 | u_char, int)); 49 | __END_DECLS 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /common/put.c: -------------------------------------------------------------------------------- 1 | /* $NetBSD: put.c,v 1.2 1997/03/25 03:07:33 thorpej Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1993-95 Mats O Jansson. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by Mats O Jansson. 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | #ifndef lint 34 | static char rcsid[]="$NetBSD: put.c,v 1.2 1997/03/25 03:07:33 thorpej Exp $"; 35 | #endif 36 | 37 | #include "os.h" 38 | #include "mopdef.h" 39 | #include "put.h" 40 | 41 | void 42 | mopPutChar(pkt, index, value) 43 | u_char *pkt; 44 | int *index; 45 | u_char value; 46 | { 47 | pkt[*index] = value; 48 | *index = *index + 1; 49 | } 50 | 51 | void 52 | mopPutShort(pkt, index, value) 53 | u_char *pkt; 54 | int *index; 55 | u_short value; 56 | { 57 | int i; 58 | for (i = 0; i < 2; i++) { 59 | pkt[*index+i] = value % 256; 60 | value = value / 256; 61 | } 62 | *index = *index + 2; 63 | } 64 | 65 | void 66 | mopPutLong(pkt, index, value) 67 | u_char *pkt; 68 | int *index; 69 | u_int32_t value; 70 | { 71 | int i; 72 | for (i = 0; i < 4; i++) { 73 | pkt[*index+i] = value % 256; 74 | value = value / 256; 75 | } 76 | *index = *index + 4; 77 | } 78 | 79 | void 80 | mopPutMulti(pkt, index, value, size) 81 | u_char *pkt,*value; 82 | int *index,size; 83 | { 84 | int i; 85 | 86 | for (i = 0; i < size; i++) { 87 | pkt[*index+i] = value[i]; 88 | } 89 | *index = *index + size; 90 | } 91 | 92 | void 93 | mopPutTime(pkt, index, value) 94 | u_char *pkt; 95 | int *index; 96 | time_t value; 97 | { 98 | time_t tnow; 99 | struct tm *timenow; 100 | 101 | if ((value == 0)) { 102 | tnow = time(NULL); 103 | } else { 104 | tnow = value; 105 | } 106 | 107 | timenow = localtime(&tnow); 108 | 109 | mopPutChar (pkt,index,10); 110 | mopPutChar (pkt,index,(timenow->tm_year / 100) + 19); 111 | mopPutChar (pkt,index,(timenow->tm_year % 100)); 112 | mopPutChar (pkt,index,(timenow->tm_mon + 1)); 113 | mopPutChar (pkt,index,(timenow->tm_mday)); 114 | mopPutChar (pkt,index,(timenow->tm_hour)); 115 | mopPutChar (pkt,index,(timenow->tm_min)); 116 | mopPutChar (pkt,index,(timenow->tm_sec)); 117 | mopPutChar (pkt,index,0x00); 118 | mopPutChar (pkt,index,0x00); 119 | mopPutChar (pkt,index,0x00); 120 | } 121 | 122 | void 123 | mopPutHeader(pkt, index, dst, src, proto, trans) 124 | u_char *pkt; 125 | int *index; 126 | u_char dst[], src[]; 127 | u_short proto; 128 | int trans; 129 | { 130 | 131 | mopPutMulti(pkt, index, dst, 6); 132 | mopPutMulti(pkt, index, src, 6); 133 | if (trans == TRANS_8023) { 134 | mopPutShort(pkt, index, 0); 135 | mopPutChar (pkt, index, MOP_K_PROTO_802_DSAP); 136 | mopPutChar (pkt, index, MOP_K_PROTO_802_SSAP); 137 | mopPutChar (pkt, index, MOP_K_PROTO_802_CNTL); 138 | mopPutChar (pkt, index, 0x08); 139 | mopPutChar (pkt, index, 0x00); 140 | mopPutChar (pkt, index, 0x2b); 141 | } 142 | #if !defined(__FreeBSD__) 143 | mopPutChar(pkt, index, (proto / 256)); 144 | mopPutChar(pkt, index, (proto % 256)); 145 | #else 146 | if (trans == TRANS_8023) { 147 | mopPutChar(pkt, index, (proto / 256)); 148 | mopPutChar(pkt, index, (proto % 256)); 149 | } else { 150 | mopPutChar(pkt, index, (proto % 256)); 151 | mopPutChar(pkt, index, (proto / 256)); 152 | } 153 | #endif 154 | if (trans == TRANS_ETHER) 155 | mopPutShort(pkt, index, 0); 156 | 157 | } 158 | 159 | void 160 | mopPutLength(pkt, trans, len) 161 | u_char *pkt; 162 | int trans; 163 | u_short len; 164 | { 165 | int index = 0; 166 | 167 | switch(trans) { 168 | case TRANS_ETHER: 169 | index = 14; 170 | mopPutChar(pkt, &index, ((len - 16) % 256)); 171 | mopPutChar(pkt, &index, ((len - 16) / 256)); 172 | break; 173 | case TRANS_8023: 174 | index = 12; 175 | #if !defined(__FreeBSD__) 176 | mopPutChar(pkt, &index, ((len - 14) / 256)); 177 | mopPutChar(pkt, &index, ((len - 14) % 256)); 178 | #else 179 | mopPutChar(pkt, &index, ((len - 14) % 256)); 180 | mopPutChar(pkt, &index, ((len - 14) / 256)); 181 | #endif 182 | break; 183 | } 184 | 185 | } 186 | -------------------------------------------------------------------------------- /common/put.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: put.h,v 1.2 1997/03/25 03:07:34 thorpej Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1993-95 Mats O Jansson. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by Mats O Jansson. 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | * $NetBSD: put.h,v 1.2 1997/03/25 03:07:34 thorpej Exp $ 32 | * 33 | */ 34 | 35 | #ifndef _PUT_H_ 36 | #define _PUT_H_ 37 | 38 | __BEGIN_DECLS 39 | void mopPutChar __P((u_char *, int *, u_char)); 40 | void mopPutShort __P((u_char *, int *, u_short)); 41 | void mopPutLong __P((u_char *, int *, u_int32_t)); 42 | void mopPutMulti __P((u_char *, int *, u_char *, int)); 43 | void mopPutTime __P((u_char *, int *, time_t)); 44 | void mopPutHeader __P((u_char *, int *, u_char *, u_char *, u_short, int)); 45 | void mopPutLength __P((u_char *, int, u_short)); 46 | __END_DECLS 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /common/rc.c: -------------------------------------------------------------------------------- 1 | /* $NetBSD: rc.c,v 1.2 1997/03/25 03:07:35 thorpej Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1993-95 Mats O Jansson. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by Mats O Jansson. 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | #ifndef lint 34 | static char rcsid[]="$NetBSD: rc.c,v 1.2 1997/03/25 03:07:35 thorpej Exp $"; 35 | #endif 36 | 37 | #include "os.h" 38 | #include "get.h" 39 | #include "mopdef.h" 40 | #include "print.h" 41 | #include "rc.h" 42 | 43 | void 44 | mopDumpRC(fd, pkt, trans) 45 | FILE *fd; 46 | u_char *pkt; 47 | int trans; 48 | { 49 | int i,index = 0; 50 | int32_t tmpl; 51 | u_char tmpc,code,control; 52 | u_short len,tmps,moplen; 53 | 54 | len = mopGetLength(pkt, trans); 55 | 56 | switch (trans) { 57 | case TRANS_8023: 58 | index = 22; 59 | moplen = len - 8; 60 | break; 61 | default: 62 | index = 16; 63 | moplen = len; 64 | } 65 | code = mopGetChar(pkt,&index); 66 | /* see above, if (len < 8) then moplen ends up around 65535 */ 67 | if (moplen > len) moplen = len; 68 | 69 | switch (code) { 70 | case MOP_K_CODE_RID: 71 | 72 | tmpc = mopGetChar(pkt,&index); 73 | (void)fprintf(fd,"Reserved : %02x\n",tmpc); 74 | 75 | tmps = mopGetShort(pkt,&index); 76 | (void)fprintf(fd,"Receipt Nbr : %04x\n",tmps); 77 | 78 | break; 79 | case MOP_K_CODE_BOT: 80 | 81 | if ((moplen == 5)) { 82 | tmps = mopGetShort(pkt,&index); 83 | (void)fprintf(fd,"Verification : %04x\n",tmps); 84 | } else { 85 | 86 | tmpl = mopGetLong(pkt,&index); 87 | (void)fprintf(fd,"Verification : %08x\n",tmpl); 88 | 89 | tmpc = mopGetChar(pkt,&index); /* Processor */ 90 | (void)fprintf(fd,"Processor : %02x ",tmpc); 91 | mopPrintBPTY(fd, tmpc); (void)fprintf(fd, "\n"); 92 | 93 | control = mopGetChar(pkt,&index); /* Control */ 94 | (void)fprintf(fd,"Control : %02x ",control); 95 | if ((control & (1>>MOP_K_BOT_CNTL_SERVER))) { 96 | (void)fprintf(fd, 97 | "Bootserver Requesting system "); 98 | } else { 99 | (void)fprintf(fd, 100 | "Bootserver System default "); 101 | } 102 | if ((control & (1>>MOP_K_BOT_CNTL_DEVICE))) { 103 | (void)fprintf(fd, 104 | "Bootdevice Specified device"); 105 | } else { 106 | (void)fprintf(fd, 107 | "Bootdevice System default"); 108 | } 109 | (void)fprintf(fd,"\n"); 110 | 111 | if ((control & (1>>MOP_K_BOT_CNTL_DEVICE))) { 112 | tmpc = mopGetChar(pkt,&index);/* Device ID */ 113 | (void)fprintf(fd, 114 | "Device ID : %02x '",tmpc); 115 | for (i = 0; i < ((int) tmpc); i++) { 116 | (void)fprintf(fd,"%c", 117 | mopGetChar(pkt,&index)); 118 | } 119 | (void)fprintf(fd,"'\n"); 120 | } 121 | 122 | tmpc = mopGetChar(pkt,&index); /* Software ID */ 123 | (void)fprintf(fd,"Software ID : %02x ",tmpc); 124 | if ((tmpc == 0)) { 125 | (void)fprintf(fd,"No software id"); 126 | } 127 | if ((tmpc == 254)) { 128 | (void)fprintf(fd,"Maintenance system"); 129 | tmpc = 0; 130 | } 131 | if ((tmpc == 255)) { 132 | (void)fprintf(fd,"Standard operating system"); 133 | tmpc = 0; 134 | } 135 | if ((tmpc > 0)) { 136 | (void)fprintf(fd,"'"); 137 | for (i = 0; i < ((int) tmpc); i++) { 138 | (void)fprintf(fd,"%c", 139 | mopGetChar(pkt,&index)); 140 | } 141 | (void)fprintf(fd,"'"); 142 | } 143 | (void)fprintf(fd,"'\n"); 144 | 145 | } 146 | break; 147 | case MOP_K_CODE_SID: 148 | 149 | tmpc = mopGetChar(pkt,&index); /* Reserved */ 150 | (void)fprintf(fd, "Reserved : %02x\n",tmpc); 151 | 152 | tmps = mopGetShort(pkt,&index); /* Receipt # */ 153 | (void)fprintf(fd, "Receipt Nbr : %04x\n",tmpc); 154 | 155 | mopPrintInfo(fd, pkt, &index, moplen, code, trans); 156 | 157 | break; 158 | case MOP_K_CODE_RQC: 159 | 160 | tmps = mopGetShort(pkt,&index); 161 | (void)fprintf(fd,"Receipt Nbr : %04x\n",tmps); 162 | 163 | break; 164 | case MOP_K_CODE_CNT: 165 | 166 | tmps = mopGetShort(pkt,&index); 167 | (void)fprintf(fd,"Receipt Nbr : %04x %d\n",tmps,tmps); 168 | 169 | tmps = mopGetShort(pkt,&index); 170 | (void)fprintf(fd,"Last Zeroed : %04x %d\n",tmps,tmps); 171 | 172 | tmpl = mopGetLong(pkt,&index); 173 | (void)fprintf(fd,"Bytes rec : %08x %d\n",tmpl,tmpl); 174 | 175 | tmpl = mopGetLong(pkt,&index); 176 | (void)fprintf(fd,"Bytes snd : %08x %d\n",tmpl,tmpl); 177 | 178 | tmpl = mopGetLong(pkt,&index); 179 | (void)fprintf(fd,"Frames rec : %08x %d\n",tmpl,tmpl); 180 | 181 | tmpl = mopGetLong(pkt,&index); 182 | (void)fprintf(fd,"Frames snd : %08x %d\n",tmpl,tmpl); 183 | 184 | tmpl = mopGetLong(pkt,&index); 185 | (void)fprintf(fd,"Mcst Bytes re: %08x %d\n",tmpl,tmpl); 186 | 187 | tmpl = mopGetLong(pkt,&index); 188 | (void)fprintf(fd,"Mcst Frame re: %08x %d\n",tmpl,tmpl); 189 | 190 | tmpl = mopGetLong(pkt,&index); 191 | (void)fprintf(fd,"Frame snd,def: %08x %d\n",tmpl,tmpl); 192 | 193 | tmpl = mopGetLong(pkt,&index); 194 | (void)fprintf(fd,"Frame snd,col: %08x %d\n",tmpl,tmpl); 195 | 196 | tmpl = mopGetLong(pkt,&index); 197 | (void)fprintf(fd,"Frame snd,mcl: %08x %d\n",tmpl,tmpl); 198 | 199 | tmps = mopGetShort(pkt,&index); 200 | (void)fprintf(fd,"Snd failure : %04x %d\n",tmps,tmps); 201 | 202 | tmps = mopGetShort(pkt,&index); 203 | (void)fprintf(fd,"Snd fail reas: %04x ",tmps); 204 | if ((tmps & 1)) (void)fprintf(fd,"Excess col "); 205 | if ((tmps & 2)) (void)fprintf(fd,"Carrier chk fail "); 206 | if ((tmps & 4)) (void)fprintf(fd,"Short circ "); 207 | if ((tmps & 8)) (void)fprintf(fd,"Open circ "); 208 | if ((tmps & 16)) (void)fprintf(fd,"Frm to long "); 209 | if ((tmps & 32)) (void)fprintf(fd,"Rem fail to defer "); 210 | (void)fprintf(fd,"\n"); 211 | 212 | tmps = mopGetShort(pkt,&index); 213 | (void)fprintf(fd,"Rec failure : %04x %d\n",tmps,tmps); 214 | 215 | tmps = mopGetShort(pkt,&index); 216 | (void)fprintf(fd,"Rec fail reas: %04x ",tmps); 217 | if ((tmps & 1)) (void)fprintf(fd,"Block chk err "); 218 | if ((tmps & 2)) (void)fprintf(fd,"Framing err "); 219 | if ((tmps & 4)) (void)fprintf(fd,"Frm to long "); 220 | (void)fprintf(fd,"\n"); 221 | 222 | tmps = mopGetShort(pkt,&index); 223 | (void)fprintf(fd,"Unrec frm dst: %04x %d\n",tmps,tmps); 224 | 225 | tmps = mopGetShort(pkt,&index); 226 | (void)fprintf(fd,"Data overrun : %04x %d\n",tmps,tmps); 227 | 228 | tmps = mopGetShort(pkt,&index); 229 | (void)fprintf(fd,"Sys Buf Unava: %04x %d\n",tmps,tmps); 230 | 231 | tmps = mopGetShort(pkt,&index); 232 | (void)fprintf(fd,"Usr Buf Unava: %04x %d\n",tmps,tmps); 233 | 234 | break; 235 | case MOP_K_CODE_RVC: 236 | 237 | tmpl = mopGetLong(pkt,&index); 238 | (void)fprintf(fd,"Verification : %08x\n",tmpl); 239 | 240 | break; 241 | case MOP_K_CODE_RLC: 242 | 243 | /* Empty message */ 244 | 245 | break; 246 | case MOP_K_CODE_CCP: 247 | 248 | tmpc = mopGetChar(pkt,&index); 249 | (void)fprintf(fd, 250 | "Control Flags: %02x Message %d ",tmpc,tmpc & 1); 251 | if ((tmpc & 2)) 252 | (void)fprintf(fd,"Break"); 253 | (void)fprintf(fd,"\n"); 254 | 255 | if (moplen > 2) { 256 | #ifndef SHORT_PRINT 257 | for (i = 0; i < (moplen - 2); i++) { 258 | if ((i % 16) == 0) { 259 | if ((i / 16) == 0) { 260 | (void)fprintf(fd, 261 | "Image Data : %04x ", 262 | moplen-2); 263 | } else { 264 | (void)fprintf(fd, 265 | " "); 266 | } 267 | } 268 | (void)fprintf(fd,"%02x ", 269 | mopGetChar(pkt,&index)); 270 | if ((i % 16) == 15) 271 | (void)fprintf(fd,"\n"); 272 | } 273 | if ((i % 16) != 15) 274 | (void)fprintf(fd,"\n"); 275 | #else 276 | index = index + moplen - 2; 277 | #endif 278 | } 279 | 280 | break; 281 | case MOP_K_CODE_CRA: 282 | 283 | tmpc = mopGetChar(pkt,&index); 284 | (void)fprintf(fd, 285 | "Control Flags: %02x Message %d ",tmpc,tmpc & 1); 286 | if ((tmpc & 2)) 287 | (void)fprintf(fd,"Cmd Data Lost "); 288 | if ((tmpc & 4)) 289 | (void)fprintf(fd,"Resp Data Lost "); 290 | (void)fprintf(fd,"\n"); 291 | 292 | if (moplen > 2) { 293 | #ifndef SHORT_PRINT 294 | for (i = 0; i < (moplen - 2); i++) { 295 | if ((i % 16) == 0) { 296 | if ((i / 16) == 0) { 297 | (void)fprintf(fd, 298 | "Image Data : %04x ", 299 | moplen-2); 300 | } else { 301 | (void)fprintf(fd, 302 | " "); 303 | } 304 | } 305 | (void)fprintf(fd,"%02x ", 306 | mopGetChar(pkt,&index)); 307 | if ((i % 16) == 15) 308 | (void)fprintf(fd,"\n"); 309 | } 310 | if ((i % 16) != 15) 311 | (void)fprintf(fd,"\n"); 312 | #else 313 | index = index + moplen - 2; 314 | #endif 315 | } 316 | 317 | break; 318 | default: 319 | break; 320 | } 321 | } 322 | 323 | -------------------------------------------------------------------------------- /common/rc.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: rc.h,v 1.2 1997/03/25 03:07:36 thorpej Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1993-95 Mats O Jansson. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by Mats O Jansson. 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | * $NetBSD: rc.h,v 1.2 1997/03/25 03:07:36 thorpej Exp $ 32 | * 33 | */ 34 | 35 | #ifndef _RC_H_ 36 | #define _RC_H_ 37 | 38 | __BEGIN_DECLS 39 | void mopDumpRC __P((FILE *, u_char *, int)); 40 | __END_DECLS 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /mopa.out/Makefile: -------------------------------------------------------------------------------- 1 | # $NetBSD: Makefile,v 1.4 1997/04/17 21:09:02 christos Exp $ 2 | 3 | PROG= mopa.out 4 | 5 | .include 6 | -------------------------------------------------------------------------------- /mopa.out/mopa.out.1: -------------------------------------------------------------------------------- 1 | .\" $NetBSD: mopa.out.1,v 1.2 1997/03/25 03:07:39 thorpej Exp $ 2 | .\" 3 | .\" Copyright (c) 1996 Mats O Jansson. All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 3. All advertising materials mentioning features or use of this software 14 | .\" must display the following acknowledgement: 15 | .\" This product includes software developed by Mats O Jansson. 16 | .\" 4. The name of the author may not be used to endorse or promote products 17 | .\" derived from this software without specific prior written permission. 18 | .\" 19 | .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | .\" 30 | .Dd August 11, 1996 31 | .Dt MOPA.OUT 1 32 | .Sh NAME 33 | .Nm mopa.out 34 | .Nd Create MOP image from a a.out file 35 | .Sh SYNOPSIS 36 | .Nm 37 | .Ar infile 38 | .Ar outfile 39 | .Sh DESCRIPTION 40 | .Nm 41 | is used to convert an a.out file to a MOP-image. 42 | .Pp 43 | This program will check if 44 | .Xr a.out 5 45 | machine-id is recognized. If not it will try to swap the 46 | .Xr a.out 5 47 | header, and try again. 48 | .Sh BUGS 49 | This program only supports the VAX machine-id for now. 50 | .Sh SEE ALSO 51 | .Xr a.out 5 , 52 | .Xr mopchk 1 , 53 | .Xr mopd 8 , 54 | .Xr mopprobe 1 , 55 | .Xr moptrace 1 56 | .Sh AUTHORS 57 | Lloyd Parkes. 58 | 59 | -------------------------------------------------------------------------------- /mopa.out/mopa.out.c: -------------------------------------------------------------------------------- 1 | /* $NetBSD: mopa.out.c,v 1.5 1997/10/16 23:25:09 lukem Exp $ */ 2 | 3 | /* mopa.out - Convert a Unix format kernel into something that 4 | * can be transfered via MOP. 5 | * 6 | * This code was written while refering to the NetBSD/vax boot 7 | * loader. Therefore anything that can be booted by the Vax 8 | * should be convertable with this program. 9 | * 10 | * If necessary, the a.out header is stripped, and the program 11 | * segments are padded out. The BSS segment is zero filled. 12 | * A header is prepended that looks like an IHD header. In 13 | * particular the Unix mahine ID is placed where mopd expects 14 | * the image type to be (offset is IHD_W_ALIAS). If the machine 15 | * ID could be mistaken for a DEC image type, then the conversion 16 | * is aborted. The original a.out header is copied into the front 17 | * of the header so that once we have detected the Unix machine 18 | * ID we can haul the load address and the xfer address out. 19 | */ 20 | 21 | /* 22 | * Copyright (c) 1996 Lloyd Parkes. All rights reserved. 23 | * 24 | * Redistribution and use in source and binary forms, with or without 25 | * modification, are permitted provided that the following conditions 26 | * are met: 27 | * 1. Redistributions of source code must retain the above copyright 28 | * notice, this list of conditions and the following disclaimer. 29 | * 2. Redistributions in binary form must reproduce the above copyright 30 | * notice, this list of conditions and the following disclaimer in the 31 | * documentation and/or other materials provided with the distribution. 32 | * 3. All advertising materials mentioning features or use of this software 33 | * must display the following acknowledgement: 34 | * This product includes software developed by Lloyd Parkes. 35 | * 4. The name of the author may not be used to endorse or promote products 36 | * derived from this software without specific prior written permission. 37 | * 38 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 39 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 40 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 41 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 42 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 43 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 44 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 45 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 46 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 47 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 48 | */ 49 | 50 | #include 51 | #ifndef lint 52 | __RCSID("$NetBSD: mopa.out.c,v 1.5 1997/10/16 23:25:09 lukem Exp $"); 53 | #endif 54 | 55 | #include "os.h" 56 | #include "common/common.h" 57 | #include "common/mopdef.h" 58 | #include "common/file.h" 59 | #if defined(__NetBSD__) || defined(__OpenBSD__) 60 | #include 61 | #endif 62 | #if defined(__FreeBSD__) 63 | #include 64 | #endif 65 | #if defined(__bsdi__) || defined(__Linux__) 66 | #include 67 | #define NOAOUT 68 | #endif 69 | #if !defined(MID_VAX) 70 | #define MID_VAX 140 71 | #endif 72 | 73 | u_char header[512]; /* The VAX header we generate is 1 block. */ 74 | struct exec ex, ex_swap; 75 | 76 | int 77 | main (int argc, char **argv) 78 | { 79 | FILE *out; /* A FILE because that is easier. */ 80 | int i; 81 | struct dllist dl; 82 | 83 | extern char *__progname; /* from crt0.o */ 84 | 85 | #ifdef NOAOUT 86 | errx(1, "has no function in NetBSD"); 87 | #endif 88 | 89 | if (argc != 3) { 90 | fprintf (stderr, "usage: %s kernel-in sys-out\n", __progname); 91 | return (1); 92 | } 93 | 94 | dl.ldfd = open (argv[1], O_RDONLY); 95 | if (dl.ldfd == -1) 96 | err(2, "open `%s'", argv[1]); 97 | 98 | GetFileInfo(dl.ldfd, 99 | &dl.loadaddr, 100 | &dl.xferaddr, 101 | &dl.aout, 102 | &dl.a_text,&dl.a_text_fill, 103 | &dl.a_data,&dl.a_data_fill, 104 | &dl.a_bss ,&dl.a_bss_fill ); 105 | 106 | if (dl.aout == -1) 107 | errx(3, "`%s' is not an a.out file", argv[1]); 108 | 109 | if (dl.aout != MID_VAX) 110 | printf("WARNING: `%s' is not a VAX image (mid=%d)\n", 111 | argv[1], dl.aout); 112 | 113 | i = dl.a_text + dl.a_text_fill + dl.a_data + dl.a_data_fill + 114 | dl.a_bss + dl.a_bss_fill; 115 | i = (i+1) / 512; 116 | 117 | dl.nloadaddr = dl.loadaddr; 118 | dl.lseek = lseek(dl.ldfd,0L,SEEK_CUR); 119 | dl.a_lseek = 0; 120 | dl.count = 0; 121 | dl.dl_bsz = 512; 122 | 123 | mopFilePutLX(header,IHD_W_SIZE,0xd4,2); /* Offset to ISD section. */ 124 | mopFilePutLX(header,IHD_W_ACTIVOFF,0x30,2);/* Offset to 1st section.*/ 125 | mopFilePutLX(header,IHD_W_ALIAS,IHD_C_NATIVE,2);/* It's a VAX image.*/ 126 | mopFilePutLX(header,IHD_B_HDRBLKCNT,1,1); /* Only one header block. */ 127 | mopFilePutLX(header,0x30+IHA_L_TFRADR1,dl.xferaddr,4); /* Xfer Addr */ 128 | mopFilePutLX(header,0xd4+ISD_W_PAGCNT,i,2);/* Imagesize in blks.*/ 129 | 130 | out = fopen (argv[2], "w"); 131 | if (!out) 132 | err(2, "writing `%s'", argv[2]); 133 | 134 | /* Now we do the actual work. Write VAX MOP-image header */ 135 | 136 | fwrite (header, sizeof (header), 1, out); 137 | 138 | fprintf(stderr, "copying %u+%u+%u->%u\n", dl.a_text, 139 | dl.a_data, dl.a_bss, dl.xferaddr); 140 | 141 | while ((i = mopFileRead(&dl,header)) > 0) { 142 | (void)fwrite(header, i, 1, out); 143 | } 144 | 145 | fclose (out); 146 | return (0); 147 | } 148 | -------------------------------------------------------------------------------- /mopchk/Makefile: -------------------------------------------------------------------------------- 1 | OBJS=mopchk.o 2 | INCL=-I../ -I../common 3 | LIBS=../common/libcommon.a 4 | 5 | all: mopchk 6 | 7 | mopchk: ${OBJS} version.o $(LIBS) 8 | cc -o mopchk version.o ${OBJS} ${LIBS} 9 | 10 | .c.o: .c 11 | cc -c $(CFLAGS) ${INCL} $< 12 | 13 | clean: 14 | rm -f *.o *~ mopchk VERSION version.* 15 | 16 | version.o: version.c 17 | version.c version.h: 18 | ln -sf ../common/VERSION VERSION 19 | rm -f version.c ; sed 's/.*/char version[] = "&";/' VERSION > version.c 20 | set `sed 's/\([0-9]*\)\.\([0-9]*\).*/\1 \2/' VERSION` ; \ 21 | { echo '#define VERSION_MAJOR' $$1 ; \ 22 | echo '#define VERSION_MINOR' $$2 ; } > version.h 23 | 24 | -------------------------------------------------------------------------------- /mopchk/mopchk.1: -------------------------------------------------------------------------------- 1 | .\" $NetBSD: mopchk.1,v 1.4 1998/09/30 15:05:01 briggs Exp $ 2 | .\" 3 | .\" Copyright (c) 1996 Mats O Jansson. All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 3. All advertising materials mentioning features or use of this software 14 | .\" must display the following acknowledgement: 15 | .\" This product includes software developed by Mats O Jansson. 16 | .\" 4. The name of the author may not be used to endorse or promote products 17 | .\" derived from this software without specific prior written permission. 18 | .\" 19 | .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | .\" 30 | .Dd October 2, 1995 31 | .Dt MOPCHK 1 32 | .Sh NAME 33 | .Nm mopchk 34 | .Nd MOP Check Utility 35 | .Sh SYNOPSIS 36 | .Nm 37 | .Op Fl a 38 | .Op Fl v 39 | .Op Ar filename 40 | .Sh DESCRIPTION 41 | .Nm 42 | shows information about which devices are known, version of mopd suite or 43 | information about a MOP-image. 44 | .Pp 45 | If 46 | .Ar filename 47 | is given, information about the MOP-image is read from the header of the 48 | file. 49 | .Sh OPTIONS 50 | .Bl -tag -width indent 51 | .It Fl a 52 | Show all the Ethernets attached to the system. 53 | .It Fl v 54 | Show version of the mopd suite. 55 | .El 56 | .Sh BUGS 57 | In some implementations the same interface can occur more than once. 58 | .Sh SEE ALSO 59 | .Xr mopa.out 1 , 60 | .Xr mopprobe 1 , 61 | .Xr moptrace 1 , 62 | .Xr mopd 8 63 | .Sh AUTHORS 64 | Mats O Jansson (moj@stacken.kth.se). 65 | -------------------------------------------------------------------------------- /mopchk/mopchk.c: -------------------------------------------------------------------------------- 1 | /* $NetBSD: mopchk.c,v 1.5 1997/10/16 07:36:50 lukem Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1995-96 Mats O Jansson. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by Mats O Jansson. 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | #ifndef lint 34 | /*__RCSID("$NetBSD: mopchk.c,v 1.5 1997/10/16 07:36:50 lukem Exp $");*/ 35 | #endif 36 | 37 | /* 38 | * mopchk - MOP Check Utility 39 | * 40 | * Usage: mopchk [-a] [-v] [filename...] 41 | */ 42 | 43 | #include "os.h" 44 | #include "common/common.h" 45 | #include "common/device.h" 46 | #include "common/file.h" 47 | #include "common/mopdef.h" 48 | #include "common/pf.h" 49 | 50 | /* 51 | * The list of all interfaces that are being listened to. rarp_loop() 52 | * "selects" on the descriptors in this list. 53 | */ 54 | struct if_info *iflist; 55 | 56 | void Usage __P((void)); 57 | int main __P((int, char **)); 58 | void mopProcess __P((struct if_info *, u_char *)); 59 | 60 | int AllFlag = 0; /* listen on "all" interfaces */ 61 | int VersionFlag = 0; /* Show version */ 62 | int promisc = 0; /* promisc mode not needed */ 63 | 64 | extern char *__progname; /* from crt0.o */ 65 | extern char version[]; 66 | 67 | int 68 | main(argc, argv) 69 | int argc; 70 | char **argv; 71 | { 72 | int op, i, fd; 73 | char *filename; 74 | struct if_info *ii; 75 | int err, aout; 76 | 77 | /* All error reporting is done through syslogs. */ 78 | openlog(__progname, LOG_PID | LOG_CONS, LOG_DAEMON); 79 | 80 | opterr = 0; 81 | while ((op = getopt(argc, argv, "av")) != -1) { 82 | switch (op) { 83 | case 'a': 84 | AllFlag++; 85 | break; 86 | case 'v': 87 | VersionFlag++; 88 | break; 89 | default: 90 | Usage(); 91 | /* NOTREACHED */ 92 | } 93 | } 94 | 95 | if (VersionFlag) 96 | printf("%s: Version %s\n", __progname, version); 97 | 98 | if (AllFlag) { 99 | if (VersionFlag) 100 | printf("\n"); 101 | iflist = NULL; 102 | deviceInitAll(); 103 | if (iflist == NULL) 104 | printf("No interface\n"); 105 | else { 106 | printf("Interface Address\n"); 107 | for (ii = iflist; ii; ii = ii->next) 108 | printf("%-9s %x:%x:%x:%x:%x:%x\n", 109 | ii->if_name, ii->eaddr[0], ii->eaddr[1], 110 | ii->eaddr[2], ii->eaddr[3], ii->eaddr[4], 111 | ii->eaddr[5]); 112 | } 113 | } 114 | 115 | if (VersionFlag || AllFlag) 116 | i = 1; 117 | else 118 | i = 0; 119 | 120 | while (argc > optind) { 121 | if (i) printf("\n"); 122 | i++; 123 | filename = argv[optind++]; 124 | printf("Checking: %s\n", filename); 125 | fd = open(filename, O_RDONLY, 0); 126 | if (fd == -1) 127 | printf("Unknown file.\n"); 128 | else { 129 | err = CheckAOutFile(fd); 130 | if (err == 0) { 131 | if (GetAOutFileInfo(fd, 0, 0, 0, 0, 132 | 0, 0, 0, 0, &aout) < 0) { 133 | printf( 134 | "Some failure in GetAOutFileInfo\n"); 135 | aout = -1; 136 | } 137 | } else 138 | aout = -1; 139 | if (aout == -1) 140 | err = CheckMopFile(fd); 141 | if (aout == -1 && err == 0) 142 | if (GetMopFileInfo(fd, 0, 0) < 0) 143 | printf( 144 | "Some failure in GetMopFileInfo\n"); 145 | } 146 | } 147 | return (0); 148 | } 149 | 150 | void 151 | Usage() 152 | { 153 | (void) fprintf(stderr, "usage: %s [-a] [-v] [filename...]\n", 154 | __progname); 155 | exit(1); 156 | } 157 | 158 | /* 159 | * Process incomming packages. 160 | * Doesn't actually do anything for mopchk(1) 161 | */ 162 | void 163 | mopProcess(ii, pkt) 164 | struct if_info *ii; 165 | u_char *pkt; 166 | { 167 | } 168 | -------------------------------------------------------------------------------- /mopd/Makefile: -------------------------------------------------------------------------------- 1 | OBJS=mopd.o process.o 2 | INCL=-I../ -I../common 3 | LIBS=../common/libcommon.a 4 | 5 | all: mopd 6 | 7 | mopd: ${OBJS} version.o $(LIBS) 8 | cc -o mopd version.o ${OBJS} ${LIBS} 9 | 10 | .c.o: .c 11 | cc -c $(CFLAGS) ${INCL} $< 12 | 13 | clean: 14 | rm -f *.o *~ mopd VERSION version.* 15 | 16 | version.o: version.c 17 | version.c version.h: 18 | ln -sf ../common/VERSION VERSION 19 | rm -f version.c ; sed 's/.*/char version[] = "&";/' VERSION > version.c 20 | set `sed 's/\([0-9]*\)\.\([0-9]*\).*/\1 \2/' VERSION` ; \ 21 | { echo '#define VERSION_MAJOR' $$1 ; \ 22 | echo '#define VERSION_MINOR' $$2 ; } > version.h 23 | 24 | -------------------------------------------------------------------------------- /mopd/TODO: -------------------------------------------------------------------------------- 1 | Change code to send hostname instead of 'ipc'. 2 | -------------------------------------------------------------------------------- /mopd/mopd.8: -------------------------------------------------------------------------------- 1 | .\" $NetBSD: mopd.8,v 1.2 1997/03/25 03:07:48 thorpej Exp $ 2 | .\" 3 | .\" Copyright (c) 1993-96 Mats O Jansson. All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 3. All advertising materials mentioning features or use of this software 14 | .\" must display the following acknowledgement: 15 | .\" This product includes software developed by Mats O Jansson. 16 | .\" 4. The name of the author may not be used to endorse or promote products 17 | .\" derived from this software without specific prior written permission. 18 | .\" 19 | .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | .\" 30 | .Dd September 24, 1995 31 | .Dt MOPD 8 32 | .Sh NAME 33 | .Nm mopd 34 | .Nd MOP Loader Daemon 35 | .Sh SYNOPSIS 36 | .Nm 37 | .Op Fl adf 38 | .Op Ar interface 39 | .Sh DESCRIPTION 40 | .Nm 41 | services MOP Load requests on the Ethernet connected to 42 | .Ar interface 43 | or all interfaces if 44 | .Sq Fl a 45 | is given. 46 | In a load request received by 47 | .Nm 48 | a filename can be given. This is the normal case for e.g. terminal servers. 49 | If a filename isn't given 50 | .Nm 51 | must know what image to load. 52 | .Pp 53 | Upon receiving a request, 54 | .Nm 55 | checks if the requested file exists in 56 | .Pa /tftpboot/mop , 57 | the filename is normaly uppercase and with an extension of 58 | .Pa .SYS . 59 | If the filename isn't given, the ethernet address of the target is used as 60 | filename, e.g. 61 | .Pa 08002b09f4de.SYS 62 | and it might be a soft link to another file. 63 | .Pp 64 | .Nm 65 | supports two kinds of files. The first type that is check is if the file is 66 | in 67 | .Xr a.out 5 68 | format. If not, a couple of Digital's formats are checked. 69 | .Pp 70 | In normal operation, 71 | .Nm 72 | forks a copy of itself and runs in 73 | the background. Anomalies and errors are reported via 74 | .Xr syslog 3 . 75 | .Sh OPTIONS 76 | .Bl -tag -width indent 77 | .It Fl a 78 | Listen on all the Ethernets attached to the system. 79 | If 80 | .Sq Fl a 81 | is omitted, an interface must be specified. 82 | .It Fl d 83 | Run in debug mode, with all the output to stdout. The process will run in 84 | the foreground. 85 | .It Fl f 86 | Run in the foreground. 87 | .El 88 | .Sh FILES 89 | .Bl -tag -width Pa -compact 90 | .It Pa /tftpboot/mop 91 | .El 92 | .Sh SEE ALSO 93 | .Xr bpf 4 , 94 | .Xr mopa.out 1 , 95 | .Xr mopchk 1 , 96 | .Xr mopprobe 1 , 97 | .Xr moptrace 1 98 | .Rs 99 | DECnet Digital Network Architecture Phase IV, 100 | .%R Maintenance Operations Functional Specification V3.0.0 101 | .%N AA-X436A-TK 102 | .Re 103 | .Rs 104 | DECnet Digital Network Architecture, 105 | .%R Maintenance Operations Protocol Functional Specification V4.0.0 106 | .%N EK-DNA11-FS-001 107 | .Re 108 | .Sh AUTHORS 109 | Mats O Jansson (moj@stacken.kth.se). 110 | -------------------------------------------------------------------------------- /mopd/mopd.c: -------------------------------------------------------------------------------- 1 | /* $NetBSD: mopd.c,v 1.5 1997/10/16 23:25:17 lukem Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1993-96 Mats O Jansson. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by Mats O Jansson. 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | #ifndef lint 34 | /*__RCSID("$NetBSD: mopd.c,v 1.5 1997/10/16 23:25:17 lukem Exp $");*/ 35 | #endif 36 | 37 | /* 38 | * mopd - MOP Dump/Load Daemon 39 | * 40 | * Usage: mopd -a [ -d -f -v ] [ -3 | -4 ] 41 | * mopd [ -d -f -v ] [ -3 | -4 ] interface 42 | */ 43 | 44 | #include "common/os.h" 45 | #include "common/cmp.h" 46 | #include "common/common.h" 47 | #include "common/device.h" 48 | #include "common/dl.h" 49 | #include "common/get.h" 50 | #include "common/mopdef.h" 51 | #include "common/pf.h" 52 | #include "common/print.h" 53 | #include "process.h" 54 | #include "common/rc.h" 55 | 56 | #ifndef __linux__ 57 | #include 58 | #else 59 | #define pidfile(x) x; 60 | #endif 61 | 62 | /* 63 | * The list of all interfaces that are being listened to. 64 | * "selects" on the descriptors in this list. 65 | */ 66 | struct if_info *iflist; 67 | 68 | void Usage __P((void)); 69 | int main __P((int, char **)); 70 | void mopProcess __P((struct if_info *, u_char *)); 71 | 72 | int AllFlag = 0; /* listen on "all" interfaces */ 73 | int DebugFlag = 0; /* print debugging messages */ 74 | int ForegroundFlag = 0; /* run in foreground */ 75 | int VersionFlag = 0; /* print version */ 76 | int Not3Flag = 0; /* Not MOP V3 messages. */ 77 | int Not4Flag = 0; /* Not MOP V4 messages. */ 78 | int promisc = 1; /* Need promisc mode */ 79 | 80 | extern char *__progname; /* from crt0.o */ 81 | 82 | int 83 | main(argc, argv) 84 | int argc; 85 | char **argv; 86 | { 87 | int c, pid; 88 | char *interface; 89 | 90 | extern char version[]; 91 | 92 | while ((c = getopt(argc, argv, "34adfv")) != -1) 93 | switch (c) { 94 | case '3': 95 | Not3Flag++; 96 | break; 97 | case '4': 98 | Not4Flag++; 99 | break; 100 | case 'a': 101 | AllFlag++; 102 | break; 103 | case 'd': 104 | DebugFlag++; 105 | break; 106 | case 'f': 107 | ForegroundFlag++; 108 | break; 109 | case 'v': 110 | VersionFlag++; 111 | break; 112 | default: 113 | Usage(); 114 | /* NOTREACHED */ 115 | } 116 | 117 | if (VersionFlag) { 118 | fprintf(stdout,"%s: version %s\n", __progname, version); 119 | exit(0); 120 | } 121 | 122 | interface = argv[optind++]; 123 | 124 | if ((AllFlag && interface) || 125 | (!AllFlag && interface == 0) || 126 | (argc > optind) || 127 | (Not3Flag && Not4Flag)) 128 | Usage(); 129 | 130 | /* All error reporting is done through syslogs. */ 131 | openlog(__progname, LOG_PID | LOG_CONS, LOG_DAEMON); 132 | 133 | if ((!ForegroundFlag) && DebugFlag) 134 | fprintf(stdout, 135 | "%s: not running as daemon, -d given.\n", __progname); 136 | 137 | if ((!ForegroundFlag) && (!DebugFlag)) { 138 | pid = fork(); 139 | if (pid > 0) 140 | /* Parent exits, leaving child in background. */ 141 | exit(0); 142 | else 143 | if (pid == -1) { 144 | syslog(LOG_ERR, "cannot fork"); 145 | exit(0); 146 | } 147 | 148 | /* Fade into the background */ 149 | daemon(0, 0); 150 | pidfile(NULL); 151 | } 152 | 153 | syslog(LOG_INFO, "%s %s started.", __progname, version); 154 | 155 | if (AllFlag) 156 | deviceInitAll(); 157 | else 158 | deviceInitOne(interface); 159 | 160 | Loop(); 161 | /* NOTREACHED */ 162 | return (0); 163 | } 164 | 165 | void 166 | Usage() 167 | { 168 | (void) fprintf(stderr, "usage: %s -a [ -d -f -v ] [ -3 | -4 ]\n", 169 | __progname); 170 | (void) fprintf(stderr, " %s [ -d -f -v ] [ -3 | -4 ] interface\n", 171 | __progname); 172 | exit(1); 173 | } 174 | 175 | /* 176 | * Process incomming packages. 177 | */ 178 | void 179 | mopProcess(ii, pkt) 180 | struct if_info *ii; 181 | u_char *pkt; 182 | { 183 | u_char *dst, *src; 184 | u_short ptype; 185 | int index, trans, len; 186 | 187 | /* We don't known with transport, Guess! */ 188 | 189 | trans = mopGetTrans(pkt, 0); 190 | 191 | /* Ok, return if we don't wan't this message */ 192 | 193 | if ((trans == TRANS_ETHER) && Not3Flag) return; 194 | if ((trans == TRANS_8023) && Not4Flag) return; 195 | 196 | index = 0; 197 | mopGetHeader(pkt, &index, &dst, &src, &ptype, &len, trans); 198 | 199 | /* 200 | * Ignore our own transmissions 201 | * 202 | */ 203 | if (mopCmpEAddr(ii->eaddr,src) == 0) 204 | return; 205 | 206 | switch(ptype) { 207 | case MOP_K_PROTO_DL: 208 | mopProcessDL(stdout, ii, pkt, &index, dst, src, trans, len); 209 | break; 210 | case MOP_K_PROTO_RC: 211 | mopProcessRC(stdout, ii, pkt, &index, dst, src, trans, len); 212 | break; 213 | default: 214 | break; 215 | } 216 | } 217 | -------------------------------------------------------------------------------- /mopd/process.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: process.h,v 1.2 1997/03/25 03:07:52 thorpej Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1993-95 Mats O Jansson. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by Mats O Jansson. 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | * $NetBSD: process.h,v 1.2 1997/03/25 03:07:52 thorpej Exp $ 32 | * 33 | */ 34 | 35 | #ifndef _PROCESS_H_ 36 | #define _PROCESS_H_ 37 | 38 | __BEGIN_DECLS 39 | void mopProcessDL __P((FILE *, struct if_info *, u_char *, int *, 40 | u_char *, u_char *, int, u_short)); 41 | void mopProcessRC __P((FILE *, struct if_info *, u_char *, int *, 42 | u_char *, u_char *, int, u_short)); 43 | __END_DECLS 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /mopprobe/Makefile: -------------------------------------------------------------------------------- 1 | OBJS=mopprobe.o 2 | INCL=-I../ -I../common 3 | LIBS=../common/libcommon.a 4 | 5 | all: mopprobe 6 | 7 | mopprobe: ${OBJS} version.o $(LIBS) 8 | cc -o mopprobe version.o ${OBJS} ${LIBS} 9 | 10 | .c.o: .c 11 | cc -c $(CFLAGS) ${INCL} $< 12 | 13 | clean: 14 | rm -f *.o *~ mopprobe VERSION version.* 15 | 16 | version.o: version.c 17 | version.c version.h: 18 | ln -sf ../common/VERSION VERSION 19 | rm -f version.c ; sed 's/.*/char version[] = "&";/' VERSION > version.c 20 | set `sed 's/\([0-9]*\)\.\([0-9]*\).*/\1 \2/' VERSION` ; \ 21 | { echo '#define VERSION_MAJOR' $$1 ; \ 22 | echo '#define VERSION_MINOR' $$2 ; } > version.h 23 | 24 | -------------------------------------------------------------------------------- /mopprobe/mopprobe.1: -------------------------------------------------------------------------------- 1 | .\" $NetBSD: mopprobe.1,v 1.2 1997/03/25 03:07:56 thorpej Exp $ 2 | .\" 3 | .\" Copyright (c) 1996 Mats O Jansson. All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 3. All advertising materials mentioning features or use of this software 14 | .\" must display the following acknowledgement: 15 | .\" This product includes software developed by Mats O Jansson. 16 | .\" 4. The name of the author may not be used to endorse or promote products 17 | .\" derived from this software without specific prior written permission. 18 | .\" 19 | .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | .\" 30 | .Dd October 2, 1995 31 | .Dt MOPPROBE 1 32 | .Sh NAME 33 | .Nm mopprobe 34 | .Nd MOP Probe Utility 35 | .Sh SYNOPSIS 36 | .Nm 37 | .Fl a 38 | .Op Fl 3 | 4 39 | .Nm "" 40 | .Op Fl 3 | 4 41 | .Ar interface 42 | .Sh DESCRIPTION 43 | .Nm 44 | prints the ethernet address and nodename of MOP SID message on the Ethernet 45 | connected to 46 | .Ar interface 47 | or all known interfaces if 48 | .Sq Fl a 49 | is given. 50 | .Sh OPTIONS 51 | .Bl -tag -width indent 52 | .It Fl a 53 | Listen on all the Ethernets attached to the system. 54 | If 55 | .Sq Fl a 56 | is omitted, an interface must be specified. 57 | .It Fl 3 58 | Ignore MOP V3 messages (Ethernet II). 59 | .It Fl 4 60 | Ignore MOP V4 messages (Ethernet 802.3). 61 | .El 62 | .Sh SEE ALSO 63 | .Xr mopa.out 1 , 64 | .Xr mopchk 1 , 65 | .Xr mopd 8 , 66 | .Xr moptrace 8 67 | .Sh AUTHORS 68 | Mats O Jansson (moj@stacken.kth.se). 69 | -------------------------------------------------------------------------------- /mopprobe/mopprobe.c: -------------------------------------------------------------------------------- 1 | /* $NetBSD: mopprobe.c,v 1.4 1997/04/17 21:09:27 christos Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1993-96 Mats O Jansson. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by Mats O Jansson. 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | #ifndef lint 34 | /*__RCSID("$NetBSD: mopprobe.c,v 1.4 1997/04/17 21:09:27 christos Exp $");*/ 35 | #endif 36 | 37 | /* 38 | * mopprobe - MOP Probe Utility 39 | * 40 | * Usage: mopprobe -a [ -3 | -4 ] 41 | * mopprobe [ -3 | -4 ] interface 42 | */ 43 | 44 | #include "os.h" 45 | #include "common/cmp.h" 46 | #include "common/common.h" 47 | #include "common/device.h" 48 | #include "common/get.h" 49 | #include "common/mopdef.h" 50 | #include "common/nmadef.h" 51 | #include "common/pf.h" 52 | #include "common/print.h" 53 | 54 | /* 55 | * The list of all interfaces that are being listened to. rarp_loop() 56 | * "selects" on the descriptors in this list. 57 | */ 58 | struct if_info *iflist; 59 | 60 | void Usage __P((void)); 61 | int main __P((int, char **)); 62 | void mopProcess __P((struct if_info *, u_char *)); 63 | 64 | int AllFlag = 0; /* listen on "all" interfaces */ 65 | int DebugFlag = 0; /* print debugging messages */ 66 | int Not3Flag = 0; /* Not MOP V3 messages */ 67 | int Not4Flag = 0; /* Not MOP V4 messages */ 68 | int oflag = 0; /* print only once */ 69 | int promisc = 1; /* Need promisc mode */ 70 | 71 | extern char *__progname; /* from crt0.o */ 72 | 73 | int 74 | main(argc, argv) 75 | int argc; 76 | char **argv; 77 | { 78 | int op; 79 | char *interface; 80 | 81 | /* All error reporting is done through syslogs. */ 82 | openlog(__progname, LOG_PID | LOG_CONS, LOG_DAEMON); 83 | 84 | opterr = 0; 85 | while ((op = getopt(argc, argv, "ado")) != -1) { 86 | switch (op) { 87 | case '3': 88 | Not3Flag++; 89 | break; 90 | case '4': 91 | Not4Flag++; 92 | break; 93 | case 'a': 94 | AllFlag++; 95 | break; 96 | case 'd': 97 | DebugFlag++; 98 | break; 99 | case 'o': 100 | oflag++; 101 | break; 102 | 103 | default: 104 | Usage(); 105 | /* NOTREACHED */ 106 | } 107 | } 108 | interface = argv[optind++]; 109 | 110 | if ((AllFlag && interface) || 111 | (!AllFlag && interface == 0) || 112 | (Not3Flag && Not4Flag)) 113 | Usage(); 114 | 115 | if (AllFlag) 116 | deviceInitAll(); 117 | else 118 | deviceInitOne(interface); 119 | 120 | Loop(); 121 | /* NOTREACHED */ 122 | return (0); 123 | } 124 | 125 | void 126 | Usage() 127 | { 128 | (void) fprintf(stderr, "usage: %s -a [ -3 | -4 ]\n", __progname); 129 | (void) fprintf(stderr, " %s [ -3 | -4 ] interface\n", __progname); 130 | exit(1); 131 | } 132 | 133 | /* 134 | * Process incomming packages. 135 | */ 136 | void 137 | mopProcess(ii, pkt) 138 | struct if_info *ii; 139 | u_char *pkt; 140 | { 141 | u_char *dst, *src, *p, mopcode, tmpc, ilen; 142 | u_short *ptype, moplen, tmps, itype, len; 143 | int index, i, device, trans; 144 | 145 | dst = pkt; 146 | src = pkt+6; 147 | ptype = (u_short *)(pkt+12); 148 | index = 0; 149 | 150 | if (*ptype < 1600) { 151 | len = *ptype; 152 | trans = TRANS_8023; 153 | ptype = (u_short *)(pkt+20); 154 | p = pkt+22; 155 | if (Not4Flag) return; 156 | } else { 157 | len = 0; 158 | trans = TRANS_ETHER; 159 | p = pkt+14; 160 | if (Not3Flag) return; 161 | } 162 | 163 | /* Ignore our own messages */ 164 | 165 | if (mopCmpEAddr(ii->eaddr,src) == 0) { 166 | return; 167 | } 168 | 169 | /* Just check multicast */ 170 | 171 | if (mopCmpEAddr(rc_mcst,dst) != 0) { 172 | return; 173 | } 174 | 175 | switch (trans) { 176 | case TRANS_8023: 177 | moplen = len; 178 | break; 179 | default: 180 | moplen = mopGetShort(pkt,&index); 181 | } 182 | mopcode = mopGetChar(p,&index); 183 | 184 | /* Just process System Information */ 185 | 186 | if (mopcode != MOP_K_CODE_SID) { 187 | return; 188 | } 189 | 190 | tmpc = mopGetChar(pkt,&index); /* Reserved */ 191 | tmps = mopGetShort(pkt,&index); /* Receipt # */ 192 | 193 | device = 0; /* Unknown Device */ 194 | 195 | itype = mopGetShort(pkt,&index); 196 | 197 | while (index < (int)(moplen + 2)) { 198 | ilen = mopGetChar(pkt,&index); 199 | switch (itype) { 200 | case 0: 201 | tmpc = mopGetChar(pkt,&index); 202 | index = index + tmpc; 203 | break; 204 | case MOP_K_INFO_VER: 205 | index = index + 3; 206 | break; 207 | case MOP_K_INFO_MFCT: 208 | index = index + 2; 209 | break; 210 | case MOP_K_INFO_CNU: 211 | index = index + 6; 212 | break; 213 | case MOP_K_INFO_RTM: 214 | index = index + 2; 215 | break; 216 | case MOP_K_INFO_CSZ: 217 | index = index + 2; 218 | break; 219 | case MOP_K_INFO_RSZ: 220 | index = index + 2; 221 | break; 222 | case MOP_K_INFO_HWA: 223 | index = index + 6; 224 | break; 225 | case MOP_K_INFO_TIME: 226 | index = index + 10; 227 | break; 228 | case MOP_K_INFO_SOFD: 229 | device = mopGetChar(pkt,&index); 230 | break; 231 | case MOP_K_INFO_SFID: 232 | tmpc = mopGetChar(pkt,&index); 233 | if ((index > 0) && (index < 17)) 234 | index = index + tmpc; 235 | break; 236 | case MOP_K_INFO_PRTY: 237 | index = index + 1; 238 | break; 239 | case MOP_K_INFO_DLTY: 240 | index = index + 1; 241 | break; 242 | case MOP_K_INFO_DLBSZ: 243 | index = index + 2; 244 | break; 245 | default: 246 | if (((device = NMA_C_SOFD_LCS) || /* DECserver 100 */ 247 | (device = NMA_C_SOFD_DS2) || /* DECserver 200 */ 248 | (device = NMA_C_SOFD_DP2) || /* DECserver 250 */ 249 | (device = NMA_C_SOFD_DS3)) && /* DECserver 300 */ 250 | ((itype > 101) && (itype < 107))) 251 | { 252 | switch (itype) { 253 | case 102: 254 | index = index + ilen; 255 | break; 256 | case 103: 257 | index = index + ilen; 258 | break; 259 | case 104: 260 | index = index + 2; 261 | break; 262 | case 105: 263 | (void)fprintf(stdout,"%x:%x:%x:%x:%x:%x\t", 264 | src[0],src[1],src[2],src[3],src[4],src[5]); 265 | for (i = 0; i < ilen; i++) { 266 | (void)fprintf(stdout, "%c",pkt[index+i]); 267 | } 268 | index = index + ilen; 269 | (void)fprintf(stdout, "\n"); 270 | break; 271 | case 106: 272 | index = index + ilen; 273 | break; 274 | }; 275 | } else { 276 | index = index + ilen; 277 | }; 278 | } 279 | itype = mopGetShort(pkt,&index); 280 | } 281 | 282 | } 283 | 284 | -------------------------------------------------------------------------------- /moptrace/Makefile: -------------------------------------------------------------------------------- 1 | OBJS=moptrace.o 2 | INCL=-I../ -I../common 3 | LIBS=../common/libcommon.a 4 | 5 | all: moptrace 6 | 7 | moptrace: ${OBJS} version.o $(LIBS) 8 | cc -o moptrace version.o ${OBJS} ${LIBS} 9 | 10 | .c.o: .c 11 | cc -c $(CFLAGS) ${INCL} $< 12 | 13 | clean: 14 | rm -f *.o *~ moptrace VERSION version.* 15 | 16 | version.o: version.c 17 | version.c version.h: 18 | ln -sf ../common/VERSION VERSION 19 | rm -f version.c ; sed 's/.*/char version[] = "&";/' VERSION > version.c 20 | set `sed 's/\([0-9]*\)\.\([0-9]*\).*/\1 \2/' VERSION` ; \ 21 | { echo '#define VERSION_MAJOR' $$1 ; \ 22 | echo '#define VERSION_MINOR' $$2 ; } > version.h 23 | 24 | -------------------------------------------------------------------------------- /moptrace/moptrace.1: -------------------------------------------------------------------------------- 1 | .\" $NetBSD: moptrace.1,v 1.4 1997/10/18 04:37:37 lukem Exp $ 2 | .\" 3 | .\" Copyright (c) 1993-95 Mats O Jansson. All rights reserved. 4 | .\" 5 | .\" Redistribution and use in source and binary forms, with or without 6 | .\" modification, are permitted provided that the following conditions 7 | .\" are met: 8 | .\" 1. Redistributions of source code must retain the above copyright 9 | .\" notice, this list of conditions and the following disclaimer. 10 | .\" 2. Redistributions in binary form must reproduce the above copyright 11 | .\" notice, this list of conditions and the following disclaimer in the 12 | .\" documentation and/or other materials provided with the distribution. 13 | .\" 3. All advertising materials mentioning features or use of this software 14 | .\" must display the following acknowledgement: 15 | .\" This product includes software developed by Mats O Jansson. 16 | .\" 4. The name of the author may not be used to endorse or promote products 17 | .\" derived from this software without specific prior written permission. 18 | .\" 19 | .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | .\" 30 | .\" @(#) $NetBSD: moptrace.1,v 1.4 1997/10/18 04:37:37 lukem Exp $ 31 | .\" 32 | .Dd October 2, 1995 33 | .Dt MOPTRACE 1 34 | .Sh NAME 35 | .Nm moptrace 36 | .Nd MOP Trace Utility 37 | .Sh SYNOPSIS 38 | .Nm 39 | .Op Fl a 40 | .Op Fl d 41 | .Op Fl 3 | 4 42 | .Nm "" 43 | .Op Fl d 44 | .Op Fl 3 | 4 45 | .Op Ar interface 46 | .Sh DESCRIPTION 47 | .Nm 48 | prints the contents of MOP packages on the Ethernet connected to 49 | .Ar interface 50 | or all known interfaces if 51 | .Sq Fl a 52 | is given. 53 | .Sh OPTIONS 54 | .Bl -tag -width indent 55 | .It Fl a 56 | Listen on all the Ethernets attached to the system. 57 | If 58 | .Sq Fl a 59 | is omitted, an interface must be specified. 60 | .It Fl d 61 | Run in debug mode, with all the output to stderr. 62 | .It Fl 3 63 | Ignore MOP V3 messages (Ethernet II). 64 | .It Fl 4 65 | Ignore MOP V4 messages (Ethernet 802.3). 66 | .El 67 | .Sh SEE ALSO 68 | .Xr mopa.out 1 , 69 | .Xr mopchk 1 , 70 | .Xr mopd 8 , 71 | .Xr mopprobe 1 72 | .Rs 73 | DECnet Digital Network Architecture Phase IV, 74 | .%R Maintenance Operations Functional Specification V3.0.0 75 | .%N AA-X436A-TK 76 | .Re 77 | .Rs 78 | DECnet Digital Network Architecture, 79 | .%R Maintenance Operations Protocol Functional Specification V4.0.0 80 | .%N EK-DNA11-FS-001 81 | .Re 82 | .Sh AUTHORS 83 | Mats O Jansson (moj@stacken.kth.se). 84 | -------------------------------------------------------------------------------- /moptrace/moptrace.c: -------------------------------------------------------------------------------- 1 | /* $NetBSD: moptrace.c,v 1.4 1997/04/17 21:09:33 christos Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1993-95 Mats O Jansson. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by Mats O Jansson. 17 | * 4. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | #ifndef lint 34 | /*__RCSID("$NetBSD: moptrace.c,v 1.4 1997/04/17 21:09:33 christos Exp $");*/ 35 | #endif 36 | 37 | /* 38 | * moptrace - MOP Trace Utility 39 | * 40 | * Usage: moptrace -a [ -d ] [ -3 | -4 ] 41 | * moptrace [ -d ] [ -3 | -4 ] interface 42 | */ 43 | 44 | #include "os.h" 45 | #include "common/common.h" 46 | #include "common/device.h" 47 | #include "common/dl.h" 48 | #include "common/get.h" 49 | #include "common/mopdef.h" 50 | #include "common/pf.h" 51 | #include "common/print.h" 52 | #include "common/rc.h" 53 | 54 | /* 55 | * The list of all interfaces that are being listened to. 56 | * "selects" on the descriptors in this list. 57 | */ 58 | struct if_info *iflist; 59 | 60 | void Usage __P((void)); 61 | int main __P((int, char **)); 62 | void mopProcess __P((struct if_info *, u_char *)); 63 | 64 | int AllFlag = 0; /* listen on "all" interfaces */ 65 | int DebugFlag = 0; /* print debugging messages */ 66 | int Not3Flag = 0; /* Ignore MOP V3 messages */ 67 | int Not4Flag = 0; /* Ignore MOP V4 messages */ 68 | int promisc = 1; /* Need promisc mode */ 69 | 70 | extern char *__progname; /* from crt0.o */ 71 | 72 | int 73 | main(argc, argv) 74 | int argc; 75 | char **argv; 76 | { 77 | int op; 78 | char *interface; 79 | 80 | /* All error reporting is done through syslogs. */ 81 | openlog(__progname, LOG_PID | LOG_CONS, LOG_DAEMON); 82 | 83 | opterr = 0; 84 | while ((op = getopt(argc, argv, "34ad")) != -1) { 85 | switch (op) { 86 | case '3': 87 | Not3Flag++; 88 | break; 89 | case '4': 90 | Not4Flag++; 91 | break; 92 | case 'a': 93 | AllFlag++; 94 | break; 95 | case 'd': 96 | DebugFlag++; 97 | break; 98 | default: 99 | Usage(); 100 | /* NOTREACHED */ 101 | } 102 | } 103 | 104 | interface = argv[optind++]; 105 | 106 | if ((AllFlag && interface) || 107 | (!AllFlag && interface == 0) || 108 | (Not3Flag && Not4Flag)) 109 | Usage(); 110 | 111 | if (AllFlag) 112 | deviceInitAll(); 113 | else 114 | deviceInitOne(interface); 115 | 116 | Loop(); 117 | /* NOTREACHED */ 118 | return (0); 119 | } 120 | 121 | void 122 | Usage() 123 | { 124 | (void) fprintf(stderr, "usage: %s -a [ -d ] [ -3 | -4 ]\n", __progname); 125 | (void) fprintf(stderr, " %s [ -d ] [ -3 | -4 ] interface\n", 126 | __progname); 127 | exit(1); 128 | } 129 | 130 | /* 131 | * Process incoming packages. 132 | */ 133 | void 134 | mopProcess(ii, pkt) 135 | struct if_info *ii; 136 | u_char *pkt; 137 | { 138 | int trans; 139 | 140 | /* We don't known which transport, Guess! */ 141 | 142 | trans = mopGetTrans(pkt, 0); 143 | 144 | /* Ok, return if we don't want this message */ 145 | 146 | if ((trans == TRANS_ETHER) && Not3Flag) return; 147 | if ((trans == TRANS_8023) && Not4Flag) return; 148 | 149 | mopPrintHeader(stdout, pkt, trans); 150 | mopPrintMopHeader(stdout, pkt, trans); 151 | 152 | mopDumpDL(stdout, pkt, trans); 153 | mopDumpRC(stdout, pkt, trans); 154 | 155 | fprintf(stdout, "\n"); 156 | fflush(stdout); 157 | } 158 | --------------------------------------------------------------------------------