Upgrade make(1). 1/2
[dragonfly.git] / usr.sbin / bthcid / bthcid.h
1 /* $NetBSD: bthcid.h,v 1.3 2006/09/26 19:18:19 plunky Exp $ */
2
3 /*-
4  * Copyright (c) 2006 Itronix Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. The name of Itronix Inc. may not be used to endorse
16  *    or promote products derived from this software without specific
17  *    prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY
23  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26  * ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31
32 #ifndef _BTHCID_H_
33 #define _BTHCID_H_      1
34
35 #include <sys/queue.h>
36
37 /* config.c */
38 uint8_t         *lookup_key             (bdaddr_t *, bdaddr_t *);
39 void             save_key               (bdaddr_t *, bdaddr_t *, uint8_t *);
40 void             create_dict(bdaddr_t *laddr, bdaddr_t *raddr, uint8_t * key);
41
42 /* client.c */
43 int              init_control           (const char *, mode_t);
44 int              send_client_request    (bdaddr_t *, bdaddr_t *, int);
45 uint8_t         *lookup_pin             (bdaddr_t *, bdaddr_t *);
46 uint8_t         *lookup_pin_conf        (bdaddr_t *, bdaddr_t *);
47 void            process_control         (int);
48 void            process_client          (int, void *);
49 void            process_item            (void *);
50
51 /* hci.c */
52 int             init_hci                (bdaddr_t *);
53 void            process_hci             (int);
54 int             send_pin_code_reply     (int, struct sockaddr_bt *, bdaddr_t *, uint8_t *);
55
56 #define BTHCID_BUFFER_SIZE      512
57 #define BTHCID_IDENT            "bthcid"
58 #define BTHCID_PIDFILE          "/var/run/" BTHCID_IDENT ".pid"
59 #define BTHCID_KEYSFILE         "/var/db/"  BTHCID_IDENT ".keys"
60 #define BTHCID_KQ_EVENTS        64
61
62 struct link_key
63 {
64         bdaddr_t                 bdaddr; /* remote device BDADDR */
65         char                    *name;   /* remote device name */
66         uint8_t                 *key;    /* link key (or NULL if no key) */
67         char                    *pin;    /* pin (or NULL if no pin) */
68         LIST_ENTRY(link_key)     next;   /* link to the next */
69 };
70 typedef struct link_key         link_key_t;
71 typedef struct link_key *       link_key_p;
72
73 extern const char               *config_file;
74 extern int                      hci_kq;
75
76 #ifdef __config_debug__
77 void            dump_config     (void);
78 #endif
79
80 #ifndef bdaddr_p 
81 #define bdaddr_p bdaddr_t *
82 #endif
83
84 void            read_config_file(void);
85 void            clean_config    (void);
86 link_key_p      get_key         (bdaddr_p bdaddr, int exact_match);
87
88 int             read_keys_file  (void);
89 int             dump_keys_file  (void);
90
91 #endif  /* _BTHCID_H_ */