Navigation



Ignore:
Timestamp:
Jul 28, 2010, 3:59:39 PM (14 years ago)
Author:
Souheil Ben Ayed <souheil@tera.ics.keio.ac.jp>
Branch:
default
Phase:
public
Message:

Corrected compilation warnings on app_diameap

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/app_diameap/diameap_eap.c

    • Property exe set to *
    r425 r438  
    3838#include "diameap_common.h"
    3939
     40static void diameap_ba_nextid(struct eap_state_machine * sm, int * id)
     41{
     42        TRACE_ENTRY("%p %p",sm,id);
     43
     44        if (sm->currentId < 0)
     45        {
     46                *id = (u8) (255 * rand() / RAND_MAX) & 0xFFU;
     47        }
     48        else
     49        {
     50                *id = (sm->currentId++) & 0xFFU;
     51        }
     52        if (*id == sm->lastId)
     53        {
     54                *id=*id+1;
     55        }
     56}
     57
     58static void diameap_ba_policyupdate(struct eap_state_machine * eap_sm,
     59                struct eap_packet eapPacket)
     60{
     61        TRACE_ENTRY("%p %p",eap_sm, eapPacket);
     62        if ((eap_sm->respMethod == TYPE_NAK))
     63        {
     64                int id;
     65                eap_sm->user.pmethods = 0;
     66                u32 vendor;
     67                eap_type type;
     68                u8 *data = (u8 *) eapPacket.data;
     69                data += 5;
     70                id = 5;
     71                while (id < eapPacket.length)
     72                {
     73                        vendor = VENDOR_IETF;
     74                        type = G8(data);
     75                        if (diameap_plugin_exist(vendor, type) == TRUE)
     76                        {
     77                                eap_sm->user.proposedmethods[id - 5].method = type;
     78                                eap_sm->user.proposedmethods[id - 5].vendor = vendor;
     79                                eap_sm->user.pmethods++;
     80                        }
     81                        data++;
     82                        id++;
     83                }
     84                eap_sm->user.methodId = -1;
     85        }
     86}
     87
     88static int diameap_ba_policygetnextmethod(struct eap_state_machine * eap_sm,
     89                eap_type * eaptype, u32 * vendor)
     90{
     91        TRACE_ENTRY("%p %p %p",eap_sm,eaptype,vendor);
     92        *vendor = 0;
     93        *eaptype = TYPE_NONE;
     94        eap_sm->selectedMethod = NULL;
     95
     96        if (eap_sm == NULL)
     97        {
     98                return EINVAL;
     99        }
     100
     101        if (eap_sm->user.userid == NULL)
     102        {
     103                if ((eap_sm->currentMethod == TYPE_NONE))
     104                {
     105                        *vendor = VENDOR_IETF;
     106                        *eaptype = TYPE_IDENTITY;
     107                        if (eap_sm->selectedMethod != NULL)
     108                        {
     109                                (*eap_sm->selectedMethod->eap_method_free)(eap_sm->methodData);
     110                                eap_sm->methodData = NULL;
     111                        }
     112                        CHECK_FCT(diameap_plugin_get(VENDOR_IETF,TYPE_IDENTITY,&eap_sm->selectedMethod));
     113                        return 0;
     114                }
     115
     116                eap_sm->selectedMethod = NULL;
     117                *vendor = 0;
     118                *eaptype = TYPE_NONE;
     119                return 0;
     120        }
     121
     122        if (eap_sm->user.methodId == -1)
     123        {
     124                if (eap_sm->user.proposed_eap_method >= TYPE_EAP_MD5)
     125                {
     126                        *vendor = eap_sm->user.proposed_eap_method_vendor;
     127                        if (*vendor == VENDOR_IETF)
     128                        {
     129                                *eaptype = eap_sm->user.proposed_eap_method;
     130                        }
     131                        else
     132                        {
     133                                *eaptype = TYPE_EXPANDED_TYPES;
     134                        }
     135                        if (eap_sm->selectedMethod != NULL)
     136                        {
     137                                (*eap_sm->selectedMethod->eap_method_free)(eap_sm->methodData);
     138                                eap_sm->methodData = NULL;
     139                        }
     140                        CHECK_FCT_DO(diameap_plugin_get(*vendor,*eaptype,&eap_sm->selectedMethod),
     141                                        {       TRACE_DEBUG(INFO,"%s [EAP Protocol] Invalid EAP-TYPE %d (vendor %d)",DIAMEAP_EXTENSION,*eaptype,*vendor);return 1;});
     142
     143                }
     144                eap_sm->user.proposed_eap_method = TYPE_NONE;
     145        }
     146        else
     147        {
     148                *vendor = eap_sm->user.proposedmethods[eap_sm->user.methodId].vendor;
     149                if (eap_sm->user.proposedmethods[eap_sm->user.methodId].vendor
     150                                == VENDOR_IETF)
     151                {
     152                        *eaptype
     153                                        = eap_sm->user.proposedmethods[eap_sm->user.methodId].method;
     154                }
     155                else
     156                {
     157                        *eaptype = TYPE_EXPANDED_TYPES;
     158                }
     159                if (eap_sm->selectedMethod != NULL)
     160                {
     161                        (*eap_sm->selectedMethod->eap_method_free)(eap_sm->methodData);
     162                        eap_sm->methodData=NULL;
     163                }
     164                CHECK_FCT(diameap_plugin_get(eap_sm->user.proposedmethods[eap_sm->user.methodId].vendor,eap_sm->user.proposedmethods[eap_sm->user.methodId].method,&eap_sm->selectedMethod));
     165
     166                eap_sm->user.methodId++;
     167        }
     168
     169        return 0;
     170}
     171
     172static int diameap_ba_policygetdecision(struct eap_state_machine * eap_sm,
     173                struct diameap_eap_interface * eap_i, decision * gdecision)
     174{
     175        TRACE_ENTRY("%p %p %p",eap_sm,eap_i,gdecision);
     176
     177        if (eap_sm->user.userid != NULL)
     178        {
     179
     180                if (eap_sm->methodState == EAP_M_END)
     181                {
     182
     183                        if (eap_sm->respMethod == TYPE_IDENTITY)
     184                        {
     185
     186                                *gdecision = DECISION_CONTINUE;
     187                                return 0;
     188                        }
     189
     190                        if ((eap_sm->respMethod == TYPE_NAK) || ((eap_sm->respMethod
     191                                        == TYPE_EXPANDED_TYPES) && (eap_sm->respVendor
     192                                        == VENDOR_IETF) && (eap_sm->respVendorMethod == TYPE_NAK)))
     193                        {
     194                                goto SelectNextMethod;
     195                        }
     196
     197                        if (eap_sm->user.success == TRUE)
     198                        {
     199
     200                                *gdecision = DECISION_SUCCESS;
     201                        }
     202                        else
     203                        {
     204
     205                                *gdecision = DECISION_FAILURE;
     206                        }
     207
     208                }
     209                else
     210                {
     211                        goto SelectNextMethod;
     212                }
     213                return 0;
     214
     215                SelectNextMethod: if ((eap_sm->user.methodId
     216                                == (MAXPROPOSEDMETHODS - 1))
     217                                || ((eap_sm->user.proposedmethods[eap_sm->user.methodId + 1].method
     218                                                == TYPE_NONE)
     219                                                && (eap_sm->user.proposedmethods[eap_sm->user.methodId
     220                                                                + 1].vendor == VENDOR_IETF)))
     221                {
     222                        TRACE_DEBUG(FULL+1,
     223                                        "%s [EAP protocol] None of proposed EAP Methods authenticated the user.(FAILURE)",DIAMEAP_EXTENSION);
     224                        *gdecision = DECISION_FAILURE;
     225                        return 0;
     226                }
     227
     228                eap_sm->user.methodId = 0;
     229                *gdecision = DECISION_CONTINUE;
     230                return 0;
     231        }
     232
     233        if (eap_sm->currentMethod == TYPE_IDENTITY)
     234        {
     235                *gdecision = DECISION_FAILURE;
     236                return 0;
     237        }
     238
     239        *gdecision = DECISION_CONTINUE;
     240        return 0;
     241}
     242
     243static boolean diameap_ba_policydopickup(eap_type type)
     244{
     245        TRACE_ENTRY("%p",type);
     246        if (type == TYPE_IDENTITY)
     247        {
     248                return TRUE;
     249        }
     250        return FALSE;
     251}
     252
    40253int diameap_eap_statemachine(struct eap_state_machine * eap_sm,
    41254                struct diameap_eap_interface * eap_i, boolean * non_fatal_error)
     
    375588                        }
    376589                        break;
     590
    377591                case EAP_END:
     592                        break;
     593
     594                case EAP_IDLE:
    378595                        break;
    379596                }
     
    383600}
    384601
    385 static void diameap_ba_nextid(struct eap_state_machine * sm, int * id)
    386 {
    387         TRACE_ENTRY("%p %p",sm,id);
    388 
    389         if (sm->currentId < 0)
    390         {
    391                 *id = (u8) (255 * rand() / RAND_MAX) & 0xFFU;
    392         }
    393         else
    394         {
    395                 *id = (sm->currentId++) & 0xFFU;
    396         }
    397         if (*id == sm->lastId)
    398         {
    399                 *id++;
    400         }
    401 }
    402 
    403 static void diameap_ba_policyupdate(struct eap_state_machine * eap_sm,
    404                 struct eap_packet eapPacket)
    405 {
    406         TRACE_ENTRY("%p %p",eap_sm, eapPacket);
    407         if ((eap_sm->respMethod == TYPE_NAK))
    408         {
    409                 int id;
    410                 eap_sm->user.pmethods = 0;
    411                 u32 vendor;
    412                 eap_type type;
    413                 u8 *data = (u8 *) eapPacket.data;
    414                 data += 5;
    415                 id = 5;
    416                 while (id < eapPacket.length)
    417                 {
    418                         vendor = VENDOR_IETF;
    419                         type = G8(data);
    420                         if (diameap_plugin_exist(vendor, type) == TRUE)
    421                         {
    422                                 eap_sm->user.proposedmethods[id - 5].method = type;
    423                                 eap_sm->user.proposedmethods[id - 5].vendor = vendor;
    424                                 eap_sm->user.pmethods++;
    425                         }
    426                         data++;
    427                         id++;
    428                 }
    429                 eap_sm->user.methodId = -1;
    430         }
    431 }
    432 
    433 static int diameap_ba_policygetnextmethod(struct eap_state_machine * eap_sm,
    434                 eap_type * eaptype, u32 * vendor)
    435 {
    436         TRACE_ENTRY("%p %p %p",eap_sm,eaptype,vendor);
    437         *vendor = 0;
    438         *eaptype = TYPE_NONE;
    439         eap_sm->selectedMethod = NULL;
    440 
    441         if (eap_sm == NULL)
    442         {
    443                 return EINVAL;
    444         }
    445 
    446         if (eap_sm->user.userid == NULL)
    447         {
    448                 if ((eap_sm->currentMethod == TYPE_NONE))
    449                 {
    450                         *vendor = VENDOR_IETF;
    451                         *eaptype = TYPE_IDENTITY;
    452                         if (eap_sm->selectedMethod != NULL)
    453                         {
    454                                 (*eap_sm->selectedMethod->eap_method_free)(eap_sm->methodData);
    455                                 eap_sm->methodData = NULL;
    456                         }
    457                         CHECK_FCT(diameap_plugin_get(VENDOR_IETF,TYPE_IDENTITY,&eap_sm->selectedMethod));
    458                         return 0;
    459                 }
    460 
    461                 eap_sm->selectedMethod = NULL;
    462                 *vendor = 0;
    463                 *eaptype = TYPE_NONE;
    464                 return 0;
    465         }
    466 
    467         if (eap_sm->user.methodId == -1)
    468         {
    469                 if (eap_sm->user.proposed_eap_method >= TYPE_EAP_MD5)
    470                 {
    471                         *vendor = eap_sm->user.proposed_eap_method_vendor;
    472                         if (*vendor == VENDOR_IETF)
    473                         {
    474                                 *eaptype = eap_sm->user.proposed_eap_method;
    475                         }
    476                         else
    477                         {
    478                                 *eaptype = TYPE_EXPANDED_TYPES;
    479                         }
    480                         if (eap_sm->selectedMethod != NULL)
    481                         {
    482                                 (*eap_sm->selectedMethod->eap_method_free)(eap_sm->methodData);
    483                                 eap_sm->methodData = NULL;
    484                         }
    485                         CHECK_FCT_DO(diameap_plugin_get(*vendor,*eaptype,&eap_sm->selectedMethod),
    486                                         {       TRACE_DEBUG(INFO,"%s [EAP Protocol] Invalid EAP-TYPE %d (vendor %d)",DIAMEAP_EXTENSION,*eaptype,*vendor);return 1;});
    487 
    488                 }
    489                 eap_sm->user.proposed_eap_method = TYPE_NONE;
    490         }
    491         else
    492         {
    493                 *vendor = eap_sm->user.proposedmethods[eap_sm->user.methodId].vendor;
    494                 if (eap_sm->user.proposedmethods[eap_sm->user.methodId].vendor
    495                                 == VENDOR_IETF)
    496                 {
    497                         *eaptype
    498                                         = eap_sm->user.proposedmethods[eap_sm->user.methodId].method;
    499                 }
    500                 else
    501                 {
    502                         *eaptype = TYPE_EXPANDED_TYPES;
    503                 }
    504                 if (eap_sm->selectedMethod != NULL)
    505                 {
    506                         (*eap_sm->selectedMethod->eap_method_free)(eap_sm->methodData);
    507                         eap_sm->methodData;
    508                 }
    509                 CHECK_FCT(diameap_plugin_get(eap_sm->user.proposedmethods[eap_sm->user.methodId].vendor,eap_sm->user.proposedmethods[eap_sm->user.methodId].method,&eap_sm->selectedMethod));
    510 
    511                 eap_sm->user.methodId++;
    512         }
    513 
    514         return 0;
    515 }
    516 
    517 static int diameap_ba_policygetdecision(struct eap_state_machine * eap_sm,
    518                 struct diameap_eap_interface * eap_i, decision * gdecision)
    519 {
    520         TRACE_ENTRY("%p %p %p",eap_sm,eap_i,gdecision);
    521 
    522         if (eap_sm->user.userid != NULL)
    523         {
    524 
    525                 if (eap_sm->methodState == EAP_M_END)
    526                 {
    527 
    528                         if (eap_sm->respMethod == TYPE_IDENTITY)
    529                         {
    530 
    531                                 *gdecision = DECISION_CONTINUE;
    532                                 return 0;
    533                         }
    534 
    535                         if ((eap_sm->respMethod == TYPE_NAK) || ((eap_sm->respMethod
    536                                         == TYPE_EXPANDED_TYPES) && (eap_sm->respVendor
    537                                         == VENDOR_IETF) && (eap_sm->respVendorMethod == TYPE_NAK)))
    538                         {
    539                                 goto SelectNextMethod;
    540                         }
    541 
    542                         if (eap_sm->user.success == TRUE)
    543                         {
    544 
    545                                 *gdecision = DECISION_SUCCESS;
    546                         }
    547                         else
    548                         {
    549 
    550                                 *gdecision = DECISION_FAILURE;
    551                         }
    552 
    553                 }
    554                 else
    555                 {
    556                         goto SelectNextMethod;
    557                 }
    558                 return 0;
    559 
    560                 SelectNextMethod: if ((eap_sm->user.methodId
    561                                 == (MAXPROPOSEDMETHODS - 1))
    562                                 || ((eap_sm->user.proposedmethods[eap_sm->user.methodId + 1].method
    563                                                 == TYPE_NONE)
    564                                                 && (eap_sm->user.proposedmethods[eap_sm->user.methodId
    565                                                                 + 1].vendor == VENDOR_IETF)))
    566                 {
    567                         TRACE_DEBUG(FULL+1,
    568                                         "%s [EAP protocol] None of proposed EAP Methods authenticated the user.(FAILURE)",DIAMEAP_EXTENSION);
    569                         *gdecision = DECISION_FAILURE;
    570                         return 0;
    571                 }
    572 
    573                 eap_sm->user.methodId = 0;
    574                 *gdecision = DECISION_CONTINUE;
    575                 return 0;
    576         }
    577 
    578         if (eap_sm->currentMethod == TYPE_IDENTITY)
    579         {
    580                 *gdecision = DECISION_FAILURE;
    581                 return 0;
    582         }
    583 
    584         *gdecision = DECISION_CONTINUE;
    585         return 0;
    586 }
    587 
    588 static boolean diameap_ba_policydopickup(eap_type type)
    589 {
    590         TRACE_ENTRY("%p",type);
    591         if (type == TYPE_IDENTITY)
    592         {
    593                 return TRUE;
    594         }
    595         return FALSE;
    596 }
Note: See TracChangeset for help on using the changeset viewer.