Skip to content

Commit

Permalink
all: fix for new netreg_entry_t structure
Browse files Browse the repository at this point in the history
  • Loading branch information
miri64 committed Oct 25, 2016
1 parent 97adff5 commit 8c7ce02
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions examples/gnrc_networking/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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");
}

Expand Down
2 changes: 1 addition & 1 deletion sys/net/gnrc/conn/ip/gnrc_conn_ip.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions sys/net/gnrc/conn/udp/gnrc_conn_udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
2 changes: 1 addition & 1 deletion sys/net/gnrc/routing/rpl/gnrc_rpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions tests/unittests/tests-netreg/tests-netreg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}

Expand All @@ -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));
}
Expand All @@ -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));
}
Expand Down

0 comments on commit 8c7ce02

Please sign in to comment.