Changeset 48

Show
Ignore:
Timestamp:
04/11/04 00:28:21 (9 years ago)
Author:
alexcv
Message:

Proper handling of existing connections

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog/src/child.c

    r46 r48  
    7878         
    7979        if (status > 0) { 
    80                 debug(D_LOG_DEBUG, "Allowing %s with mac %s and profile %d",  
    81                                 tmp_ci->ip, tmp_ci->mac, status); 
    82                  
    83                 tmp_uc = find_userclasses(status); 
     80                if (tmp_node = node_find_by_ip(tmp_ci->ip)) { 
     81                        /* Existing node */ 
     82                        debug(D_LOG_DEBUG, "Node %s with mac %s and profile " 
     83                                "%d re-validated", tmp_ci->ip, tmp_ci->mac, 
     84                                status); 
     85                        if (tmp_node->rights->end_time < time(NULL)) { 
     86                                /* expired node */ 
     87                                debug(D_LOG_DEBUG, "Connection from node %s " 
     88                                        "with mac %s and profile %d has " 
     89                                        "expired", tmp_ci->ip, tmp_ci->mac, 
     90                                        status); 
     91                                fw_deny(tmp_ci->ip, tmp_ci->mac, status); 
     92                                node_delete(tmp_node); 
     93                        } 
     94                } else { 
     95                        /* New node */ 
     96                        debug(D_LOG_DEBUG, "Allowing %s with mac %s and " 
     97                                "profile %d", tmp_ci->ip, tmp_ci->mac, status); 
     98                         
     99                        tmp_uc = find_userclasses(status); 
    84100 
    85                 if (tmp_uc == NULL) { 
    86                         debug(D_LOG_DEBUG, "Profile %d undefined", status); 
    87                         return; 
    88                 } 
    89                  
    90                 tmp_ur = new_userrights(); 
    91                 tmp_ur->profile = status; 
    92                 tmp_ur->start_time = time(NULL); 
    93                 tmp_ur->end_time = tmp_ur->start_time - (time_t)tmp_uc->timeout; 
    94                  
    95                 fw_allow(tmp_ci->ip, tmp_ci->mac, status); 
    96                 if (tmp_node = node_find_by_ip(tmp_ci->ip)) { 
    97                         tmp_node->active = 1; 
    98                         tmp_node->rights = tmp_ur; 
     101                        if (tmp_uc == NULL) { 
     102                                debug(D_LOG_DEBUG, "Profile %d undefined", 
     103                                        status); 
     104                                return; 
     105                        } 
     106                         
     107                        tmp_ur = new_userrights(); 
     108                        tmp_ur->profile = status; 
     109                        tmp_ur->start_time = time(NULL); 
     110                        tmp_ur->end_time = tmp_ur->start_time - 
     111                                                (time_t)tmp_uc->timeout; 
     112                         
     113                        fw_allow(tmp_ci->ip, tmp_ci->mac, status); 
     114                        if (tmp_node = node_find_by_ip(tmp_ci->ip)) { 
     115                                tmp_node->active = 1; 
     116                                tmp_node->rights = tmp_ur; 
     117                        } 
    99118                } 
    100119        } else { 
     120                /* XXX We should only get here if the UserClass has changed 
     121                 * while the connection was active. */ 
    101122                debug(D_LOG_DEBUG, "Denying %s with mac %s and profile %d",  
    102123                                tmp_ci->ip, tmp_ci->mac, status);