source: uKadecot/trunk/kadecot/wamp.h@ 101

Last change on this file since 101 was 101, checked in by coas-nagasima, 8 years ago

TOPPERS/uKadecotのソースコードを追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/plain
File size: 5.4 KB
Line 
1/*
2 * TOPPERS ECHONET Lite Communication Middleware
3 *
4 * Copyright (C) 2015 Cores Co., Ltd. Japan
5 *
6 * ã‹L’˜ìŒ ŽÒ‚́CˆÈ‰º‚Ì(1)`(4)‚ÌðŒ‚ð–ž‚½‚·ê‡‚ÉŒÀ‚èC–{ƒ\ƒtƒgƒEƒF
7 * ƒAi–{ƒ\ƒtƒgƒEƒFƒA‚ð‰ü•Ï‚µ‚½‚à‚Ì‚ðŠÜ‚ށDˆÈ‰º“¯‚¶j‚ðŽg—pE•¡»E‰ü
8 * •ÏEÄ”z•ziˆÈ‰ºC—˜—p‚ƌĂԁj‚·‚邱‚Ƃ𖳏ž‚Å‹–‘ø‚·‚éD
9 * (1) –{ƒ\ƒtƒgƒEƒFƒA‚ðƒ\[ƒXƒR[ƒh‚ÌŒ`‚Å—˜—p‚·‚éê‡‚ɂ́Cã‹L‚Ì’˜ì
10 * Œ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’肪C‚»‚Ì‚Ü‚Ü‚ÌŒ`‚Ń\[
11 * ƒXƒR[ƒh’†‚ÉŠÜ‚Ü‚ê‚Ä‚¢‚邱‚ƁD
12 * (2) –{ƒ\ƒtƒgƒEƒFƒA‚ðCƒ‰ƒCƒuƒ‰ƒŠŒ`Ž®‚ȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
13 * —p‚Å‚«‚éŒ`‚ōĔz•z‚·‚éê‡‚ɂ́CÄ”z•z‚É”º‚¤ƒhƒLƒ…
14ƒƒ“ƒgi—˜—p
15 * ŽÒƒ}ƒjƒ…
16ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L
17 * ‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
18 * (3) –{ƒ\ƒtƒgƒEƒFƒA‚ðC‹@Ší‚É‘g‚ݍž‚ނȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
19 * —p‚Å‚«‚È‚¢Œ`‚ōĔz•z‚·‚éê‡‚ɂ́CŽŸ‚Ì‚¢‚¸‚ê‚©‚ÌðŒ‚ð–ž‚½‚·‚±
20 * ‚ƁD
21 * (a) Ä”z•z‚É”º‚¤ƒhƒLƒ…
22ƒƒ“ƒgi—˜—pŽÒƒ}ƒjƒ…
23ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜
24 * ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
25 * (b) Ä”z•z‚ÌŒ`‘Ô‚ðC•Ê‚É’è‚ß‚é•û–@‚É‚æ‚Á‚āCTOPPERSƒvƒƒWƒFƒNƒg‚É
26 * •ñ‚·‚邱‚ƁD
27 * (4) –{ƒ\ƒtƒgƒEƒFƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚é‚¢‚©‚Ȃ鑹
28 * ŠQ‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð–Ɛӂ·‚邱‚ƁD
29 * ‚Ü‚½C–{ƒ\ƒtƒgƒEƒFƒA‚̃†[ƒU‚Ü‚½‚̓Gƒ“ƒhƒ†[ƒU‚©‚ç‚Ì‚¢‚©‚Ȃ闝
30 * —R‚ÉŠî‚­¿‹‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð
31 * –Ɛӂ·‚邱‚ƁD
32 *
33 * –{ƒ\ƒtƒgƒEƒFƒA‚́C–³•ÛØ‚Å’ñ‹Ÿ‚³‚ê‚Ä‚¢‚é‚à‚Ì‚Å‚ ‚éDã‹L’˜ìŒ ŽÒ‚¨
34 * ‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚́C–{ƒ\ƒtƒgƒEƒFƒA‚ÉŠÖ‚µ‚āC“Á’è‚ÌŽg—p–Ú“I
35 * ‚ɑ΂·‚é“K‡«‚àŠÜ‚߂āC‚¢‚©‚È‚é•ÛØ‚às‚í‚È‚¢D‚Ü‚½C–{ƒ\ƒtƒgƒEƒF
36 * ƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚½‚¢‚©‚Ȃ鑹ŠQ‚ÉŠÖ‚µ‚Ä‚àC‚»
37 * ‚̐ӔC‚𕉂í‚È‚¢D
38 *
39 * @(#) $Id: wamp.h 101 2015-06-02 15:37:23Z coas-nagasima $
40 */
41
42#ifndef WAMP_H
43#define WAMP_H
44
45#include "jsonsl.h"
46#include "echonet_fbs.h"
47#include "wamp_router.h"
48#include "wamp_client.h"
49#include "wamp_broker.h"
50#include "wamp_publisher.h"
51#include "wamp_subscriber.h"
52#include "wamp_dealer.h"
53#include "wamp_caller.h"
54#include "wamp_callee.h"
55
56#define JSN_NLEVELS 10
57
58/* ƒp[ƒXƒGƒ‰[ */
59extern const char parse_error[];
60/* –³Œø‚ȃŠƒNƒGƒXƒg */
61extern const char invalid_request[];
62/* ‘¶Ý‚µ‚È‚¢ƒƒ\ƒbƒh */
63extern const char method_not_found[];
64/* echo object‚ª‘¶Ý‚µ‚È‚¢,@JSONArrayŒ`Ž®‚É‚È‚Á‚Ä‚¢‚È‚¢ */
65extern const char invalid_params[];
66/* ƒ^ƒCƒ€ƒAƒEƒg”­¶, ƒR[ƒ‹ƒoƒbƒN‚ª@null*/
67extern const char internal_error[];
68
69typedef enum wamp_code{
70 WAMP_CODE_NONE = 0,
71 WAMP_CODE_HELLO = 1,
72 WAMP_CODE_WELCOME = 2,
73 WAMP_CODE_ABORT = 3,
74 WAMP_CODE_CHALLENGE = 4,
75 WAMP_CODE_AUTHENTICATE = 5,
76 WAMP_CODE_GOODBYE = 6,
77 WAMP_CODE_ERROR = 8,
78 WAMP_CODE_PUBLISH = 16,
79 WAMP_CODE_PUBLISHED = 17,
80 WAMP_CODE_SUBSCRIBE = 32,
81 WAMP_CODE_SUBSCRIBED = 33,
82 WAMP_CODE_UNSUBSCRIBE = 34,
83 WAMP_CODE_UNSUBSCRIBED = 35,
84 WAMP_CODE_EVENT = 36,
85 WAMP_CODE_CALL = 48,
86 WAMP_CODE_CANCEL = 49,
87 WAMP_CODE_RESULT = 50,
88 WAMP_CODE_REGISTER = 64,
89 WAMP_CODE_REGISTERED = 65,
90 WAMP_CODE_UNREGISTER = 66,
91 WAMP_CODE_UNREGISTERED = 67,
92 WAMP_CODE_INVOCATION = 68,
93 WAMP_CODE_INTERRUPT = 69,
94 WAMP_CODE_YIELD = 70,
95} wamp_code_t;
96
97typedef enum wamp_parse_state{
98 WAMP_PARSE_STATE_IDLE,
99 WAMP_PARSE_STATE_CODE_PUSH,
100 WAMP_PARSE_STATE_CODE_POP,
101 WAMP_PARSE_STATE_ID_PUSH,
102 WAMP_PARSE_STATE_LIST_PUSH,
103 WAMP_PARSE_STATE_DICT_PUSH,
104 WAMP_PARSE_STATE_URI_PUSH,
105 WAMP_PARSE_STATE_INT_PUSH,
106 WAMP_PARSE_STATE_STRING_PUSH,
107 WAMP_PARSE_STATE_PARAM,
108 WAMP_PARSE_STATE_NOMORE_PARAM,
109 WAMP_PARSE_STATE_ERROR
110} wamp_parse_state_t;
111
112typedef enum wamp_param_state
113{
114 WAMP_PARAM_STATE_NONE,
115 WAMP_PARAM_STATE_SESSION_ID,
116 WAMP_PARAM_STATE_REQUEST_ID,
117 WAMP_PARAM_STATE_REGISTRATION_ID,
118 WAMP_PARAM_STATE_SUBSCRIPTION_ID,
119 WAMP_PARAM_STATE_PUBLICATION_ID,
120 WAMP_PARAM_STATE_ARGUMENTS_LIST,
121 WAMP_PARAM_STATE_OPTIONS_DICT,
122 WAMP_PARAM_STATE_DETAILS_DICT,
123 WAMP_PARAM_STATE_ARGUMENTSKW_DICT,
124 WAMP_PARAM_STATE_EXTRA_DICT,
125 WAMP_PARAM_STATE_REALM_URI,
126 WAMP_PARAM_STATE_PROCEDURE_URI,
127 WAMP_PARAM_STATE_REASON_URI,
128 WAMP_PARAM_STATE_TOPIC_URI,
129 WAMP_PARAM_STATE_ERROR_URI,
130 WAMP_PARAM_STATE_TYPE_INT,
131 WAMP_PARAM_STATE_AUTHMETHOD_STRING,
132 WAMP_PARAM_STATE_SIGNATURE_STRING,
133} wamp_param_state_t;
134
135typedef void (* wamp_proc_handler_t)(struct wamp_state *s, jsonsl_action_t action,
136 struct jsonsl_state_st *state, const char *buf);
137
138typedef void (*wamp_param_handler_t)(struct wamp_state *s, jsonsl_action_t action,
139 wamp_param_state_t param, const char *value);
140
141typedef void (*wamp_message_close_handler_t)(struct wamp_state *s);
142
143typedef struct wamp_state
144{
145 char jsn[sizeof(struct jsonsl_st) + ((JSN_NLEVELS - 1) * sizeof(struct jsonsl_state_st))];
146 wamp_parse_state_t state;
147 wamp_param_state_t prmst;
148 wamp_code_t code;
149 wamp_proc_handler_t proc_handler;
150 wamp_param_handler_t param_handler;
151 wamp_message_close_handler_t message_close_handler;
152 ID wbsid;
153 char jsn_buf[80];
154 int jsn_buf_pos;
155 wamp_router_t router;
156 wamp_client_t client;
157 wamp_broker_t broker;
158 wamp_dealer_t dealer;
159 wamp_publisher_t publisher;
160 wamp_subscriber_t subscriber;
161 wamp_caller_t caller;
162 wamp_callee_t callee;
163} wamp_state_t;
164
165void wamp_init(wamp_state_t *s);
166void wamp_put_msg(wamp_state_t *s, ECN_FBS_ID msg, ID wbsid);
167void wamp_state_callback(jsonsl_t jsn, jsonsl_action_t action,
168 struct jsonsl_state_st *state, const char *buf);
169int wamp_error_callback(jsonsl_t jsn, jsonsl_error_t err,
170 struct jsonsl_state_st *state, char *errat);
171ER wamp_send_error_res(struct wamp_state *s, wamp_code_t code,
172 int requestId, const char *error);
173
174#endif /* WAMP_H */
Note: See TracBrowser for help on using the repository browser.