Show
Ignore:
Timestamp:
03/13/09 13:59:34 (15 years ago)
Author:
bhilburn
Message:

Implemented the old default policy engine in our new PolicyEngine? class. Doesn't
link properly due to redefinitions of socket functions... might need to change
the way that is laid out to fix it.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • vtcross/branches/bhilburn/src/policy_engines/default_policy_engine.cpp

    r151 r155  
    1818 
    1919#include "vtcross/common.h" 
     20#include "vtcross/components.h" 
    2021#include "vtcross/containers.h" 
    2122#include "vtcross/socket_comm.h" 
     
    2627 
    2728int32_t  
    28 ValidateTransmissionParameters(struct Parameter pList[], \ 
    29         struct CE_Info *ce_info, int decision_array[]) 
    30 { 
    31     LOG("Policy Engine:: Policies Validated.\n"); 
    32     for (size_t i = 0; i < ce_info->numParameters; i++) 
    33         decision_array[i] = 1; 
    34  
    35     return 1; 
    36 } 
    37  
    38  
    39 int32_t  
    40 RegisterPE(int32_t socketFD) 
    41 { 
    42     SendMessage(socketFD, "p_register"); 
    43     LOG("Policy Engine:: Registration message sent.\n"); 
    44     return 1; 
    45 } 
    46  
    47  
    48 int32_t  
    49 SendCEDecision(int32_t socketFD, struct Parameter pList[], \ 
    50         struct CE_Info *ce_info, int32_t decision_array[]) 
    51 { 
    52     char var[50]; 
    53   
    54     for (size_t i = 0; i < ce_info->numParameters; i++) { 
    55         sprintf(var, "%i", decision_array[i]); 
    56         SendMessage(socketFD, var); 
    57     } 
    58      
    59     return 1; 
    60 } 
    61  
    62  
    63 int32_t  
    64 ParsePolicies()  
    65 { 
    66  
    67     LOG("Policy Engine:: Policies parsed.\n"); 
    68     return 1; 
    69 } 
    70  
    71  
    72 int32_t  
    7329main(int32_t argc, char *argv[]) 
    7430{ 
    7531    if(argc < 3) 
    7632       ERROR(1, "Usage: %s hostname port\n", argv[0]); 
    77  
    78     int32_t decision_array[10]; 
    79     struct Parameter pList[10]; 
    80     struct CE_Info ce_info; 
    81     int32_t ret = 0; 
    8233     
    8334    int32_t socketFD = ClientSocket(argv[1], argv[2]); 
    8435 
    85     LOG("Policy Engine:: Parsing local policies.\n"); 
    86     ParsePolicies(); 
    87  
    88     RegisterPE(socketFD); 
     36    PolicyEngine policyEngine; 
     37    policyEngine.RegisterComponent(socketFD); 
    8938 
    9039    while(1) { 
    91         LOG("Policy Engine:: Waiting for Policy Check Request.\n"); 
    92         ret = GetRequest(socketFD, pList, &ce_info); 
    93         
    94         if(ret == 1) { 
    95             LOG("Policy Engine:: Validating Transmission Parameters.\n"); 
    96             ValidateTransmissionParameters(pList, &ce_info, decision_array);     
    97     
    98             LOG("Policy Engine:: Sending Policy decision to Server.\n"); 
    99             SendCEDecision(socketFD, pList, &ce_info, decision_array); 
    100         } 
     40        policyEngine.WaitForSignal(socketFD); 
    10141    } 
    102      
     42 
    10343    return 0; 
    10444} 
     45