Skip to content

Commit

Permalink
Merge pull request #20190 from benpicco/netif.h-const
Browse files Browse the repository at this point in the history
sys/net/netif: constify netif access
  • Loading branch information
maribu authored Dec 15, 2023
2 parents 095ac74 + 2f9c68d commit bcecd58
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions pkg/lwip/contrib/_netif.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "lwip/netifapi.h"
#include "net/netif.h"

int netif_get_name(netif_t *iface, char *name)
int netif_get_name(const netif_t *iface, char *name)
{
lwip_netif_t *lwip_netif = (lwip_netif_t*) iface;
struct netif *netif = &lwip_netif->lwip_netif;
Expand All @@ -34,7 +34,7 @@ int netif_get_name(netif_t *iface, char *name)
return res;
}

int netif_get_opt(netif_t *iface, netopt_t opt, uint16_t context,
int netif_get_opt(const netif_t *iface, netopt_t opt, uint16_t context,
void *value, size_t max_len)
{
(void)context;
Expand Down Expand Up @@ -83,7 +83,7 @@ int netif_get_opt(netif_t *iface, netopt_t opt, uint16_t context,
return res;
}

int netif_set_opt(netif_t *iface, netopt_t opt, uint16_t context,
int netif_set_opt(const netif_t *iface, netopt_t opt, uint16_t context,
void *value, size_t value_len)
{
(void)context;
Expand Down
6 changes: 3 additions & 3 deletions sys/include/net/netif.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ netif_t *netif_iter(const netif_t *last);
* @return length of @p name on success
*/

int netif_get_name(netif_t *netif, char *name);
int netif_get_name(const netif_t *netif, char *name);

/**
* @brief Gets the numeric identifier of an interface
Expand Down Expand Up @@ -170,7 +170,7 @@ netif_t *netif_get_by_id(int16_t id);
* @return Number of bytes written to @p value.
* @return `< 0` on error, 0 on success.
*/
int netif_get_opt(netif_t *netif, netopt_t opt, uint16_t context,
int netif_get_opt(const netif_t *netif, netopt_t opt, uint16_t context,
void *value, size_t max_len);

/**
Expand All @@ -187,7 +187,7 @@ int netif_get_opt(netif_t *netif, netopt_t opt, uint16_t context,
* @return Number of bytes used from @p value.
* @return `< 0` on error, 0 on success.
*/
int netif_set_opt(netif_t *netif, netopt_t opt, uint16_t context,
int netif_set_opt(const netif_t *netif, netopt_t opt, uint16_t context,
void *value, size_t value_len);

/**
Expand Down
6 changes: 3 additions & 3 deletions sys/net/gnrc/netif/_netif.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include "net/netif.h"

int netif_get_name(netif_t *iface, char *name)
int netif_get_name(const netif_t *iface, char *name)
{
gnrc_netif_t *netif = container_of(iface, gnrc_netif_t, netif);

Expand All @@ -45,14 +45,14 @@ netif_t *netif_get_by_id(int16_t id)
return &gnrc_netif_get_by_pid((kernel_pid_t)id)->netif;
}

int netif_get_opt(netif_t *iface, netopt_t opt, uint16_t context,
int netif_get_opt(const netif_t *iface, netopt_t opt, uint16_t context,
void *value, size_t max_len)
{
const gnrc_netif_t *netif = container_of(iface, gnrc_netif_t, netif);
return gnrc_netapi_get(netif->pid, opt, context, value, max_len);
}

int netif_set_opt(netif_t *iface, netopt_t opt, uint16_t context,
int netif_set_opt(const netif_t *iface, netopt_t opt, uint16_t context,
void *value, size_t value_len)
{
const gnrc_netif_t *netif = container_of(iface, gnrc_netif_t, netif);
Expand Down

0 comments on commit bcecd58

Please sign in to comment.