2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef __ASP_COORDINATION_PROTOCOL_H__
18 #define __ASP_COORDINATION_PROTOCOL_H__
25 #define SESSION_MAC_BUF_SIZE 6
26 #define SESSION_INFO_BUF_SIZE 144
27 #define DEFERRED_INFO_BUF_SIZE 144
32 #define ROLE "[seeker ]"
33 #define INFO_MSG ASP_LOGD("%s %s : %s(), :%s line:%d", ROLE, __TIME__, __FILE__, __func__, __LINE__)
35 #define ROLE "[advertiser]"
36 #define INFO_MSG ASP_LOGD("%s %s : %s(), :%s line:%d", ROLE, __TIME__, __FILE__, __func__, __LINE__)
39 typedef struct asp_coord_header {
42 } __attribute__((packed)) asp_coord_header_s;
44 typedef struct asp_request_header {
47 guint8 session_mac[SESSION_MAC_BUF_SIZE];
49 } __attribute__((packed)) asp_request_header_s;
51 typedef struct asp_request_session {
54 guint8 session_mac[SESSION_MAC_BUF_SIZE];
56 guint32 advertisement_id;
57 guint8 session_information_length;
58 guint8 session_information[SESSION_INFO_BUF_SIZE];
59 } __attribute__((packed)) asp_request_session_s;
61 typedef struct asp_added_session {
64 guint8 session_mac[SESSION_MAC_BUF_SIZE];
66 } __attribute__((packed)) asp_added_session_s;
68 typedef struct asp_rejected_session {
71 guint8 session_mac[SESSION_MAC_BUF_SIZE];
73 } __attribute__((packed)) asp_rejected_session_s;
75 typedef struct asp_remove_session {
78 guint8 session_mac[SESSION_MAC_BUF_SIZE];
81 } __attribute__((packed)) asp_remove_session_s;
83 typedef struct asp_allowed_port {
86 guint8 session_mac[SESSION_MAC_BUF_SIZE];
90 } __attribute__((packed)) asp_allowed_port_s;
92 typedef struct asp_version {
95 guint8 coordination_version;
96 guint8 vendor_information_length;
97 guint32 vendor_information;
98 } __attribute__((packed)) asp_version_s;
100 typedef struct asp_deferred_session {
103 guint8 session_mac[SESSION_MAC_BUF_SIZE];
105 guint8 deferred_session__response_length;
106 guint8 deferred_session__response[DEFERRED_INFO_BUF_SIZE];
107 } __attribute__((packed)) asp_deferred_session_s;
109 typedef struct asp_ack {
112 } __attribute__((packed)) asp_ack_s;
114 typedef struct asp_nack {
118 } __attribute__((packed)) asp_nack_s;
121 ASP_OPCODE_REQUEST_SESSION = 0x00,
122 ASP_OPCODE_ADDED_SESSION = 0x01,
123 ASP_OPCODE_REJECTED_SESSION = 0x02,
125 ASP_OPCODE_REMOVE_SESSION = 0x03,
126 ASP_OPCODE_ALLOWED_PORT = 0x04,
127 ASP_OPCODE_VERSION = 0x05,
128 ASP_OPCODE_DEFERRED_SESSION = 0x06,
129 ASP_OPCODE_ACK = 0xFE,
130 ASP_OPCODE_NACK = 0xFF
134 ASP_REMOVE_SESS_REASON_UNKOWN_REASON = 0x00,
135 ASP_REMOVE_SESS_REASON_REJECTED_BY_USER = 0x01,
136 ASP_REMOVE_SESS_REASON_ADVERTISED_SERVICE_NOT_AVAILABLE = 0x02,
137 ASP_REMOVE_SESS_REASON_SYSTEM_FAILURE = 0x03
141 ASP_NACK_REASON_INVALID_SESSION_MAC = 0x00,
142 ASP_NACK_REASON_INVALID_SESSION_ID = 0x01,
143 ASP_NACK_REASON_INVALID_OPCODE = 0x02,
144 ASP_NACK_REASON_INVALID_SEQUENCE_NUM = 0x03,
145 ASP_NACK_REASON_NO_SESSION_EXIST = 0x04,
146 ASP_NACK_REASON_UNKNOWN_REASON = 0x05
149 gboolean asp_coordination_protocol_init();
150 gboolean asp_coordination_protocol_destroy();
151 gboolean asp_coordination_protocol_send_msg(GSocketAddress *input_sock_addr,
154 #endif /* __ASP_COORDINATION_PROTOCOL_H__ */