|
Document of c-modernization-kit (porter) 1.0.0
|
N:1 モード用ピアテーブル管理モジュールの内部ヘッダー。 More...
Go to the source code of this file.
Functions | |
| void | peer_send_fin (struct PotrContext_ *ctx, PotrPeerContext *peer) |
| ピアの全パスへ FIN パケットを送信する。 | |
| int | peer_table_init (struct PotrContext_ *ctx) |
| ピアテーブルを初期化する。 | |
| void | peer_table_destroy (struct PotrContext_ *ctx) |
| ピアテーブルを破棄する。 | |
| PotrPeerContext * | peer_find_by_session (struct PotrContext_ *ctx, uint32_t session_id, int64_t session_tv_sec, int32_t session_tv_nsec) |
| session_triplet でピアを検索する。 | |
| PotrPeerContext * | peer_find_by_id (struct PotrContext_ *ctx, PotrPeerId peer_id) |
| peer_id でピアを検索する。 | |
| PotrPeerContext * | peer_create (struct PotrContext_ *ctx, const struct sockaddr_in *sender_addr, int path_idx) |
| 新規ピアを作成する。 | |
| void | peer_path_clear (struct PotrContext_ *ctx, PotrPeerContext *peer, int path_idx) |
| ピアの特定パスをクリアしてスロットを未使用に戻す。 | |
| void | peer_free (struct PotrContext_ *ctx, PotrPeerContext *peer) |
| ピアリソースを解放してスロットをクリアする。 | |
N:1 モード用ピアテーブル管理モジュールの内部ヘッダー。
POTR_TYPE_UNICAST_BIDIR の N:1 モード (src 情報省略) において、 複数クライアントピアの状態を管理するユーティリティです。
is_multi_peer == 1 のときのみ有効。
Definition in file potrPeerTable.h.
|
extern |
ピアの全パスへ FIN パケットを送信する。
ピアの dest_addr[] に対して FIN パケットを直接 sendto する。\n 呼び出し元は peers_mutex を取得してから呼び出すこと。
| [in,out] | ctx | セッションコンテキスト。 |
| [in] | peer | FIN を送信するピアコンテキスト。 |
Definition at line 117 of file potrPeerTable.c.
References PotrPeerContext_::dest_addr, PotrServiceDef::encrypt_enabled, PotrServiceDef::encrypt_key, PotrPacket::flags, packet_build_fin(), PACKET_HEADER_SIZE, packet_wire_size(), PotrPacket::payload_len, POTR_CRYPTO_NONCE_SIZE, POTR_CRYPTO_TAG_SIZE, potr_encrypt(), POTR_FLAG_ENCRYPTED, POTR_INVALID_SOCKET, POTR_MAX_PATH, POTR_SUCCESS, PotrContext_::service, PotrPacketSessionHdr::service_id, PotrServiceDef::service_id, PotrPacket::session_id, PotrPacketSessionHdr::session_id, PotrPeerContext_::session_id, PotrPacketSessionHdr::session_tv_nsec, PotrPeerContext_::session_tv_nsec, PotrPacketSessionHdr::session_tv_sec, PotrPeerContext_::session_tv_sec, and PotrContext_::sock.
Referenced by peer_table_destroy(), and potrDisconnectPeer().
|
extern |
ピアテーブルを初期化する。
ctx->peers を max_peers 分確保し、peers_mutex を初期化する。
ctx->max_peers, ctx->n_peers, ctx->next_peer_id を設定する。
| [in,out] | ctx | セッションコンテキスト。 |
Definition at line 197 of file potrPeerTable.c.
References PotrPeerContext_::active, PotrContext_::max_peers, PotrContext_::n_peers, PotrContext_::next_peer_id, PotrContext_::peers, PotrContext_::peers_mutex, POTR_ERROR, POTR_LOG, POTR_MUTEX_INIT, POTR_SUCCESS, POTR_TRACE_ERROR, POTR_TRACE_VERBOSE, PotrContext_::service, and PotrServiceDef::service_id.
Referenced by potrOpenService().
|
extern |
ピアテーブルを破棄する。
全アクティブピアに FIN を送信し、リソースを解放する。
peers_mutex を解放する。
| [in,out] | ctx | セッションコンテキスト。 |
Definition at line 228 of file potrPeerTable.c.
References PotrPeerContext_::active, PotrPeerContext_::frag_buf, PotrContext_::max_peers, PotrContext_::n_peers, peer_send_fin(), PotrContext_::peers, PotrContext_::peers_mutex, POTR_LOG, POTR_MUTEX_DESTROY, POTR_TRACE_VERBOSE, PotrPeerContext_::recv_window, PotrPeerContext_::send_window, PotrPeerContext_::send_window_mutex, PotrContext_::service, PotrServiceDef::service_id, and window_destroy().
Referenced by ctx_cleanup(), and potrCloseService().
|
extern |
session_triplet でピアを検索する。
ピアテーブルを線形探索し、session_id / session_tv_sec / session_tv_nsec が 一致するアクティブなエントリを返す。
呼び出し元は peers_mutex を取得してから呼び出すこと。
| [in] | ctx | セッションコンテキスト。 |
| [in] | session_id | ピアのセッション識別子。 |
| [in] | session_tv_sec | ピアのセッション開始時刻 秒部。 |
| [in] | session_tv_nsec | ピアのセッション開始時刻 ナノ秒部。 |
Definition at line 268 of file potrPeerTable.c.
References PotrPeerContext_::active, PotrContext_::max_peers, PotrPeerContext_::peer_session_id, PotrPeerContext_::peer_session_tv_nsec, PotrPeerContext_::peer_session_tv_sec, and PotrContext_::peers.
Referenced by recv_thread_func().
|
extern |
peer_id でピアを検索する。
呼び出し元は peers_mutex を取得してから呼び出すこと。
| [in] | ctx | セッションコンテキスト。 |
| [in] | peer_id | 検索するピア ID。 |
Definition at line 292 of file potrPeerTable.c.
References PotrPeerContext_::active, PotrContext_::max_peers, PotrPeerContext_::peer_id, and PotrContext_::peers.
Referenced by potrDisconnectPeer(), potrSend(), and send_packed_peer_mode().
|
extern |
新規ピアを作成する。
空きスロットを確保し、session_id/session_tv を生成してウィンドウを初期化する。
送信元アドレスを dest_addr[path_idx] に記録し、n_paths を 1 に設定する。
dest_addr[] のインデックスは ctx->sock[] / src_addr[] と直接対応する。
path_last_recv_sec[path_idx] は後続の n1_update_path_recv() 呼び出しで設定される。
max_peers 超過時はログエラー後 NULL を返す。
呼び出し元は peers_mutex を取得してから呼び出すこと。
| [in,out] | ctx | セッションコンテキスト。 |
| [in] | sender_addr | ピアの送信元アドレス (recvfrom で取得したアドレス)。 |
| [in] | path_idx | パケットを受信したサーバソケットのインデックス (ctx->sock[] の添字)。 |
Definition at line 307 of file potrPeerTable.c.
References PotrPeerContext_::active, allocate_peer_id(), PotrPeerContext_::dest_addr, PotrPeerContext_::frag_buf, PotrPeerContext_::frag_buf_len, PotrPeerContext_::frag_compressed, PotrContext_::global, PotrGlobalConfig::max_message_size, PotrGlobalConfig::max_payload, PotrContext_::max_peers, PotrPeerContext_::n_paths, PotrContext_::n_peers, PotrPeerContext_::path_last_recv_sec, peer_generate_session(), PotrPeerContext_::peer_id, PotrContext_::peers, POTR_LOG, POTR_MUTEX_DESTROY, POTR_MUTEX_INIT, POTR_SUCCESS, POTR_TRACE_ERROR, POTR_TRACE_INFO, PotrPeerContext_::recv_window, PotrPeerContext_::send_window, PotrPeerContext_::send_window_mutex, PotrContext_::service, PotrServiceDef::service_id, window_destroy(), window_init(), and PotrGlobalConfig::window_size.
Referenced by recv_thread_func().
|
extern |
ピアの特定パスをクリアしてスロットを未使用に戻す。
dest_addr[path_idx] をゼロクリアし、path_last_recv_sec/nsec をリセット後 n_paths を減算する。
タイムアウト・TCP FIN/RST などパス断の発生源によらず共通して呼び出す。
呼び出し元は peers_mutex を取得してから呼び出すこと。
| [in,out] | ctx | セッションコンテキスト。 |
| [in,out] | peer | 対象ピアコンテキスト。 |
| [in] | path_idx | クリアするパスのインデックス (ctx->sock[] の添字)。 |
Definition at line 410 of file potrPeerTable.c.
References PotrPeerContext_::dest_addr, PotrPeerContext_::n_paths, PotrPeerContext_::path_last_recv_nsec, PotrPeerContext_::path_last_recv_sec, PotrPeerContext_::peer_id, POTR_LOG, POTR_TRACE_WARNING, PotrContext_::service, and PotrServiceDef::service_id.
Referenced by n1_check_health_timeout().
|
extern |
ピアリソースを解放してスロットをクリアする。
ウィンドウ破棄・frag_buf 解放・send_window_mutex 解放・スロットクリアを行う。
呼び出し元は peers_mutex を取得してから呼び出すこと。
FIN の送信は呼び出し元が行うこと (本関数は送信しない)。
| [in,out] | ctx | セッションコンテキスト。 |
| [in,out] | peer | 解放するピアコンテキスト。 |
Definition at line 428 of file potrPeerTable.c.
References PotrPeerContext_::active, PotrPeerContext_::frag_buf, PotrContext_::n_peers, PotrPeerContext_::peer_id, POTR_LOG, POTR_MUTEX_DESTROY, POTR_TRACE_INFO, PotrPeerContext_::recv_window, PotrPeerContext_::send_window, PotrPeerContext_::send_window_mutex, PotrContext_::service, PotrServiceDef::service_id, and window_destroy().
Referenced by n1_check_health_timeout(), potrDisconnectPeer(), and recv_thread_func().