mrpd: comment cleanup
[profile/ivi/OpenAVB.git] / daemons / mrpd / mmrp.h
1 /******************************************************************************
2
3   Copyright (c) 2012, Intel Corporation 
4   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 are met:
8   
9    1. Redistributions of source code must retain the above copyright notice, 
10       this list of conditions and the following disclaimer.
11   
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   
16    3. Neither the name of the Intel Corporation nor the names of its 
17       contributors may be used to endorse or promote products derived from 
18       this software without specific prior written permission.
19   
20   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
22   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
23   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
24   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
25   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
26   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
27   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
28   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
29   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   POSSIBILITY OF SUCH DAMAGE.
31
32 ******************************************************************************/
33
34 #define MMRP_ETYPE      0x88F6
35 #define MMRP_PROT_VER   0x00
36
37 /* two attribute types defined for MMRP */
38 #define MMRP_SVCREQ_TYPE        1
39 #define MMRP_MACVEC_TYPE        2
40
41 /* MMRP_MACVEC_TYPE FirstValue is the 6-byte MAC address, with
42  * corresponding attrib_length=6
43  */
44
45 /* MMRP_SVCREQ_TYPE FirstValue is a single byte - values follow,
46  * attrib_length=1
47  */
48
49 #define MMRP_SVCREQ_FOWARD_ALL                  0
50 #define MMRP_SVCREQ_FOWARD_UNREGISTERED 1
51 /* MMRP uses ThreePackedEvents for all vector encodings */
52
53 struct mmrp_attribute {
54         struct mmrp_attribute *prev;
55         struct mmrp_attribute *next;
56         uint32_t type;
57         union {
58                 unsigned char macaddr[6];
59                 uint8_t svcreq;
60         } attribute;
61         mrp_applicant_attribute_t applicant;
62         mrp_registrar_attribute_t registrar;
63 };
64
65 struct mmrp_database {
66         struct mrp_database mrp_db;
67         struct mmrp_attribute *attrib_list;
68 };
69
70 int mmrp_init(int mmrp_enable);
71 int mmrp_event(int event, struct mmrp_attribute *rattrib);
72 int mmrp_recv_cmd(char *buf, int buflen, struct sockaddr_in *client);
73 int mmrp_reclaim(void);
74 void mmrp_bye(struct sockaddr_in *client);
75 int mmrp_recv_msg(void);
76 void mmrp_increment_macaddr(uint8_t * macaddr);
77 int mmrp_send_notifications(struct mmrp_attribute *attrib, int notify);