00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #include <string.h>
00036 #ifndef _WIN32
00037 #include <sys/types.h>
00038 #include <sys/socket.h>
00039 #include <netinet/in.h>
00040 #include <arpa/inet.h>
00041 #include <unistd.h>
00042 #include <netdb.h>
00043 #include <errno.h>
00044 #include "config.h"
00045 #else
00046 #include "winconfig.h"
00047 #endif
00048 #include <mxml.h>
00049 #include "include/libmc.h"
00050 #include "include/agent.h"
00051 #include "include/mc_platform.h"
00052 #include "include/message.h"
00053 #include "include/mtp_http.h"
00054 #include "include/xml_compose.h"
00055 #include "include/xml_helper.h"
00056 #include "include/xml_parser.h"
00057 #include "include/macros.h"
00058
00059 #include "security/asm_node.h"
00060
00061 #define SOCKET_INPUT_SIZE 4096
00062
00063 message_p
00064 message_New(void)
00065 {
00066 message_p message;
00067 message = (message_p)malloc(sizeof(message_t));
00068 CHECK_NULL(message, exit(0););
00069 message->addr = NULL;
00070 message->connect_id = 0;
00071 message->message_id = 0;
00072 message->isHTTP = 0;
00073 message->message_type = 0;
00074 message->http_type = 0;
00075 message->xml_root = NULL;
00076 message->xml_payload = NULL;
00077 message->message_body = NULL;
00078 message->update_name = NULL;
00079 message->update_num = 0;
00080 message->from_address = NULL;
00081 message->to_address = NULL;
00082 message->target = NULL;
00083 message->agent_xml_flag = 0;
00084 return message;
00085 }
00086
00087 message_p
00088 message_Copy(message_p src)
00089 {
00090 fprintf(stderr, "FIXME: message_Copy() is not implemented yet. %s:%d\n",
00091 __FILE__, __LINE__);
00092 return NULL;
00093 }
00094
00095 int
00096 message_InitializeFromAgent(
00097 mc_platform_p mc_platform,
00098 message_p message,
00099 agent_p agent)
00100 {
00101 struct hostent* host;
00102
00103 char* buf;
00104 char* destination_host;
00105 char* destination_port_str;
00106 #ifndef _WIN32
00107 char* save_ptr;
00108 #endif
00109 int destination_port;
00110
00111 message->message_id = rand();
00112 message->message_type = MOBILE_AGENT;
00113
00114 message->xml_root = agent_xml_compose(agent);
00115
00116
00117 CHECK_NULL(message->xml_root, exit(0););
00118 message->message_body = mxmlSaveAllocString(
00119 message->xml_root,
00120 MXML_NO_CALLBACK );
00121
00122 message->update_name = NULL;
00123
00124 message->from_address =
00125 (char*)malloc(sizeof(char) * (strlen(mc_platform->hostname) + 10));
00126 sprintf(
00127 message->from_address,
00128 "%s:%d",
00129 mc_platform->hostname,
00130 mc_platform->port );
00131 if (
00132 agent->datastate->task_progress >=
00133 agent->datastate->number_of_tasks
00134 )
00135 {
00136 message->to_address =
00137 (char*)malloc
00138 (
00139 sizeof(char) *
00140 (
00141 strlen(agent->home) + 1
00142 )
00143 );
00144 CHECK_NULL(message->to_address, exit(0););
00145 strcpy
00146 (
00147 message->to_address,
00148 agent->home
00149 );
00150 } else {
00151 message->to_address =
00152 (char*) malloc
00153 (
00154 sizeof(char) *
00155 (
00156 strlen
00157 (
00158 agent->datastate->tasks[ agent->datastate->task_progress ]
00159 ->server_name
00160 )
00161 +1
00162 )
00163 );
00164 CHECK_NULL( message->to_address, mc_platform->err = MC_ERR_MEMORY; return MC_ERR_MEMORY;);
00165 strcpy(
00166 message->to_address,
00167 agent->datastate->tasks[ agent->datastate->task_progress ]->server_name
00168 );
00169 }
00170 message->agent_xml_flag = 0;
00171 message->target = strdup("ams");
00172 message->sending_agent_name = strdup(agent->name);
00173
00174 buf = (char*)malloc
00175 (
00176 sizeof(char) *
00177 (strlen(message->to_address)+1)
00178 );
00179 CHECK_NULL(buf, exit(0););
00180 strcpy(buf, message->to_address);
00181 destination_host = strtok_r(buf, ":", &save_ptr);
00182 destination_port_str = strtok_r(NULL, ":", &save_ptr);
00183 destination_port = atoi(destination_port_str);
00184 message->addr = (struct sockaddr_in*)malloc(sizeof(struct sockaddr_in));
00185 if ((host = gethostbyname(destination_host))) {
00186 memcpy(&(message->addr->sin_addr), host->h_addr, host->h_length);
00187 message->addr->sin_port = htons(destination_port);
00188 } else {
00189 WARN("Host not found.");
00190 }
00191 free(buf);
00192 return MC_SUCCESS;
00193 }
00194
00195 int
00196 message_InitializeFromConnection(
00197 mc_platform_p mc_platform,
00198 message_p message,
00199 connection_p connection)
00200 {
00201 int i = 1;
00202 int n;
00203 char *message_string;
00204 char *buffer;
00205
00206 message->addr = (struct sockaddr_in*)malloc(sizeof(struct sockaddr_in));
00207 CHECK_NULL(message->addr, exit(0););
00208 *(message->addr) = connection->addr;
00209
00210 message->connect_id = connection->connect_id;
00211
00212 message->message_id = rand();
00213
00214 message->to_address = NULL;
00215 message->from_address = NULL;
00216 message->target = NULL;
00217
00218 buffer = (char*) malloc(sizeof(char) * (SOCKET_INPUT_SIZE + 1));
00219 CHECK_NULL(buffer, exit(0););
00220 message_string = (char*) malloc(sizeof(char) * (SOCKET_INPUT_SIZE + 1));
00221 CHECK_NULL(message_string, exit(0););
00222 message_string[0] = '\0';
00223 buffer[0] = '\0';
00224
00225
00226 while(1) {
00227 #ifndef _WIN32
00228
00229
00230
00231
00232
00233
00234 n = recv(connection->clientfd, (void*)buffer, (size_t) sizeof(char)*SOCKET_INPUT_SIZE, MSG_WAITALL);
00235 #else
00236 n = recvfrom(connection->clientfd,
00237 (void *) buffer,
00238 (size_t) sizeof(char)*SOCKET_INPUT_SIZE,
00239 0,
00240 (struct sockaddr *) 0,
00241 0);
00242 #endif
00243 if (n < 0) {
00244 free(buffer);
00245 SOCKET_ERROR();
00246 return MC_ERR_CONNECT;
00247 }
00248 else if (n == 0) {
00249 free(buffer);
00250 break;
00251 } else {
00252 buffer[n] = '\0';
00253 i++;
00254 strcat(message_string, buffer);
00255 message_string = realloc
00256 (
00257 message_string,
00258 sizeof(char) * (SOCKET_INPUT_SIZE+1) * i
00259 );
00260 CHECK_NULL(message_string, exit(0););
00261 buffer[0] = '\0';
00262 }
00263 }
00264 message->message_body = (char*)malloc
00265 (
00266 sizeof(char) *
00267 (strlen(message_string) + 1)
00268 );
00269 CHECK_NULL(message->message_body, exit(0););
00270 strcpy(message->message_body, message_string);
00271 free(message_string);
00272 message->xml_root = mxmlLoadString
00273 (
00274 NULL,
00275 message->message_body,
00276 MXML_NO_CALLBACK
00277 );
00278 if (message_xml_parse(message)) {
00279 fprintf(stderr, "Error parsing message at %s:%d.\n",
00280 __FILE__, __LINE__);
00281 message_Destroy(message);
00282 return MC_ERR_PARSE;
00283 }
00284 return MC_SUCCESS;
00285 }
00286
00287 int http_to_hostport(const char* http_str, char** host, int* port, char** target)
00288 {
00289
00290
00291
00292
00293 char* tmp;
00294 if(strncmp(http_str, "http://", 7)) {
00295 return MC_ERR_PARSE;
00296 }
00297 http_str += 7;
00298 tmp = strchr(http_str, (int)':');
00299 if (tmp == NULL) return MC_ERR_PARSE;
00300
00301
00302 *host = (char*)malloc(sizeof(char) *
00303 (tmp - http_str + 1) );
00304 strncpy(*host, http_str, tmp - http_str);
00305 (*host)[tmp-http_str] = '\0';
00306
00307
00308 tmp++;
00309 sscanf(tmp, "%d", port);
00310
00311
00312 tmp = strchr(tmp, (int)'/');
00313 tmp++;
00314 *target = (char*)malloc(sizeof(char) *
00315 (strlen(tmp)+1) );
00316 strcpy(*target, tmp);
00317
00318 return 0;
00319 }
00320
00321 int
00322 message_InitializeFromString(
00323 mc_platform_p mc_platform,
00324 message_p message,
00325 const char* string,
00326 const char* destination_host,
00327 int destination_port,
00328 const char* target)
00329 {
00330 char* destination;
00331 struct hostent* host;
00332
00333 message->connect_id = 0;
00334 message->message_id = rand();
00335
00336 message->message_type = MOBILE_AGENT;
00337
00338 message->xml_root = NULL;
00339
00340 message->message_body =
00341 (char*)malloc( sizeof(char) * (strlen(string)+1));
00342 CHECK_NULL(message->message_body,
00343 mc_platform->err = MC_ERR_MEMORY;
00344 return MC_ERR_MEMORY; );
00345 strcpy(message->message_body, string);
00346
00347 message->update_name = NULL;
00348
00349 destination = malloc(sizeof(char)*(strlen(destination_host) + 10));
00350 CHECK_NULL(destination,
00351 mc_platform->err = MC_ERR_MEMORY;
00352 return MC_ERR_MEMORY; );
00353 sprintf(destination, "%s:%d",
00354 destination_host,
00355 destination_port
00356 );
00357
00358 message->to_address = destination;
00359 message->from_address = (char*)malloc(
00360 sizeof(char) * (strlen(mc_platform->hostname)+10));
00361 sprintf(message->from_address,
00362 "%s:%d",
00363 mc_platform->hostname,
00364 mc_platform->port );
00365 message->target = (char*)malloc(sizeof(char) *
00366 (strlen(target)+1));
00367 strcpy(message->target, target);
00368
00369
00370 message->addr = (struct sockaddr_in*)malloc(sizeof(struct sockaddr_in));
00371 if (destination_host != NULL && strlen(destination_host)!= 0) {
00372 if((host = gethostbyname(destination_host)))
00373 {
00374 memcpy(&(message->addr->sin_addr), host->h_addr, host->h_length);
00375 message->addr->sin_port = htons(destination_port);
00376 } else {
00377 fprintf(stderr, "Warning: Host not found: %s:%d %s:%d",
00378 destination_host, destination_port, __FILE__, __LINE__ );
00379 }
00380 }
00381 message->xml_root = mxmlLoadString
00382 (
00383 NULL,
00384 message->message_body,
00385 MXML_NO_CALLBACK
00386 );
00387 if (message_xml_parse(message)) {
00388 fprintf(stderr, "Error parsing message at %s:%d.\n",
00389 __FILE__, __LINE__);
00390 message_Destroy(message);
00391 return MC_ERR_PARSE;
00392 }
00393
00394 return MC_SUCCESS;
00395 }
00396
00397 int
00398 message_Destroy(message_p message)
00399 {
00400 if (message == NULL) {
00401 return MC_SUCCESS;
00402 }
00403
00404
00405 if(message->xml_root != NULL && message->agent_xml_flag == 0) {
00406 mxmlDelete(message->xml_root);
00407 }
00408
00409 if(message->addr) {
00410 free(message->addr);
00411 message->addr = NULL;
00412 }
00413 if(message->message_body != NULL) {
00414 free(message->message_body);
00415 message->message_body = NULL;
00416 }
00417 if(message->update_name != NULL) {
00418 free(message->update_name);
00419 }
00420 if(message->from_address != NULL) {
00421 free(message->from_address);
00422 }
00423 if(message->to_address != NULL) {
00424 free(message->to_address);
00425 }
00426 if(message->target != NULL) {
00427 free(message->target);
00428 }
00429
00430 free(message);
00431 message = NULL;
00432 return MC_SUCCESS;
00433 }
00434
00435
00436 int
00437 auth_rece_send_msg(int sockfd, char *hostname, char *message, char *privkey, char *known_host_filename){
00438
00439 int ret=-1;
00440 unsigned char passphrase[35], aes_key[35];
00441 int nonce, mode;
00442 char privatekey[1215];
00443 char peer_pubkey[300], ch;
00444 char plaintext[135];
00445 FILE *fd, *tempfd;
00446 char buffer[10];
00447 struct stat stbuf;
00448
00449
00450 char *infile;
00451 char *outfile;
00452 char *tempfile;
00453 memset(passphrase , '\0', 35);
00454 memset(privatekey , '\0', 1215);
00455 memset(plaintext , '\0', 135);
00456 memset(aes_key, '\0', 35);
00457
00458
00459
00460
00461 #ifndef _WIN32
00462 int fd1;
00463 infile = (char *)malloc(sizeof(char)*20);
00464 strcpy(infile, "msgXXXXXX");
00465 fd1 = mkstemp(infile);
00466 if (fd == -1) {
00467 fprintf(stderr, "Could not create temporary file:%s. %s:%d\n",
00468 infile, __FILE__, __LINE__ );
00469 exit(EXIT_FAILURE);
00470 }
00471 close(fd1);
00472
00473 outfile = (char *)malloc(sizeof(char)*20);
00474 strcpy(outfile, "en-msgXXXXXX");
00475 fd1 = mkstemp(outfile);
00476 if (fd1 == -1) {
00477 fprintf(stderr, "Could not create temporary file:%s. %s:%d\n",
00478 outfile, __FILE__, __LINE__ );
00479 exit(EXIT_FAILURE);
00480 }
00481 close(fd1);
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492 #else
00493 infile = _tempnam(".", "msg");
00494 outfile = _tempnam(".", "en-msg");
00495 #endif
00496
00497
00498
00499
00500
00501
00502 strcpy(privatekey, privkey);
00503
00504
00505
00506
00507 if (read_known_host_file(peer_pubkey, hostname, known_host_filename) == -1 ){
00508 printf("Client: %s 's Public key not found in know host file\n", hostname);
00509 if( remove(infile) ) printf("message.c : remove error 4");
00510 if( remove(outfile) ) printf("message.c : remove error 5");
00511 #ifndef _WIN32
00512
00513 #else
00514
00515 #endif
00516 }else{
00517 if ((ret=initiate_migration_process(sockfd, &nonce, peer_pubkey, privatekey, aes_key)) != 1){
00518 if (ret == -1)
00519 printf("Client: Connected peer is not authenticated \n");
00520 if (ret == -2)
00521 printf("Client: Unable to get authentication from oither peer \n");
00522 }else{
00523
00524
00525
00526
00527 if( (fd = fopen(infile,"w")) == NULL){
00528 printf("Unable to write message in a file \n");
00529 if( remove(infile) ) printf("message.c : remove error 1");
00530 }else{
00531
00532 fwrite (message , 1 , strlen(message) , fd );
00533 fclose(fd);
00534
00535 mode = 0;
00536 if (aes_en_de(mode, infile, outfile, aes_key, &nonce, 0) != 1){
00537 printf("Client: AES Encryption Failed \n");
00538 if( remove(infile) ) printf("message.c : remove error 2");
00539 if( remove(outfile) ) printf("message.c : remove error 3");
00540 }else{
00541 if( remove(infile) ) printf("message.c : remove error 4");
00542 if (send_AES_en_MA(sockfd, &nonce, outfile, peer_pubkey) != 1 ){
00543 printf("Client: Error while sending mobile agent \n");
00544 if( remove(outfile) ) printf("message.c : remove error 5");
00545 }else{
00546 if( remove(outfile) ) printf("message.c : remove error 6");
00547
00548 ret = 2;
00549 }
00550 }
00551 }
00552 }
00553 }
00554
00555
00556
00557
00558 return ret;
00559 }
00560
00561 #define MSG_THREADS 40
00562 int message_Send(mc_platform_t* mc_platform, message_p message, char *privatekey)
00563 {
00564 THREAD_T msg_thread;
00565 message_send_arg_t* arg;
00566 #ifndef _WIN32
00567 pthread_attr_t attr;
00568 pthread_attr_init(&attr);
00569 #else
00570 int stack_size = 0;
00571 #endif
00572
00573 arg = (message_send_arg_t*)malloc(sizeof(message_send_arg_t));
00574 arg->mc_platform = mc_platform;
00575 arg->message = message;
00576 arg->privatekey = privatekey;
00577
00578 MUTEX_LOCK(&mc_platform->acc->msg_thread_lock);
00579 while(mc_platform->acc->num_msg_threads >= MSG_THREADS) {
00580 COND_WAIT(&mc_platform->acc->msg_thread_cond, &mc_platform->acc->msg_thread_lock);
00581 }
00582 mc_platform->acc->num_msg_threads++;
00583 MUTEX_UNLOCK(&mc_platform->acc->msg_thread_lock);
00584
00585 THREAD_CREATE(&msg_thread, message_send_Thread, arg);
00586 THREAD_DETACH(msg_thread);
00587 }
00588
00589
00590 #define MSG_THREAD_EXIT() \
00591 free(arg); \
00592 message_Destroy(message); \
00593 MUTEX_LOCK(&mc_platform->acc->msg_thread_lock); \
00594 mc_platform->acc->num_msg_threads--; \
00595 COND_SIGNAL(&mc_platform->acc->msg_thread_cond); \
00596 MUTEX_UNLOCK(&mc_platform->acc->msg_thread_lock); \
00597 THREAD_EXIT()
00598
00599 #ifndef _WIN32
00600 void*
00601 message_send_Thread(void* arg)
00602 #else
00603 DWORD WINAPI
00604 message_send_Thread( LPVOID arg )
00605 #endif
00606 {
00607 mc_platform_t* mc_platform;
00608 message_p message;
00609 char* privatekey;
00610 char *buffer;
00611 mtp_http_t* mtp_http;
00612 int n, ret;
00613 #ifndef _WIN32
00614 int skt;
00615 struct sockaddr_in sktin;
00616 struct addrinfo* myaddrinfo;
00617 #else
00618 SOCKET skt;
00619 SOCKADDR_IN sktin;
00620 #endif
00621 struct hostent host;
00622 struct hostent *host_result;
00623 char *buf;
00624 char *hostname;
00625 #ifndef _WIN32
00626 char *saveptr;
00627 #endif
00628 int port;
00629
00630 int num_tries = 0;
00631 const int max_num_tries = 100;
00632 int errnum;
00633
00634 dynstring_t* message_string;
00635
00636 char hostbuf[80];
00637 int hostbuf_len = 80;
00638
00639 mc_platform = ((message_send_arg_t*)arg)->mc_platform;
00640 message = ((message_send_arg_t*)arg)->message;
00641 privatekey = ((message_send_arg_t*)arg)->privatekey;
00642
00643
00644 if (
00645 mtp_http_ComposeMessage(
00646 message
00647 )
00648 )
00649 {
00650 fprintf(stderr, "Compose Message Error. %s:%d\n", __FILE__, __LINE__);
00651 MSG_THREAD_EXIT();
00652 }
00653
00654
00655 buf = (char*)malloc(sizeof(char)*(strlen(message->to_address)+1));
00656 strcpy(buf, message->to_address);
00657 hostname = strtok_r(buf, ":", &saveptr);
00658 sscanf( strtok_r(NULL, ":", &saveptr), "%d", &port );
00659
00660 if((skt = socket(PF_INET, SOCK_STREAM, 0)) < 0)
00661 {
00662 fprintf(stderr, "Error - can't create socket\n");
00663 MSG_THREAD_EXIT();
00664 }
00665
00666 memset(&sktin, 0, sizeof(sktin));
00667 sktin.sin_family = PF_INET;
00668 sktin.sin_port = htons(port);
00669
00670 #ifndef _WIN32
00671
00672 if( (errnum = getaddrinfo(hostname, NULL, NULL, &myaddrinfo)) == 0 )
00673 #else
00674 if(host_result = gethostbyname(hostname))
00675 #endif
00676 {
00677 #ifdef _WIN32
00678 host = *host_result;
00679 memcpy(&sktin.sin_addr, host.h_addr, host.h_length);
00680 #else
00681 ((struct sockaddr_in*)myaddrinfo->ai_addr)->sin_port = htons(port);
00682 #endif
00683 }
00684 else if((sktin.sin_addr.s_addr = inet_addr(hostname)) < 0)
00685 {
00686 fprintf(stderr, "Error - can't get host entry for %s\n", hostname);
00687 free(buf);
00688 MSG_THREAD_EXIT();
00689 }
00690
00691 while(
00692 #ifndef _WIN32
00693 (connect(skt, myaddrinfo->ai_addr, sizeof(struct sockaddr)) < 0) &&
00694 #else
00695 (connect(skt, (struct sockaddr *) &sktin, sizeof(sktin)) < 0) &&
00696 #endif
00697 (num_tries < max_num_tries)
00698 ) {
00699 printf("%s ERROR Socket Connect failed... errno:%s\n", message->sending_agent_name, strerror(errno));
00700 #ifndef _WIN32
00701 usleep(100000);
00702 #else
00703 Sleep(100);
00704 #endif
00705 num_tries++;
00706 }
00707 if (num_tries == max_num_tries) {
00708 fprintf(stderr, "Error - can't connect to %s:%d\n",
00709 hostname,
00710 port
00711 );
00712 free(buf);
00713 MSG_THREAD_EXIT();
00714 }
00715
00716 #ifdef NEW_SECURITY
00717
00718 ret = auth_rece_send_msg(skt, hostname, message->message_body, privatekey, mc_platform->agency->known_host_filename);
00719 if( ret == 1 ){
00720 printf("Successfull Authenticate and but send of MA is failed \n");
00721 #ifndef _WIN32
00722 if(close(skt) < 0) {
00723 SOCKET_ERROR();
00724 }
00725 #else
00726 closesocket(skt);
00727 #endif
00728 free(buf);
00729 fprintf(stderr, "Security Error. %s:%d\n", __FILE__, __LINE__);
00730 MSG_THREAD_EXIT();
00731 }else if(ret != 2){
00732 #ifndef _WIN32
00733 if(close(skt) < 0) {
00734 SOCKET_ERROR();
00735 }
00736 #else
00737 closesocket(skt);
00738 #endif
00739 free(buf);
00740 fprintf(stderr, "Security Error. %s:%d\n", __FILE__, __LINE__);
00741 MSG_THREAD_EXIT();
00742 }else if(ret == 2)
00743
00744 #else
00745 if(send(skt, message->message_body, strlen(message->message_body), 0) < 0) {
00746 perror(send);
00747 printf("cannot write to socket %s:%d\n", __FILE__, __LINE__);
00748 }
00749 else
00750 #endif
00751 {
00752
00753 buffer = (char*) malloc(sizeof(char) * (SOCKET_INPUT_SIZE + 1));
00754 CHECK_NULL(buffer, exit(0););
00755 mtp_http = mtp_http_New();
00756 message_string = dynstring_New();
00757 while(1) {
00758 #ifndef _WIN32
00759
00760
00761
00762
00763
00764
00765
00766 n = recv(skt, (void*)buffer, (size_t) sizeof(char)*SOCKET_INPUT_SIZE, MSG_WAITALL);
00767 #else
00768 n = recvfrom(skt,
00769 (void *) buffer,
00770 (size_t) sizeof(char)*SOCKET_INPUT_SIZE,
00771 0,
00772 (struct sockaddr *) 0,
00773 0);
00774 #endif
00775 if (n<0) {
00776
00777 SOCKET_ERROR();
00778 free(buffer);
00779 MSG_THREAD_EXIT();
00780 }
00781 else if (n==0) {
00782 break;
00783 }
00784 else
00785 {
00786 dynstring_Append(message_string, buffer);
00787 }
00788 }
00789 if( mtp_http_Parse(mtp_http, message_string->message) ) {
00790 fprintf(stderr, "http parsing error: Response expected. %s:%d\n",
00791 __FILE__, __LINE__);
00792 fprintf(stderr, "Received message was:\n%s\n", message_string->message);
00793 }
00794 if (mtp_http->response_code != 200) {
00795 fprintf(stderr, "Warning: remote http server responded: %d %s\n",
00796 mtp_http->response_code, mtp_http->response_string );
00797 }
00798
00799 mtp_http_Destroy(mtp_http);
00800 }
00801
00802 #ifndef _WIN32
00803 if(close(skt) <0) {
00804 SOCKET_ERROR();
00805 }
00806 #else
00807 closesocket(skt);
00808 #endif
00809 free(buf);
00810 free(buffer);
00811 dynstring_Destroy(message_string);
00812 MSG_THREAD_EXIT();
00813 }
00814
00815 #undef MSG_THREAD_EXIT()