Add IrDA support; patch from Dag Brattli <dagb@cs.uit.no>
[platform/upstream/net-tools.git] / lib / irda.c
1 /*********************************************************************
2  *                
3  * Filename:      irda.c
4  * Version:       0.1
5  * Description:   A first attempt to make ifconfig understand IrDA
6  * Status:        Experimental.
7  * Author:        Dag Brattli <dagb@cs.uit.no>
8  * Created at:    Wed Apr 21 09:03:09 1999
9  * Modified at:   Wed Apr 21 09:17:05 1999
10  * Modified by:   Dag Brattli <dagb@cs.uit.no>
11  * 
12  *     This program is free software; you can redistribute it and/or 
13  *     modify it under the terms of the GNU General Public License as 
14  *     published by the Free Software Foundation; either version 2 of 
15  *     the License, or (at your option) any later version.
16  * 
17  *     This program is distributed in the hope that it will be useful,
18  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
19  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  *     GNU General Public License for more details.
21  * 
22  *     You should have received a copy of the GNU General Public License 
23  *     along with this program; if not, write to the Free Software 
24  *     Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
25  *     MA 02111-1307 USA
26  *     
27  ********************************************************************/
28
29 #include "config.h"
30
31 #if HAVE_AFIRDA || HAVE_HWIRDA
32 #include <sys/types.h>
33 #include <sys/ioctl.h>
34 #include <sys/socket.h>
35 #include <net/if_arp.h>
36 #include <stdlib.h>
37 #include <stdio.h>
38 #include <ctype.h>
39 #include <errno.h>
40 #include <fcntl.h>
41 #include <string.h>
42 #include <termios.h>
43 #include <unistd.h>
44 #include "net-support.h"
45 #include "pathnames.h"
46 #include "intl.h"
47 #include "util.h"
48
49 /* Probably not a good idea to include <linux/if_arp.h> */
50 #ifndef ARPHRD_IRDA
51 #define ARPHRD_IRDA 783
52 #endif
53
54 /*
55  * Function irda_print (ptr)
56  *
57  *    Print hardware address of interface
58  *
59  */
60 static char *irda_print(unsigned char *ptr)
61 {
62     static char buff[8];
63
64     sprintf(&buff[strlen(buff)], "%02x:%02x:%02x:%02x", ptr[3], ptr[2], 
65             ptr[1], ptr[0]);
66
67     return (buff);
68 }
69
70 /*
71  * Function irda_sprint (sap)
72  *
73  *    Print IrDA socket address
74  *
75  */
76 static char *irda_sprint(struct sockaddr *sap)
77 {
78         /* NOP */
79         return NULL;
80 }
81
82 struct hwtype irda_hwtype =
83 {
84      "irda", NULL, ARPHRD_IRDA, 2,
85      irda_print, irda_sprint, NULL, NULL
86 };
87
88 #endif                          /* HAVE_xxIRDA */