%%% ``The contents of this file are subject to the Erlang Public License, %%% Version 1.1, (the "License"); you may not use this file except in %%% compliance with the License. You should have received a copy of the %%% Erlang Public License along with this software. If not, it can be %%% retrieved via the world wide web at http://www.erlang.org/. %%% %%% Software distributed under the License is distributed on an "AS IS" %%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %%% the License for the specific language governing rights and limitations %%% under the License. %%% %%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. %%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings %%% AB. All Rights Reserved.'' %%%------------------------------------------------------------------- %%% File : vccTransport.hrl %%% Author : Ulf Wiger %%% Description : %%% %%% Created : 7 Sep 2005 by Ulf Wiger %%%------------------------------------------------------------------- -define(MAX_VCHANS, 254). -define(MAX_GROUPS, 255). -define(MAX_TEMP_CHANNELS, 16#ffffFFFF). -record(state, { channel, protocol, my_version, my_cookie, his_version, his_cookie, am_leader = false, start_connector, start_listener, connector, listener, heart, host, port, my_port, init_ack, send_sock, recv_sock, listen_sock, conn_opts = [], vc_opts = [], % [{static, Info} | ...] heartbeat = {3, 30000}, % trigger on 3 lost, within 30 secs parent, report_level = debug, %% Bounds should be configurable rh}). -record(msg_opts, {vc, type = static, on_receive, % undefined | function/3 close = manually}). % manually | on_reply %%% Virtual channel data -record(vc, { id, type = static, % static | #dynamic{} remote_id, send_fun, recv_fun, send_transform, recv_transform, on_send, on_receive, encode, decode}). -record(dynamic, { template, remote_template, opts, timer}). %%% --- %%% Resource handling records -record(rh, { dynamic, static, data = ets:new(vccRh_data, [set])}). -record(range, { min, max, free}). %%% --- %%% Message format: %%% %%% +12345678-12345678-12345678-12345678+ %%% | 1 | 2 | 3 | 4 | %%% +--------+--------+--------+--------+ %%% | < p a c k e t s i z e > | ({packet,4} option) %%% +--------+--------+--------+--------+ %%% | OpCode | Flags | Expansion | %%% +--------+--------+--------+--------+ %%% | . . . | %%% 32-bit aligned to ease decoding in C %%% (for Erlang, 8-bit aligned is just fine.) %%% %%% OpCodes - one byte %%% -define(PROTOCOL, 0). -define(STRAIGHT_THROUGH, 1). -define(OFFER, 2). -define(OFFER_RESP, 3). -define(OFFER_ACK, 4). -define(MONITOR, 5). -define(DEMONITOR, 6). -define(MON_DOWN, 7). -define(TICK, 8). -define(ADD_GROUP, 9). -define(DROP_GROUP, 10). -define(OPEN_CHANNEL, 11). -define(MESSAGE, 12). % <> -define(ERROR, 13). % <> -define(REPLY, 14). % <> -define(WILL_CONNECT, 15). -define(WILL_LISTEN, 16). -define(ADM_MSG, 17). %% error messages -define(RESULT_OK, 0). -define(RESULT_ERROR, 1). -define(FLAG_SET(Byte, FLAG), ((Byte band FLAG) == FLAG)). %% ?MSG Channel Modifiers -define(CHN_TMP_CHAN, 2#00000001). -define(CHN_CLOSE_ON_REPLY, 2#00000010). %% aggregate pattern %% ?REPLY Flags -define(RPLY_RESTART_TIMER, 2#00000001). -define(RPLY_MONITOR, 2#00000010). -define(RPLY_BIG_MREF, 2#00000100). -define(BULK, 2#11000000). % multiple msgs, same channel, 224-225 -define(BULK_TMP_CHAN, 2#00000001). %% modifiers for ?MSG: -define(HANDSHAKE_TIMEOUT, 5000). -define(EXIT_ON_CLOSE, {tcp_closed, _} -> erlang:fault(socket_closed)). -define(DEFAULT_TMP_TIMEOUT, 10000).