wirelessconf.c revision 1.2 1 /* $NetBSD: wirelessconf.c,v 1.2 2009/10/14 23:51:22 pooka Exp $ */
2
3 /*
4 * Copyright (c) 2009 Antti Kantee. 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 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
16 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28 #include <sys/types.h>
29 #include <sys/ioctl.h>
30 #include <sys/reboot.h>
31 #include <sys/socket.h>
32
33 #include <net/if.h>
34
35 #include <rump/rump.h>
36 #include <rump/rump_syscalls.h>
37
38 #include <err.h>
39 #include <stdio.h>
40 #include <string.h>
41
42 /*
43 * Example program for raising rum0 interface under rump. This
44 * requires a rum-compatible usb device attached as ugen.
45 */
46
47 #define RUMFW "/libdata/firmware/rum/rum-rt2573"
48 int
49 main(void)
50 {
51 extern int rumpns_boothowto;
52 struct ifreq ifr;
53 int s;
54
55 rumpns_boothowto = AB_VERBOSE;
56 rump_init();
57 printf("\ndevice autoconfiguration finished\n");
58
59 printf("tira-if-su ...\n");
60 if (rump_pub_etfs_register(RUMFW, RUMFW, RUMP_ETFS_REG) != 0)
61 errx(1, "firmware etfs registration failed");
62
63 /* rum? shouldn't that be marsala? */
64 strcpy(ifr.ifr_name, "rum0");
65 ifr.ifr_flags = IFF_UP;
66 s = rump_sys_socket(AF_INET, SOCK_DGRAM, 0);
67 if (s == -1)
68 err(1, "socket");
69
70 if (rump_sys_ioctl(s, SIOCSIFFLAGS, &ifr) == -1)
71 err(1, "ioctl");
72 printf("... done\n");
73
74 return 0;
75 }
76