Bug 2186 - Add ns3::Callback capability to DCE-Linux SysctlGet API
Add ns3::Callback capability to DCE-Linux SysctlGet API
Status: NEW
Product: dce
Classification: Unclassified
Component: kernel
unspecified
All All
: P5 enhancement
Assigned To: Hajime Tazaki
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2015-09-27 20:02 EDT by Chip Webb
Modified: 2015-09-28 09:44 EDT (History)
2 users (show)

See Also:


Attachments
Patch to implement the described enhancement (3.51 KB, patch)
2015-09-27 20:02 EDT, Chip Webb
Details | Diff
Example code that uses proposed new API (39.34 KB, text/x-csrc)
2015-09-28 09:44 EDT, Chip Webb
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chip Webb 2015-09-27 20:02:13 EDT
Created attachment 2152 [details]
Patch to implement the described enhancement

When running a DCE-Linux simulation, the current API for LinuxStackHelper::SysctlGet requires passing a function pointer [void (*callback)(std::string,std::string)] to a callback function. This function is then called after the Sysctl Get is executed. The parameters passed to the function include "path" std::string that was queried, and the "value" std::string that the kernel returned.

If the simulation has more than one DCE-Linux node that use this API, then it can be difficult to tell which node returned which value. A simple solution is to define a separate function for each node, but this is neither convenient nor good coding practice, especially as the number of nodes increases.

A better and more elegant way would be to define an overloaded API call that uses an ns3::Callback instead of a function pointer. The ns3::Callback can be a Bound Callback that has extra arguments (like a functor or closure).

The attached patch implements the additional API that uses a Callback.
Comment 1 Chip Webb 2015-09-28 09:44:00 EDT
Created attachment 2154 [details]
Example code that uses proposed new API

There is a #define on line #141 that controls whether the original or the new (proposed) API is used.

     //#define NEW_SYSCTLGET_CALLBACK_API

It is commented out and when commented out, the example code will use the original API.

If it is uncommented, and the #define takes effect, the example code will use the new (proposed) API.