Skip to content

Commit

Permalink
Add new APIs to get the server-side RPC ID and session number in a
Browse files Browse the repository at this point in the history
request handler
  • Loading branch information
anujkaliaiitd committed Oct 20, 2021
1 parent dc0b97f commit 9db05ce
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ set(SOURCES
src/rpc_impl/rpc_fault_inject.cc
src/rpc_impl/rpc_pkt_loss.cc
src/rpc_impl/rpc_rx.cc
src/rpc_impl/rpc_sslot.cc
src/rpc_impl/rpc_connect_handlers.cc
src/rpc_impl/rpc_disconnect_handlers.cc
src/rpc_impl/rpc_reset_handlers.cc
Expand Down
4 changes: 4 additions & 0 deletions scripts/linux_autorun_process_file
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
erpc-1 31850 0
erpc-2 31850 0
erpc-3 31850 0
erpc-4 31850 0
15 changes: 15 additions & 0 deletions src/rpc_impl/rpc_sslot.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "rpc.h"

namespace erpc {

uint8_t ReqHandle::get_server_rpc_id() const {
return session_->server_.rpc_id_;
}

uint16_t ReqHandle::get_server_session_num() const {
return session_->server_.session_num_;
}

FORCE_COMPILE_TRANSPORTS

} // namespace erpc
1 change: 1 addition & 0 deletions src/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Rpc;
/// A one-to-one session class for all transports
class Session {
friend class Rpc<CTransport>;
friend class ReqHandle;

public:
enum class Role : int { kServer, kClient };
Expand Down
11 changes: 11 additions & 0 deletions src/sslot.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,21 @@ class SSlot {
size_t get_cur_req_num() const { return cur_req_num_; }
};

/// Handle object passed by eRPC to the application's request handler callbacks
class ReqHandle : public SSlot {
public:
/// Get this RPC's request message buffer. Valid until the request handler
/// enqueues a response.
inline const MsgBuffer *get_req_msgbuf() const {
return &server_info_.req_msgbuf_;
}

/// Get the RPC ID of the server-side RPC object that received this request
/// from the network. Valid until the request handler enqueues a response.
uint8_t get_server_rpc_id() const;

/// Get the server-side session number for this request. Valid until the
/// request handler enqueues a response.
uint16_t get_server_session_num() const;
};
} // namespace erpc

0 comments on commit 9db05ce

Please sign in to comment.