diff --git a/src/openvpn/route.c b/src/openvpn/route.c
index d0d26c6..449b4f1 100644
--- a/src/openvpn/route.c
+++ b/src/openvpn/route.c
@@ -3331,7 +3331,6 @@
     int rtm_addrs;
     struct sockaddr so_dst, so_mask;
     char *cp = m_rtmsg.m_space;
-    struct sockaddr *gate = NULL, *ifp = NULL, *sa;
     struct rt_msghdr *rtm_aux;
 
 #define rtm m_rtmsg.m_rtm
@@ -3396,6 +3395,8 @@
     sockfd = -1;
 
     /* extract return data from routing socket */
+    const struct sockaddr_in *gate = NULL;
+    const struct sockaddr_dl *adl = NULL;
     rtm_aux = &rtm;
     cp = (char *)(rtm_aux + 1);
     if (rtm_aux->rtm_addrs)
@@ -3404,14 +3405,14 @@
         {
             if (i & rtm_aux->rtm_addrs)
             {
-                sa = (struct sockaddr *)cp;
+                const struct sockaddr *sa = (const struct sockaddr *)cp;
                 if (i == RTA_GATEWAY)
                 {
-                    gate = sa;
+                    gate = (const struct sockaddr_in *)sa;
                 }
                 else if (i == RTA_IFP)
                 {
-                    ifp = sa;
+                    adl = (const struct sockaddr_dl *)sa;
                 }
                 ADVANCE(cp, sa);
             }
@@ -3423,19 +3424,18 @@
     }
 
     /* get gateway addr and interface name */
-    if (gate != NULL)
+    if (gate)
     {
         /* get default gateway addr */
-        rgi->gateway.addr = ntohl(((struct sockaddr_in *)gate)->sin_addr.s_addr);
+        rgi->gateway.addr = ntohl((gate)->sin_addr.s_addr);
         if (rgi->gateway.addr)
         {
             rgi->flags |= RGI_ADDR_DEFINED;
         }
 
-        if (ifp)
+        if (adl)
         {
             /* get interface name */
-            const struct sockaddr_dl *adl = (struct sockaddr_dl *)ifp;
             if (adl->sdl_nlen && adl->sdl_nlen < sizeof(rgi->iface))
             {
                 memcpy(rgi->iface, adl->sdl_data, adl->sdl_nlen);
diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
index bcea331..a1f9886 100644
--- a/src/openvpn/tun.c
+++ b/src/openvpn/tun.c
@@ -1040,7 +1040,7 @@
  * @param ctx       the networking API opaque context
  */
 static void
-do_ifconfig_ipv6(struct tuntap *tt, const char *ifname, int tun_mtu, const struct env_set *es,
+do_ifconfig_ipv6(const struct tuntap *tt, const char *ifname, int tun_mtu, const struct env_set *es,
                  openvpn_net_ctx_t *ctx)
 {
 #if !defined(TARGET_LINUX)
@@ -1231,7 +1231,7 @@
  * @param ctx       the networking API opaque context
  */
 static void
-do_ifconfig_ipv4(struct tuntap *tt, const char *ifname, int tun_mtu, const struct env_set *es,
+do_ifconfig_ipv4(const struct tuntap *tt, const char *ifname, int tun_mtu, const struct env_set *es,
                  openvpn_net_ctx_t *ctx)
 {
 #if !defined(_WIN32) && !defined(TARGET_ANDROID)
@@ -1587,7 +1587,7 @@
 }
 
 static void
-undo_ifconfig_ipv4(const struct tuntap *tt, openvpn_net_ctx_t *ctx)
+undo_ifconfig_ipv4(const struct tuntap *tt, const openvpn_net_ctx_t *ctx)
 {
 #if defined(TARGET_LINUX)
     int netbits = netmask_to_netbits2(tt->remote_netmask);
@@ -1622,7 +1622,7 @@
 }
 
 static void
-undo_ifconfig_ipv6(const struct tuntap *tt, openvpn_net_ctx_t *ctx)
+undo_ifconfig_ipv6(const struct tuntap *tt, const openvpn_net_ctx_t *ctx)
 {
 #if defined(TARGET_LINUX)
     if (net_addr_v6_del(ctx, tt->actual_name, &tt->local_ipv6, tt->netbits_ipv6) < 0)
