mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-03 14:23:02 +02:00
klinfix: add new commands ping and tcpdump, w/ interface completion
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
committed by
Tobias Waldekranz
parent
10684d200f
commit
883d59709e
@@ -46,6 +46,13 @@ int klix_files(kcontext_t *ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int klix_ifaces(kcontext_t *ctx)
|
||||
{
|
||||
(void)ctx;
|
||||
system("ls /sys/class/net");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int klix_ds_from_str(const char *text, sr_datastore_t *ds)
|
||||
{
|
||||
size_t len = strlen(text);
|
||||
@@ -148,6 +155,8 @@ int klix_commit(kcontext_t *ctx)
|
||||
sr_conn_ctx_t *conn;
|
||||
int err;
|
||||
|
||||
(void)ctx;
|
||||
|
||||
if (sr_connect(SR_CONN_DEFAULT, &conn)) {
|
||||
fprintf(stderr, "Error: Connection to datastore failed\n");
|
||||
goto err;
|
||||
@@ -243,6 +252,8 @@ err:
|
||||
|
||||
int kplugin_klinfix_fini(kcontext_t *ctx)
|
||||
{
|
||||
(void)ctx;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -253,6 +264,7 @@ int kplugin_klinfix_init(kcontext_t *ctx)
|
||||
kplugin_add_syms(plugin, ksym_new("klix_copy", klix_copy));
|
||||
kplugin_add_syms(plugin, ksym_new("klix_commit", klix_commit));
|
||||
kplugin_add_syms(plugin, ksym_new("klix_files", klix_files));
|
||||
kplugin_add_syms(plugin, ksym_new("klix_ifaces", klix_ifaces));
|
||||
kplugin_add_syms(plugin, ksym_new("klix_rpc", klix_rpc));
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -94,6 +94,13 @@
|
||||
<ACTION sym="STRING"/>
|
||||
</PTYPE>
|
||||
|
||||
<PTYPE name="PORTAR">
|
||||
<COMPL>
|
||||
<ACTION sym="klix_ifaces@klinfix"/>
|
||||
</COMPL>
|
||||
<ACTION sym="STRING"/>
|
||||
</PTYPE>
|
||||
|
||||
<VIEW name="main">
|
||||
<HOTKEY key="^D" cmd="exit"/>
|
||||
|
||||
@@ -283,6 +290,54 @@
|
||||
</ACTION>
|
||||
</COMMAND>
|
||||
|
||||
<COMMAND name="ping" help="Ping a network host or multicast group">
|
||||
<SWITCH name="optional" min="0">
|
||||
<COMMAND name="interface" help="Bypass routing table and use this interface">
|
||||
<PARAM name="iface" ptype="/PORTAR" help="Interface"/>
|
||||
</COMMAND>
|
||||
<COMMAND name="count" help="Number of packets to send, default: unlimited">
|
||||
<PARAM name="cnt" ptype="/UINT"/>
|
||||
</COMMAND>
|
||||
<COMMAND name="size" help="Define size of empty payload of packets">
|
||||
<PARAM name="sz" ptype="/UINT"/>
|
||||
</COMMAND>
|
||||
<COMMAND name="ttl" help="TTL to set in packets, default: 64 (multicast: 1)">
|
||||
<PARAM name="ttl" ptype="/UINT"/>
|
||||
</COMMAND>
|
||||
<COMMAND name="flood" help="Flood ping mode"/>
|
||||
</SWITCH>
|
||||
<PARAM name="addr" ptype="/STRING" help="Host address or multicast group"/>
|
||||
<ACTION sym="script" interactive="true">
|
||||
count=${KLISH_PARAM_cnt:+-c $KLISH_PARAM_cnt}
|
||||
iface=${KLISH_PARAM_iface:+-I $KLISH_PARAM_iface}
|
||||
size=${KLISH_PARAM_sz:+-s $KLISH_PARAM_sz}
|
||||
ttl=${KLISH_PARAM_ttl:+-t $KLISH_PARAM_ttl}
|
||||
flood=${KLISH_PARAM_flood:+-f}
|
||||
ping $iface $flood $count $size $ttl $KLISH_PARAM_addr
|
||||
</ACTION>
|
||||
</COMMAND>
|
||||
|
||||
<COMMAND name="tcpdump" help="Capture network traffic">
|
||||
<PARAM name="iface" ptype="/PORTAR" help="Interrface to run capture on"/>
|
||||
<SWITCH name="optional" min="0">
|
||||
<COMMAND name="count" help="Number of packets to capture, default: unlimited">
|
||||
<PARAM name="count" ptype="/UINT"/>
|
||||
</COMMAND>
|
||||
<COMMAND name="size" help="Number of bytes of each packet to capture">
|
||||
<PARAM name="sz" ptype="/UINT"/>
|
||||
</COMMAND>
|
||||
<COMMAND name="expression" help="Optional pcap filter expression">
|
||||
<PARAM name="expr" ptype="/STRING"/>
|
||||
</COMMAND>
|
||||
<COMMAND name="verbose" help="Verbose output"/>
|
||||
</SWITCH>
|
||||
<ACTION sym="script" interactive="true">
|
||||
count=${KLISH_PARAM_cnt:+-c $KLISH_PARAM_cnt}
|
||||
size=${KLISH_PARAM_sz:+-s $KLISH_PARAM_sz}
|
||||
verbose=${KLISH_PARAM_verbose:+-vvv}
|
||||
tcpdump -ln $count $size $verbose -i $KLISH_PARAM_iface $KLISH_PARAM_expr
|
||||
</ACTION>
|
||||
</COMMAND>
|
||||
</VIEW>
|
||||
|
||||
<VIEW name="config">
|
||||
|
||||
Reference in New Issue
Block a user