1 /******************************************************************************
3 Copyright (c) 2012, Intel Corporation
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
9 1. Redistributions of source code must retain the above copyright notice,
10 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.
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.
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.
32 ******************************************************************************/
34 #define MSRP_ETYPE 0x22EA
35 #define MSRP_PROT_VER 0x00
36 #define MSRP_SR_PVID_DEFAULT 2
39 * PortMediaType = either AccessControlPort (the case for wired) or
40 * Non-DMN shared medium port - we are assuming wired-LAN for this daemon
43 #define MSRP_TALKER_ADV_TYPE 1 /* with AttributeLength = 25 */
44 #define MSRP_TALKER_FAILED_TYPE 2 /* with AttributeLength = 34 */
45 #define MSRP_LISTENER_TYPE 3 /* with AttributeLength = 8 */
46 #define MSRP_DOMAIN_TYPE 4 /* with AttributeLength = 4 */
48 /* encodings for the Listener related FourPackedEvents field */
49 #define MSRP_LISTENER_IGNORE 0
50 #define MSRP_LISTENER_ASKFAILED 1
51 #define MSRP_LISTENER_READY 2
52 #define MSRP_LISTENER_READYFAIL 3
55 * FirstValue structure definition for MSRP Attributes
57 typedef struct msrpdu_listen {
58 uint8_t StreamID[8]; /* MSB bytes are talker MAC address */
61 typedef struct msrpdu_talker_advertise {
66 } DataFrameParameters;
68 uint16_t MaxFrameSize;
69 uint16_t MaxIntervalFrames;
71 uint8_t PriorityAndRank;
73 * PriorityAndRank := (3-bit priority | 1 bit rank | 4-bits reserved)
74 * 'rank=0 means emergency traffic, =1 otherwise
76 unsigned AccumulatedLatency; /* unsigned 32 bit nsec latency */
77 } msrpdu_talker_advertise_t;
79 typedef struct msrpdu_talker_fail {
84 } DataFrameParameters;
86 uint16_t MaxFrameSize;
87 uint16_t MaxIntervalFrames;
89 uint8_t PriorityAndRank;
90 unsigned AccumulatedLatency;
95 } msrpdu_talker_fail_t;
97 /* Failure Code definitions */
99 #define MSRP_FAIL_BANDWIDTH 1
100 #define MSRP_FAIL_BRIDGE 2
101 #define MSRP_FAIL_TC_BANDWIDTH 3
102 #define MSRP_FAIL_ID_BUSY 4
103 #define MSRP_FAIL_DSTADDR_BUSY 5
104 #define MSRP_FAIL_PREEMPTED 6
105 #define MSRP_FAIL_LATENCY_CHNG 7
106 #define MSRP_FAIL_PORT_NOT_AVB 8
107 #define MSRP_FAIL_DSTADDR_FULL 9
108 #define MSRP_FAIL_MSRP_RESOURCE 10
109 #define MSRP_FAIL_MMRP_RESOURCE 11
110 #define MSRP_FAIL_DSTADDR_FAIL 12
111 #define MSRP_FAIL_PRIO_NOT_SR 13
112 #define MSRP_FAIL_FRAME_SIZE 14
113 #define MSRP_FAIL_FANIN_EXCEED 15
114 #define MSRP_FAIL_STREAM_CHANGE 16
115 #define MSRP_FAIL_VLAN_BLOCKED 17
116 #define MSRP_FAIL_VLAN_DISABLED 18
117 #define MSRP_FAIL_SR_PRIO_ERR 19
119 /* Domain Discovery FirstValue definition */
120 typedef struct msrpdu_domain {
122 uint8_t SRclassPriority;
126 /* Class ID defitions */
127 #define MSRP_SR_CLASS_A 6
128 #define MSRP_SR_CLASS_B 5
130 /* default values for class priorities */
131 #define MSRP_SR_CLASS_A_PRIO 3
132 #define MSRP_SR_CLASS_B_PRIO 2
134 #define MSRP_DIRECTION_TALKER 0
135 #define MSRP_DIRECTION_LISTENER 1
137 struct msrp_attribute {
138 struct msrp_attribute *prev;
139 struct msrp_attribute *next;
142 msrpdu_talker_fail_t talk_listen;
143 msrpdu_domain_t domain;
145 uint32_t substate; /*for listener events */
146 uint32_t direction; /*for listener events */
147 mrp_applicant_attribute_t applicant;
148 mrp_registrar_attribute_t registrar;
151 struct msrp_database {
152 struct mrp_database mrp_db;
153 struct msrp_attribute *attrib_list;
156 int msrp_init(int msrp_enable);
157 int msrp_event(int event, struct msrp_attribute *rattrib);
158 int msrp_recv_cmd(char *buf, int buflen, struct sockaddr_in *client);
159 int msrp_send_notifications(struct msrp_attribute *attrib, int notify);
160 int msrp_reclaim(void);
161 void msrp_bye(struct sockaddr_in *client);
162 int msrp_recv_msg(void);