-/* @(#) $Id: sendmsg.c,v 1.4 2009/06/24 18:53:07 dcid Exp $ */
+/* @(#) $Id: ./src/remoted/sendmsg.c, 2011/09/08 dcid Exp $
+ */
/* Copyright (C) 2009 Trend Micro Inc.
* All right reserved.
*
* This program is a free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
- * License (version 3) as published by the FSF - Free Software
+ * License (version 2) as published by the FSF - Free Software
* Foundation
*/
{
return(0);
}
-
+
key_lock();
-
+
/* Locking before using */
if(pthread_mutex_lock(&sendmsg_mutex) != 0)
{
merror(MUTEX_ERROR, ARGV0);
return(0);
}
-
+
if(OS_UpdateKeys(&keys))
{
if(pthread_mutex_unlock(&sendmsg_mutex) != 0)
merror(MUTEX_ERROR, ARGV0);
}
key_unlock();
-
+
return(0);
}
}
-/* send_msg()
+/* send_msg()
* Send message to an agent.
* Returns -1 on error
*/
return(-1);
}
-
+
msg_size = CreateSecMSG(&keys, msg, crypt_msg, agentid);
if(msg_size == 0)
{
return(-1);
}
-
+
/* Locking before using */
if(pthread_mutex_lock(&sendmsg_mutex) != 0)
{
/* Sending initial message */
if(sendto(logr.sock, crypt_msg, msg_size, 0,
(struct sockaddr *)&keys.keyentries[agentid]->peer_info,
- logr.peer_size) < 0)
+ logr.peer_size) < 0)
{
merror(SEND_ERROR,ARGV0, keys.keyentries[agentid]->id);
}
-
-
+
+
/* Unlocking mutex */
if(pthread_mutex_unlock(&sendmsg_mutex) != 0)
{
merror(MUTEX_ERROR, ARGV0);
return(-1);
}
-
+
return(0);
}