void test_22_frame_received (VortexChannel * channel, VortexConnection * conn, VortexFrame * frame, axlPointer user_data) { const char * payload = (const char *) vortex_frame_get_payload (frame); char * value; if (axl_cmp (payload, "getServerName")) { /* get servername or empty string */ payload = vortex_connection_get_server_name (conn); if (payload == NULL) payload = ""; vortex_channel_send_rpy (channel, payload, strlen (payload), vortex_frame_get_msgno (frame)); return; } /* end if */ /* support for getRemoveAddress */ if (axl_cmp (payload, "getRemoteAddress")) { value = axl_strdup_printf ("%s:%s", vortex_connection_get_host (conn), vortex_connection_get_port (conn)); printf ("Test 28: (SERVER), sending %s (%d)\n", value, (int) strlen (value)); vortex_channel_send_rpy (channel, value, strlen (value), vortex_frame_get_msgno (frame)); axl_free (value); return; } /* end if */ /* send rpy */ vortex_channel_send_rpy (channel, vortex_frame_get_payload (frame), vortex_frame_get_payload_size (frame), vortex_frame_get_msgno (frame)); return; }
int on_accepted (VortexConnection * connection, axlPointer data) { printf ("New connection accepted from: %s:%s\n", vortex_connection_get_host (connection), vortex_connection_get_port (connection)); /* return axl_true to accept the connection to be created */ return axl_true; }
axl_bool __mod_sasl_mysql_prepare_query_and_auth (TurbulenceCtx * ctx, const char * _query, VortexConnection * conn, axlNode * auth_db_node_conf, const char * auth_id, const char * authorization_id, const char * formated_password, const char * password, const char * serverName, const char * sasl_method, axl_bool just_run_query, axl_bool skip_login_error_reporting, axlError ** err) { MYSQL_RES * result; MYSQL_ROW row; axl_bool _result; char * query; /* duplicate query */ query = axl_strdup (_query); if (query == NULL) return axl_false; /* allocation failure */ /* replace query with recognized tokens */ axl_replace (query, "%u", auth_id); axl_replace (query, "%n", serverName); axl_replace (query, "%i", authorization_id); axl_replace (query, "%m", sasl_method); axl_replace (query, "%p", vortex_connection_get_host (conn)); if (! just_run_query) { msg ("Trying to auth [%s] with query string [%s], conn-id=%d from %s:%s ", auth_id, query, vortex_connection_get_id (conn), vortex_connection_get_host (conn), vortex_connection_get_port (conn)); } /* end if */ /* run query */ result = mod_sasl_mysql_do_query (ctx, auth_db_node_conf, query, axl_false, err); axl_free (query); /* check if we have to only run this query */ if (just_run_query) { mysql_free_result (result); return axl_true; } /* end if */ /* check result */ if (result == NULL) { error ("Unable to authenticate user, query string failed with %s", axl_error_get (*err)); axl_error_free (*err); return axl_false; } /* end if */ /* return content from the first [0][0] array position */ row = mysql_fetch_row (result); if (row == NULL) { if (! skip_login_error_reporting) { /* log login failure */ error ("login failure: %s, failed from: %s", auth_id, vortex_connection_get_host_ip (conn)); } /* end if */ mysql_free_result (result); return axl_false; } /* end if */ /* check result */ _result = axl_cmp (row[0], formated_password); if (! _result) { /* if it fails, check password format */ /* support here passwords schemes using */ /* http://wiki.dovecot.org/Authentication/PasswordSchemes */ _result = common_sasl_check_crypt_password (password, row[0]); } /* end if */ mysql_free_result (result); return _result; }
/** * @brief a frame received Callback */ void listenerFrameReceivedCallback (VortexChannel* channel, VortexConnection* connection, VortexFrame* frame, axlPointer user_data) { VORTEXListenerFrameReceivedCallbackData* callbackData = (VORTEXListenerFrameReceivedCallbackData*) user_data; TML_INT32 iRet = TML_SUCCESS; ///////////////////////////////////////////////////////////////////////////// // Fetching all necessary attributes from Vortex: /////////////////////////// // Die Connection ID: callbackData->pLog->log (TML_LOG_VORTEX_CMD, "TMLCoreListener", "listenerFrameReceivedCallback", "Vortex CMD", "vortex_connection_get_id"); int iConnectionID = vortex_connection_get_id(connection); /////////////////////////// // Die Host IP: callbackData->pLog->log (TML_LOG_VORTEX_CMD, "TMLCoreListener", "listenerFrameReceivedCallback", "Vortex CMD", "vortex_connection_get_host_ip"); const char* sHostIP = vortex_connection_get_host_ip(connection); /////////////////////////// // Der Port: callbackData->pLog->log (TML_LOG_VORTEX_CMD, "TMLCoreListener", "listenerFrameReceivedCallback", "Vortex CMD", "vortex_connection_get_local_port"); const char* sPort = vortex_connection_get_port(connection); /////////////////////////// // Die Channel ID: callbackData->pLog->log (TML_LOG_VORTEX_CMD, "TMLCoreListener", "listenerFrameReceivedCallback", "Vortex CMD", "vortex_channel_get_number"); int iChannelID = vortex_channel_get_number (channel); if (-1 == iChannelID) iRet = TML_ERR_LISTENER_COMMUNICATION; /////////////////////////// // Die Message ID: callbackData->pLog->log (TML_LOG_VORTEX_CMD, "TMLCoreListener", "listenerFrameReceivedCallback", "Vortex CMD", "vortex_frame_get_msgno"); int iMsgID = vortex_frame_get_msgno (frame); if (-1 == iMsgID) iRet = TML_ERR_LISTENER_COMMUNICATION; /////////////////////////// // Das Profil, mit dem der Sender conneted ist: callbackData->pLog->log (TML_LOG_VORTEX_CMD, "TMLCoreListener", "listenerFrameReceivedCallback", "Vortex CMD", "vortex_channel_get_profile"); const char* sProfile = vortex_channel_get_profile (channel); if (NULL == sProfile) iRet = TML_ERR_LISTENER_COMMUNICATION; /////////////////////////// // Das Payload: callbackData->pLog->log (TML_LOG_VORTEX_CMD, "TMLCoreListener", "listenerFrameReceivedCallback", "Vortex CMD", "vortex_frame_get_payload"); char* cPayload = (char*)vortex_frame_get_payload (frame); if (NULL == cPayload) iRet = TML_ERR_LISTENER_COMMUNICATION; /////////////////////////// // Die Payloadsize: callbackData->pLog->log (TML_LOG_VORTEX_CMD, "TMLCoreListener", "listenerFrameReceivedCallback", "Vortex CMD", "vortex_frame_get_payload_size"); int iPayloadSize = vortex_frame_get_payload_size (frame); if (-1 == iPayloadSize) iRet = TML_ERR_LISTENER_COMMUNICATION; ///////////////////////////////////////////////////////////////////////////// // Set all necessary Vortex attributes into the TML_COMMAND_HANDLE Obj: if (TML_SUCCESS == iRet){ // A new TML_COMMAND_HANDLE object out of the payload: TML_COMMAND_HANDLE cmdHandle; iRet = tml_Cmd_Create(&cmdHandle); if (TML_SUCCESS == iRet){ SIDEX_HANDLE sHandle; /////////////////////////////////////////////// // Acquire critical section use: tml_Cmd_Acquire_Sidex_Handle(cmdHandle, &sHandle); iRet = sidex_Set_Content(sHandle, cPayload); /////////////////////////////////////////////// // Now I can release the critical section use: tml_Cmd_Release_Sidex_Handle(cmdHandle); } if (TML_SUCCESS == iRet){ // Vortex- session ID into the TML_COMMAND_HANDLE object: tml_Cmd_Attr_Set_Session_ID(cmdHandle, iConnectionID); // Don't mind of return value // Vortex- channel ID into the TML_COMMAND_HANDLE object: tml_Cmd_Attr_Set_Channel_ID(cmdHandle, iChannelID); // Don't mind of return value callbackData->pLog->log (TML_LOG_VORTEX_CMD, "TMLCoreListener", "listenerFrameReceivedCallback", "Vortex CMD", "vortex_channel_ref"); vortex_channel_ref(channel); // I will be shure to have a valid channel until the reply is send // Vortex- channel into the TML_COMMAND_HANDLE object: tml_Cmd_Attr_Set_Channel(cmdHandle, channel); // Don't mind of return value // Vortex- message ID into the TML_COMMAND_HANDLE object: tml_Cmd_Attr_Set_Message_ID(cmdHandle, iMsgID); // Don't mind of return value // Vortex- profile into the TML_COMMAND_HANDLE object: tml_Cmd_Attr_Set_Profile(cmdHandle, sProfile); // The core handle: tml_Cmd_Attr_Set_Core_Reference(cmdHandle, callbackData->tmlcorehandle); // Don't mind of return value TML_CONNECTION_HANDLE connectionHandle = TML_HANDLE_TYPE_NULL; ////////////////////////////////////////////////////////////////// // Add the connection to the list: if (NULL != sHostIP && NULL != sPort && NULL != connection){ ((tmlCoreWrapper*)callbackData->tmlcorehandle)->tmlCoreWrapper_Connect(sHostIP, sPort, false, &connectionHandle, connection); ((tmlObjWrapper*)cmdHandle)->tmlObjWrapper_Set_Connection(connectionHandle); } // Now call the callback method: globalCallback(callbackData->callback, (void*) cmdHandle); } } else{ callbackData->pLog->log ("TMLCoreListener", "listenerFrameReceivedCallback", "ERROR", "Problem on getting some attributes."); } return; }