Changeset 178

Show
Ignore:
Timestamp:
03/21/09 17:47:26 (15 years ago)
Author:
bhilburn
Message:

More cleanup in the shell file. Starting to burn out on refactoring. Finaly
refactor commit for the day. Still tons to do in this file.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • vtcross/trunk/src/shell/cr_shell.cpp

    r175 r178  
    248248 
    249249void  
    250 LoadCEConfiguration(int32_t socketfd,Utility * uList[], Parameter * pList[], Observable * oList[], CE_Info * ce_info){ 
     250LoadCEConfiguration(int32_t socketfd,Utility* uList[], Parameter* pList[], \ 
     251        Observable* oList[], CE_Info* ce_info) 
     252{ 
    251253        int32_t n,i,j; 
    252254        char counter[55]; 
     
    314316} 
    315317 
    316 void UpdateCEConfiguration() { 
    317  
    318 } 
    319  
    320 void ResetCEConfiguration(){ 
    321  
    322 } 
    323  
    324 void UpdateCEExperience(int32_t socketfd, int32_t num_rows, int32_t num_cols,  
     318 
     319void  
     320UpdateCEExperience(int32_t socketfd, int32_t num_rows, int32_t num_cols,  
    325321        float * past_exp[])  
    326322{ 
     
    353349} 
    354350 
    355 void ResetCEExperience() { 
    356  
    357 } 
    358  
    359 // Update operating settings 
    360 // This function will int32_teract with the hardware "drivers" 
    361 void UpdateRadioSettings()  
    362 { 
    363 } 
    364  
    365  
    366 int32_t RequestPolicyValidation(Parameter * pList[], CE_Info *ce_info) 
     351 
     352int32_t  
     353RequestPolicyValidation(Parameter * pList[], CE_Info *ce_info) 
    367354{ 
    368355        char counter[55]; 
     
    399386 
    400387 
    401 int32_t RequestCEOptimization(int32_t sockfd, Utility *uList[],  
     388int32_t  
     389RequestCEOptimization(int32_t sockfd, Utility *uList[],  
    402390        Parameter *pList[], Observable *oList[], 
    403391        CE_Info *ce_info) 
     
    438426} 
    439427 
    440 void RunSimulator(int32_t socketfd, Utility * uList[],  
     428void  
     429RunSimulator(int32_t socketfd, Utility * uList[],  
    441430        Parameter * pList[], Observable * oList[],  
    442431        CE_Info * ce_info) { 
     
    456445} 
    457446 
    458 void InitializePE(int32_t socket, CE_Info * ce_info)  
     447void  
     448InitializePE(int32_t socket, CE_Info * ce_info)  
    459449{ 
    460450    // Policy Engine is connected 
     
    466456} 
    467457 
    468 void InitializeCE(int32_t socketfd, Utility * uList[], Parameter * pList[], Observable * oList[], CE_Info * ce_info)  
     458void  
     459InitializeCE(int32_t socketfd, Utility* uList[], Parameter* pList[], \ 
     460        Observable* oList[], CE_Info* ce_info)  
    469461{ 
    470462        LoadCEConfiguration(socketfd, uList, pList, oList, ce_info); 
     
    507499} 
    508500 
    509 int32_t AcceptTCPConnection(int32_t servSock) 
    510 { 
    511     int32_t clntSock;                    /* Socket descriptor for client */ 
    512     struct sockaddr_in echoClntAddr; 
    513     uint32_t clntLen; 
    514  
    515     /* Set the size of the in-out parameter */ 
    516     clntLen = sizeof(echoClntAddr); 
    517  
    518     /* Wait for a client to connect */ 
    519     //if ((clntSock = accept(servSock, (struct sockaddr *) &echoClntAddr, &clntLen)) < 0) { 
    520     if ((clntSock = accept(servSock, NULL, NULL)) < 0) { 
    521         return -1; 
    522     }  
    523     
    524     /* clntSock is connected to a client! */ 
    525      
    526     printf("Handling client %s\n", inet_ntoa(echoClntAddr.sin_addr)); 
    527  
    528     return clntSock; 
    529 } 
    530  
    531 int32_t CreateTCPServerSocket(unsigned short port) 
    532 { 
    533     int32_t sock;                        /* socket to create */ 
    534     struct sockaddr_in echoServAddr; /* Local address */ 
    535  
    536     /* Create socket for incoming connections */ 
    537     if ((sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) 
    538         ERROR(1, "socket() failed\n"); 
    539        
    540     /* Construct local address structure */ 
    541     memset(&echoServAddr, 0, sizeof(echoServAddr));   /* Zero out structure */ 
    542     echoServAddr.sin_family = AF_INET;                /* int32_ternet address family */ 
    543     echoServAddr.sin_addr.s_addr = htonl(INADDR_ANY); /* Any incoming int32_terface */ 
    544     echoServAddr.sin_port = htons(port);              /* Local port */ 
    545  
    546     /* Bind to the local address */ 
    547     if (bind(sock, (struct sockaddr *) &echoServAddr, sizeof(echoServAddr)) < 0) 
    548         ERROR(1, "bind() failed\n"); 
    549  
    550     /* Mark the socket so it will listen for incoming connections */ 
    551     if (listen(sock, 5) < 0) { 
    552         printf("listen() failed\n"); 
    553         return 0; 
    554     } 
    555  
    556     return sock; 
    557 } 
    558  
    559 void HandleTCPClient(int32_t socketfd, Utility * uList[], Parameter * pList[], Observable * oList[], CE_Info * ce_info)  
    560 { 
    561     char buffer[256];        /* Buffer for echo string */ 
    562  
    563     /* Receive message from client */ 
    564     bzero(buffer,256); 
    565     ReadMessage(socketfd,buffer); 
    566  
    567     printf("Cognitive Radio:: Message Received - %s.\n\n", buffer); 
    568  
    569     if(strcmp(buffer,"c_register") == 0)  
    570             InitializeCE(socketfd, uList, pList, oList, ce_info); 
    571  
    572     if(strcmp(buffer,"p_register") == 0) 
    573             InitializePE(socketfd, ce_info); 
    574  
    575     if(strcmp(buffer,"optimize") == 0) 
    576             RunSimulator(socketfd, uList, pList, oList, ce_info); 
    577          
    578     //close(socketfd);    /* Close client socket */ 
    579 } 
    580  
    581 int32_t StartServers(Utility * uList[], Parameter * pList[], Observable * oList[], CE_Info * ce_info) { 
     501 
     502int32_t  
     503StartServers(Utility* uList[], Parameter* pList[], Observable* oList[], \ 
     504        CE_Info* ce_info) 
     505{ 
    582506    int32_t * servSock;  
    583507    int32_t running = 1;