alfred: introduce 'server status' IPC call
PATCH v2 1/1 alfred: introduce 'server status' IPC call
The 'server status' call exports the 'mode' as well as interface status via IPC. Both parameters can be modified at runtime via the IPC and as such, the current configuration is dynamic and not necessarily obvious.
The server status 'request' and 'reply' packet types are added to allow the IPC client to initiate the status retrieval. The server will respond with the 'reply' message.
The information is encapsulated in TLV data chunks allowing for future backward compatible extension of the server status call.
Signed-off-by Marek Lindner <[email protected]>
--- alfred.h | 2 + client.c | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++ main.c | 9 +++- man/alfred.8 | 3 ++ packet.h | 65 +++++++++++++++++++++++++++++ unix_sock.c | 83 ++++++++++++++++++++++++++++++++++++ 6 files changed, 277 insertions(+), 1 deletion(-)
alfred.h +2 -0
@@ -93,6 +93,7 @@ enum clientmode {CLIENT_MODESWITCH ,CLIENT_CHANGE_INTERFACE ,CLIENT_CHANGE_BAT_IFACE , + CLIENT_SERVER_STATUS, }; struct interface {
@@ -155,6 +156,7 @@ int alfred_client_set_data(struct globals *globals);int alfred_client_modeswitch (struct globals *globals);int alfred_client_change_interface (struct globals *globals);int alfred_client_change_bat_iface (struct globals *globals); +int alfred_client_server_status (struct globals *globals);/* recv.c */ int recv_alfred_packet (struct globals *globals,struct interface *interface,int recv_sock);
client.c +116 -0
119 lines not on this page · raw message
main.c +8 -1
@@ -38,6 +38,7 @@ static void alfred_usage(void)printf (" secondary switch daemon to mode secondary\n" );printf (" -I, --change-interface [interface] change to the specified interface(s)\n" );printf (" -B, --change-bat-iface [interface] change to the specified batman-adv interface\n" ); +printf (" -S, --server-status request server status info such as mode & interfaces\n" );printf ("\n" );printf ("server mode options:\n" );printf (" -i, --interface specify the interface (or comma separated list of interfaces) to listen on\n" );
@@ -162,6 +163,7 @@ static struct globals *alfred_init(int argc, char *argv[]) {"modeswitch", required_argument, NULL, 'M'}, {"change-interface", required_argument, NULL, 'I'}, {"change-bat-iface", required_argument, NULL, 'B'}, + {"server-status", required_argument, NULL, 'S'}, {"unix-path", required_argument, NULL, 'u'}, {"update-command", required_argument, NULL, 'c'}, {"version", no_argument, NULL, 'v'},
@@ -196,7 +198,7 @@ static struct globals *alfred_init(int argc, char *argv[])time_random_seed (); -while ((opt =getopt_long (argc, argv,"ms:r:hi:b:vV:M:I:B:u:dc:p:4:f" , long_options, +while ((opt =getopt_long (argc, argv,"ms:r:hi:b:vV:M:I:B:Su:dc:p:4:f" , long_options, &opt_ind)) !=-1 ) {switch (opt) {case 'r' :
@@ -258,6 +260,9 @@ static struct globals *alfred_init(int argc, char *argv[]) globals->clientmode =CLIENT_CHANGE_BAT_IFACE ; globals->mesh_iface =strdup (optarg);break ; +case 'S' : + globals->clientmode =CLIENT_SERVER_STATUS ; +break ;case 'u' : globals->unix_path = optarg;break ;
@@ -321,6 +326,8 @@ int main(int argc, char *argv[])return alfred_client_change_interface (globals);case CLIENT_CHANGE_BAT_IFACE :return alfred_client_change_bat_iface (globals); +case CLIENT_SERVER_STATUS : +return alfred_client_server_status (globals); }return 0 ;
man/alfred.8 +3 -0
@@ -94,6 +94,9 @@ Change the alfred server to use the new \fBinterface\fP(s) .TP \fB\-B\fP, \fB\-\-change\-bat\-iface\fP \fIinterface\fP Change the alfred server to use the new \fBbatman-adv interface\fP +.TP +\fB\-S\fP, \fB\-\-server\-status\fP +Request server status information such as mode & interfaces\fP . .SH SERVER OPTIONS .TP
packet.h +65 -0
77 lines not on this page · raw message
unix_sock.c +83 -0
95 lines not on this page · raw message
Signature · 1 line
2.32.0.rc0