examples: mrp_client, fix compiler warning
[profile/ivi/OpenAVB.git] / examples / mrp_client / mrpdhelper.h
1 /******************************************************************************
2
3   Copyright (c) 2012, AudioScience, Inc
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 #ifndef _MRPDHELPER_H_
35 #define _MRPDHELPER_H_
36
37 /**************************************************************************
38 This module provides helper functions for communicating with the MRPD daemon.
39 ***************************************************************************/
40
41 enum mrpdhelper_attribtype {
42         mrpdhelper_attribtype_null,
43         mrpdhelper_attribtype_mmrp,
44         mrpdhelper_attribtype_mvrp,
45         mrpdhelper_attribtype_msrp_domain,
46         mrpdhelper_attribtype_msrp_talker,
47         mrpdhelper_attribtype_msrp_listener,
48         mrpdhelper_attribtype_msrp_talker_fail,
49         mrpdhelper_attribtype_msrp_listener_fail
50 };
51
52 enum mrpdhelper_notification {
53         mrpdhelper_notification_null,
54         mrpdhelper_notification_new,
55         mrpdhelper_notification_join,
56         mrpdhelper_notification_leave
57 };
58
59 enum mrpdhelper_state {
60         mrpdhelper_state_null,
61         mrpdhelper_state_in,
62         mrpdhelper_state_leave,
63         mrpdhelper_state_empty
64 };
65
66 enum mrpdhelper_applicant_state {
67         mrpdhelper_applicant_state_null,
68         mrpdhelper_applicant_state_VO,
69         mrpdhelper_applicant_state_VP,
70         mrpdhelper_applicant_state_VN,
71         mrpdhelper_applicant_state_AN,
72         mrpdhelper_applicant_state_AA,
73         mrpdhelper_applicant_state_QA,
74         mrpdhelper_applicant_state_LA,
75         mrpdhelper_applicant_state_AO,
76         mrpdhelper_applicant_state_QO,
77         mrpdhelper_applicant_state_AP,
78         mrpdhelper_applicant_state_QP,
79         mrpdhelper_applicant_state_LO
80 };
81
82 struct mrpdhelper_mmrp_notify {
83         uint64_t mac;
84 };
85
86 struct mrpdhelper_mvrp_notify {
87         uint32_t vid;
88 };
89
90 struct mrpdhelper_msrp_domain {
91         uint32_t id;
92         uint32_t priority;
93         uint32_t vid;
94 };
95
96 struct mrpdhelper_msrp_listener {
97         uint32_t substate;
98         uint64_t id;
99 };
100
101 struct mrpdhelper_msrp_talker {
102         uint64_t id;
103         uint64_t dest_mac;
104         uint32_t vid;
105         uint32_t max_frame_size;
106         uint32_t max_interval_frames;
107         uint32_t priority_and_rank;
108         uint32_t accum_latency;
109         uint64_t bridge_id;
110         uint32_t failure_code;
111 };
112
113 struct mrpdhelper_notify {
114         enum mrpdhelper_attribtype attrib;
115         enum mrpdhelper_notification notify;
116         enum mrpdhelper_state state;
117         enum mrpdhelper_applicant_state app_state;
118         uint64_t registrar;
119         union {
120                 struct mrpdhelper_mmrp_notify m;
121                 struct mrpdhelper_mvrp_notify v;
122                 struct mrpdhelper_msrp_domain sd;
123                 struct mrpdhelper_msrp_listener sl;
124                 struct mrpdhelper_msrp_talker st;
125         } u;
126 };
127
128 int mrpdhelper_parse_notification(char *sz,
129                                   size_t len, struct mrpdhelper_notify *n);
130
131 int mrpdhelper_notify_equal(struct mrpdhelper_notify *n1,
132                             struct mrpdhelper_notify *n2);
133
134 #endif