Browse Source

all: fix for new netreg_entry_t structure

pr/spi.typo
Martine Lenders 7 years ago committed by Martine Lenders
parent
commit
0016463687
  1. 8
      examples/gnrc_networking/udp.c
  2. 2
      sys/net/gnrc/conn/ip/gnrc_conn_ip.c
  3. 4
      sys/net/gnrc/conn/udp/gnrc_conn_udp.c
  4. 2
      sys/net/gnrc/routing/rpl/gnrc_rpl.c
  5. 2
      tests/slip/main.c
  6. 6
      tests/unittests/tests-netreg/tests-netreg.c

8
examples/gnrc_networking/udp.c

@ -94,7 +94,7 @@ static void start_server(char *port_str)
uint16_t port;
/* check if server is already running */
if (server.pid != KERNEL_PID_UNDEF) {
if (server.target.pid != KERNEL_PID_UNDEF) {
printf("Error: server already running on port %" PRIu32 "\n",
server.demux_ctx);
return;
@ -106,7 +106,7 @@ static void start_server(char *port_str)
return;
}
/* start server (which means registering pktdump for the chosen port) */
server.pid = gnrc_pktdump_pid;
server.target.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);
@ -115,13 +115,13 @@ static void start_server(char *port_str)
static void stop_server(void)
{
/* check if server is running at all */
if (server.pid == KERNEL_PID_UNDEF) {
if (server.target.pid == KERNEL_PID_UNDEF) {
printf("Error: server was not running\n");
return;
}
/* stop server */
gnrc_netreg_unregister(GNRC_NETTYPE_UDP, &server);
server.pid = KERNEL_PID_UNDEF;
server.target.pid = KERNEL_PID_UNDEF;
puts("Success: stopped UDP server");
}

2
sys/net/gnrc/conn/ip/gnrc_conn_ip.c

@ -52,7 +52,7 @@ int conn_ip_create(conn_ip_t *conn, const void *addr, size_t addr_len, int famil
void conn_ip_close(conn_ip_t *conn)
{
assert(conn->l4_type == GNRC_NETTYPE_UNDEF);
if (conn->netreg_entry.pid != KERNEL_PID_UNDEF) {
if (conn->netreg_entry.target.pid != KERNEL_PID_UNDEF) {
gnrc_netreg_unregister(conn->l3_type, &conn->netreg_entry);
}
}

4
sys/net/gnrc/conn/udp/gnrc_conn_udp.c

@ -56,9 +56,9 @@ int conn_udp_create(conn_udp_t *conn, const void *addr, size_t addr_len,
void conn_udp_close(conn_udp_t *conn)
{
assert(conn->l4_type == GNRC_NETTYPE_UDP);
if (conn->netreg_entry.pid != KERNEL_PID_UNDEF) {
if (conn->netreg_entry.target.pid != KERNEL_PID_UNDEF) {
gnrc_netreg_unregister(GNRC_NETTYPE_UDP, &conn->netreg_entry);
conn->netreg_entry.pid = KERNEL_PID_UNDEF;
conn->netreg_entry.target.pid = KERNEL_PID_UNDEF;
}
}

2
sys/net/gnrc/routing/rpl/gnrc_rpl.c

@ -68,7 +68,7 @@ kernel_pid_t gnrc_rpl_init(kernel_pid_t if_pid)
}
_me_reg.demux_ctx = ICMPV6_RPL_CTRL;
_me_reg.pid = gnrc_rpl_pid;
_me_reg.target.pid = gnrc_rpl_pid;
/* register interest in all ICMPv6 packets */
gnrc_netreg_register(GNRC_NETTYPE_ICMPV6, &_me_reg);

2
tests/slip/main.c

@ -36,7 +36,7 @@ int main(void)
puts("SLIP test");
/* register pktdump */
if (dump.pid <= KERNEL_PID_UNDEF) {
if (dump.target.pid <= KERNEL_PID_UNDEF) {
puts("Error starting pktdump thread");
return -1;
}

6
tests/unittests/tests-netreg/tests-netreg.c

@ -45,7 +45,7 @@ static void test_netreg_register__success(void)
TEST_ASSERT_EQUAL_INT(0, gnrc_netreg_register(GNRC_NETTYPE_TEST, &entries[0]));
TEST_ASSERT_NOT_NULL((res = gnrc_netreg_lookup(GNRC_NETTYPE_TEST, TEST_UINT16)));
TEST_ASSERT_EQUAL_INT(TEST_UINT16, res->demux_ctx);
TEST_ASSERT_EQUAL_INT(TEST_UINT8, res->pid);
TEST_ASSERT_EQUAL_INT(TEST_UINT8, res->target.pid);
TEST_ASSERT_NULL((gnrc_netreg_getnext(res)));
}
@ -66,7 +66,7 @@ void test_netreg_unregister__success2(void)
gnrc_netreg_unregister(GNRC_NETTYPE_TEST, &entries[0]);
TEST_ASSERT_NOT_NULL((res = gnrc_netreg_lookup(GNRC_NETTYPE_TEST, TEST_UINT16)));
TEST_ASSERT_EQUAL_INT(TEST_UINT16, res->demux_ctx);
TEST_ASSERT_EQUAL_INT(TEST_UINT8 + 1, res->pid);
TEST_ASSERT_EQUAL_INT(TEST_UINT8 + 1, res->target.pid);
gnrc_netreg_unregister(GNRC_NETTYPE_TEST, &entries[1]);
TEST_ASSERT_NULL(gnrc_netreg_lookup(GNRC_NETTYPE_TEST, TEST_UINT16));
}
@ -80,7 +80,7 @@ void test_netreg_unregister__success3(void)
gnrc_netreg_unregister(GNRC_NETTYPE_TEST, &entries[1]);
TEST_ASSERT_NOT_NULL((res = gnrc_netreg_lookup(GNRC_NETTYPE_TEST, TEST_UINT16)));
TEST_ASSERT_EQUAL_INT(TEST_UINT16, res->demux_ctx);
TEST_ASSERT_EQUAL_INT(TEST_UINT8, res->pid);
TEST_ASSERT_EQUAL_INT(TEST_UINT8, res->target.pid);
gnrc_netreg_unregister(GNRC_NETTYPE_TEST, &entries[0]);
TEST_ASSERT_NULL(gnrc_netreg_lookup(GNRC_NETTYPE_TEST, TEST_UINT16));
}

Loading…
Cancel
Save