Merge pull request #5038 from cgundogan/pr/pktdump/global_pid
gnrc_pktdump: make pid global
This commit is contained in:
commit
78136ff25f
@ -55,7 +55,7 @@ int main(void)
|
||||
#ifdef MODULE_NETIF
|
||||
gnrc_netreg_entry_t dump;
|
||||
|
||||
dump.pid = gnrc_pktdump_getpid();
|
||||
dump.pid = gnrc_pktdump_pid;
|
||||
dump.demux_ctx = GNRC_NETREG_DEMUX_CTX_ALL;
|
||||
gnrc_netreg_register(GNRC_NETTYPE_UNDEF, &dump);
|
||||
#endif
|
||||
|
||||
@ -103,7 +103,7 @@ static void start_server(char *port_str)
|
||||
return;
|
||||
}
|
||||
/* start server (which means registering pktdump for the chosen port) */
|
||||
server.pid = gnrc_pktdump_getpid();
|
||||
server.pid = gnrc_pktdump_pid;
|
||||
server.demux_ctx = (uint32_t)port;
|
||||
gnrc_netreg_register(GNRC_NETTYPE_UDP, &server);
|
||||
printf("Success: started UDP server on port %" PRIu16 "\n", port);
|
||||
|
||||
@ -50,12 +50,9 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Get the PID of the pktdump thread
|
||||
*
|
||||
* @return PID of the pktdump thread
|
||||
* @return @ref KERNEL_PID_UNDEF if not initialized
|
||||
* @brief The PID of the pktdump thread
|
||||
*/
|
||||
kernel_pid_t gnrc_pktdump_getpid(void);
|
||||
extern kernel_pid_t gnrc_pktdump_pid;
|
||||
|
||||
/**
|
||||
* @brief Start the packet dump thread and listening for incoming packets
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
/**
|
||||
* @brief PID of the pktdump thread
|
||||
*/
|
||||
static kernel_pid_t _pid = KERNEL_PID_UNDEF;
|
||||
kernel_pid_t gnrc_pktdump_pid = KERNEL_PID_UNDEF;
|
||||
|
||||
/**
|
||||
* @brief Stack for the pktdump thread
|
||||
@ -154,17 +154,12 @@ static void *_eventloop(void *arg)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
kernel_pid_t gnrc_pktdump_getpid(void)
|
||||
{
|
||||
return _pid;
|
||||
}
|
||||
|
||||
kernel_pid_t gnrc_pktdump_init(void)
|
||||
{
|
||||
if (_pid == KERNEL_PID_UNDEF) {
|
||||
_pid = thread_create(_stack, sizeof(_stack), GNRC_PKTDUMP_PRIO,
|
||||
if (gnrc_pktdump_pid == KERNEL_PID_UNDEF) {
|
||||
gnrc_pktdump_pid = thread_create(_stack, sizeof(_stack), GNRC_PKTDUMP_PRIO,
|
||||
THREAD_CREATE_STACKTEST,
|
||||
_eventloop, NULL, "pktdump");
|
||||
}
|
||||
return _pid;
|
||||
return gnrc_pktdump_pid;
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ int main(void)
|
||||
|
||||
/* register the pktdump thread */
|
||||
puts("Register the packet dump thread for GNRC_NETTYPE_UNDEF packets");
|
||||
dump.pid = gnrc_pktdump_getpid();
|
||||
dump.pid = gnrc_pktdump_pid;
|
||||
dump.demux_ctx = GNRC_NETREG_DEMUX_CTX_ALL;
|
||||
gnrc_netreg_register(GNRC_NETTYPE_UNDEF, &dump);
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ int main(void)
|
||||
|
||||
/* register the pktdump thread */
|
||||
puts("Register the packet dump thread for GNRC_NETTYPE_UNDEF packets");
|
||||
dump.pid = gnrc_pktdump_getpid();
|
||||
dump.pid = gnrc_pktdump_pid;
|
||||
dump.demux_ctx = GNRC_NETREG_DEMUX_CTX_ALL;
|
||||
gnrc_netreg_register(GNRC_NETTYPE_UNDEF, &dump);
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ int main(void)
|
||||
gnrc_nomac_init(nomac_stack, sizeof(nomac_stack), 5, "nomac", &dev);
|
||||
|
||||
/* initialize packet dumper */
|
||||
netobj.pid = gnrc_pktdump_getpid();
|
||||
netobj.pid = gnrc_pktdump_pid;
|
||||
netobj.demux_ctx = GNRC_NETREG_DEMUX_CTX_ALL;
|
||||
gnrc_netreg_register(GNRC_NETTYPE_UNDEF, &netobj);
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ int main(void)
|
||||
puts("Xbee S1 device driver test");
|
||||
|
||||
/* initialize and register pktdump */
|
||||
dump.pid = gnrc_pktdump_getpid();
|
||||
dump.pid = gnrc_pktdump_pid;
|
||||
if (dump.pid <= KERNEL_PID_UNDEF) {
|
||||
puts("Error starting pktdump thread");
|
||||
return -1;
|
||||
|
||||
@ -35,7 +35,7 @@ int main(void)
|
||||
puts("SLIP test");
|
||||
|
||||
/* initialize and register pktdump */
|
||||
dump.pid = gnrc_pktdump_getpid();
|
||||
dump.pid = gnrc_pktdump_pid;
|
||||
dump.demux_ctx = GNRC_NETREG_DEMUX_CTX_ALL;
|
||||
|
||||
if (dump.pid <= KERNEL_PID_UNDEF) {
|
||||
|
||||
@ -35,7 +35,7 @@ int main(void)
|
||||
puts("ZEP module test");
|
||||
|
||||
/* initialize and register pktdump */
|
||||
dump.pid = gnrc_pktdump_getpid();
|
||||
dump.pid = gnrc_pktdump_pid;
|
||||
|
||||
if (dump.pid <= KERNEL_PID_UNDEF) {
|
||||
puts("Error starting pktdump thread");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user