|
|
1.1 root 1: /*
2: * I P C O N F I G
3: *
4: * Ethernet IP protocol setup procedure.
5: * Invoked from 'netconfig' with fd 0 open to an ethernet channel.
6: * Args: my-name his-name
7: *
8: *
9: * (c) Copyright 1985 Nirvonics, Inc.
10: *
11: * Written by Kurt Gollhardt
12: * Last update Mon Mar 18 16:33:11 1985
13: *
14: * This software is the property of Nirvonics, Inc.
15: * All rights reserved.
16: *
17: */
18:
19: #include <stdio.h>
20: #include <sys/ioctl.h>
21: #include <sys/types.h>
22: #include <sys/order.h>
23: #include <sys/ethernet.h>
24:
25: extern int ip_ld;
26: int ip_type;
27:
28:
29: main(ac,av)
30: char **av;
31: {
32: char *me, *it;
33: unsigned long myaddr, hisaddr;
34:
35: if (ioctl(0, FIOPUSHLD, &ip_ld) < 0) {
36: fprintf(stderr, "Can't push ip line discipline\n");
37: exit(1);
38: }
39: ip_type = hfirst_short(ETHERPUP_IPTYPE);
40: if (ioctl(0, ENIOTYPE, &ip_type) < 0) {
41: fprintf(stderr, "%s: Can't set ip type\n", av[0]);
42: exit(1);
43: }
44:
45: if (ac != 3) {
46: fprintf(stderr, "%s: args: my-name his-name\n", av[0]);
47: exit(1);
48: }
49: me = av[1];
50: it = av[2];
51:
52: myaddr = tcp_addr(me);
53: if(myaddr == 0){
54: fprintf(stderr, "ipconfig: unknown host %s\n", me);
55: exit(1);
56: }
57: hisaddr = tcp_addr(it);
58: if(hisaddr == 0){
59: fprintf(stderr, "ipconfig: unknown host/net %s\n", it);
60: exit(1);
61: }
62:
63: if (ioctl(0, IPIOLOCAL, &myaddr) < 0) {
64: fprintf(stderr, "%s: ", av[0]);
65: perror("IPIOLOCAL");
66: exit(1);
67: }
68: if (hisaddr & 0xff)
69: ioctl(0, IPIOHOST, &hisaddr);
70: else
71: ioctl(0, IPIONET, &hisaddr);
72: if (ioctl(0, IPIOARP, 0) < 0) {
73: fprintf(stderr, "%s: ", av[0]);
74: perror("IPIOARP");
75: exit(1);
76: }
77:
78: printf("%s: installed as %s on %s\n", av[0], me, it);
79: fflush(stdout);
80:
81: pause();
82: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.