Fix SEGFAULT
[l2tpns.git] / garden.c
index 1083b65..c3ce34a 100644 (file)
--- a/garden.c
+++ b/garden.c
@@ -34,19 +34,19 @@ int plugin_post_auth(struct param_post_auth *data)
 
        p.log(3, 0, 0, 0, "Walled Garden allowing login\n");
        data->auth_allowed = 1;
 
        p.log(3, 0, 0, 0, "Walled Garden allowing login\n");
        data->auth_allowed = 1;
-       data->s->garden = 1;
+       data->s->walled_garden = 1;
        return PLUGIN_RET_OK;
 }
 
 int plugin_new_session(struct param_new_session *data)
 {
        return PLUGIN_RET_OK;
 }
 
 int plugin_new_session(struct param_new_session *data)
 {
-       if (data->s->garden) garden_session(data->s, 1);
+       if (data->s->walled_garden) garden_session(data->s, 1);
        return PLUGIN_RET_OK;
 }
 
 int plugin_kill_session(struct param_new_session *data)
 {
        return PLUGIN_RET_OK;
 }
 
 int plugin_kill_session(struct param_new_session *data)
 {
-       if (data->s->garden) garden_session(data->s, 0);
+       if (data->s->walled_garden) garden_session(data->s, 0);
        return PLUGIN_RET_OK;
 }
 
        return PLUGIN_RET_OK;
 }
 
@@ -68,7 +68,7 @@ int plugin_control(struct param_control *data)
                sprintf((data->response + data->response_length), "%s", errormsg);
                data->response_length += strlen(errormsg) + 1;
 
                sprintf((data->response + data->response_length), "%s", errormsg);
                data->response_length += strlen(errormsg) + 1;
 
-               p.log(3, 0, 0, 0, "Unknown session %s\n", session);
+               p.log(3, 0, 0, 0, "Unknown session %d\n", session);
                return PLUGIN_RET_STOP;
        }
        *(short *)(data->response + 2) = ntohs(PKT_RESP_OK);
                return PLUGIN_RET_STOP;
        }
        *(short *)(data->response + 2) = ntohs(PKT_RESP_OK);
@@ -119,7 +119,7 @@ int garden_session(sessiont *s, int flag)
                snprintf(cmd, 2048, "iptables -t nat -A garden_users -s %s -j garden", p.inet_toa(ntohl(s->ip)));
                p.log(3, 0, 0, s->tunnel, "%s\n", cmd);
                system(cmd);
                snprintf(cmd, 2048, "iptables -t nat -A garden_users -s %s -j garden", p.inet_toa(ntohl(s->ip)));
                p.log(3, 0, 0, s->tunnel, "%s\n", cmd);
                system(cmd);
-               s->garden = 1;
+               s->walled_garden = 1;
        }
        else
        {
        }
        else
        {
@@ -145,15 +145,15 @@ int garden_session(sessiont *s, int flag)
                        if (WEXITSTATUS(status) != 0) break;
                }
 
                        if (WEXITSTATUS(status) != 0) break;
                }
 
-               s->garden = 0;
+               s->walled_garden = 0;
 
                if (!s->die) {
                        /* OK, we're up! */
 
                if (!s->die) {
                        /* OK, we're up! */
-                       u8 r = p.radiusnew(p.get_id_by_session(s));
+                       u16 r = p.radiusnew(p.get_id_by_session(s));
                        p.radiussend(r, RADIUSSTART);
                }
        }
                        p.radiussend(r, RADIUSSTART);
                }
        }
-       s->garden = flag;
+       s->walled_garden = flag;
        return 1;
 }
 
        return 1;
 }