Home | History | Annotate | Line # | Download | only in wirelessconf
      1 /*	$NetBSD: wirelessconf.c,v 1.3 2009/11/03 18:24:21 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 <errno.h>
     40 #include <stdio.h>
     41 #include <stdlib.h>
     42 #include <string.h>
     43 
     44 /*
     45  * Example program for raising rum0 interface under rump.  This
     46  * requires a rum-compatible usb device attached as ugen.
     47  */
     48 
     49 #define RUMFW "/libdata/firmware/rum/rum-rt2573"
     50 int
     51 main(void)
     52 {
     53 	struct ifreq ifr;
     54 	int s;
     55 
     56 	rump_boot_sethowto(RUMP_AB_VERBOSE);
     57 	rump_init();
     58 
     59 	/* rum?  shouldn't that be marsala? */
     60 	s = rump_sys_socket(AF_INET, SOCK_DGRAM, 0);
     61 	if (s == -1)
     62 		err(1, "socket");
     63 	strcpy(ifr.ifr_name, "rum0");
     64 	if (rump_sys_ioctl(s, SIOCGIFFLAGS, &ifr) == -1) {
     65 		if (errno == ENXIO) {
     66 			printf("rum@usb not found!\n");
     67 			exit(0);
     68 		}
     69 		err(1, "get if flags");
     70 	}
     71 	printf("\ndevice autoconfiguration finished\n");
     72 
     73 	printf("tira-if-su ...\n");
     74 	if (rump_pub_etfs_register(RUMFW, RUMFW, RUMP_ETFS_REG) != 0)
     75 		errx(1, "firmware etfs registration failed");
     76 
     77 	strcpy(ifr.ifr_name, "rum0");
     78 	ifr.ifr_flags = IFF_UP;
     79 	if (rump_sys_ioctl(s, SIOCSIFFLAGS, &ifr) == -1)
     80 		err(1, "ioctl");
     81 	printf("... done\n");
     82 
     83 	return 0;
     84 }
     85