void receiving(void)
{
	int expecting_len = 0;

	sending(expecting_len);

	while (1) {
		PRINT("%s: Waiting packet\n", __func__);

		if (wait_reply(__func__, unicast,
			       ipsum_len, expecting)) {
			if (expecting_len > 0) {
				PRINT("Resend %d bytes -> FAIL\n",
				      ipsum_len - expecting);
				expecting_len = 0;
			} else {
				PRINT("Waiting %d bytes -> resending\n",
				      ipsum_len - expecting);
				expecting_len = expecting;
			}
		}

		sending(expecting_len);
	}
}
Beispiel #2
0
void test_refresh(int vers)
{
    ConnContext *alicecontext, *bobcontext;

    printf("\n\n*** Testing refresh ***\n\n");

    otrl_context_forget_all(us);
    if (vers == 1)
	ALICEPOLICY = OTRL_POLICY_ALLOW_V1;
    else if (vers == 2)
	ALICEPOLICY = OTRL_POLICY_ALLOW_V2;
    else
	ALICEPOLICY = OTRL_POLICY_DEFAULT;
    sending(ALICE, BOB, "?OTR?"); dispatch();

    alicecontext = otrl_context_find(us, BOB, ALICE, PROTO, 0, 0, NULL, NULL, NULL);
    bobcontext = otrl_context_find(us, ALICE, BOB, PROTO, 0, 0, NULL, NULL, NULL);
    printf("%p %p\n", alicecontext, bobcontext);

    sending(ALICE, BOB, "Hi!"); dispatch();
    sending(BOB, ALICE, "There!"); dispatch();
    sending(ALICE, BOB, "You!"); dispatch();
    sending(ALICE, BOB, "Guys!"); dispatch();
    sending(BOB, ALICE, "?OTR?"); dispatch();
    sending(ALICE, BOB, "Refreshed!"); dispatch();
    sending(BOB, ALICE, "Also refreshed!"); dispatch();
}
Beispiel #3
0
void ENgrab::sendstop()
{
	eDebug("ngrab sendstop requested");
	sendStr = stopxml();
	nGrabActive = false;
	sending();
}
Beispiel #4
0
void ENgrab::sendstart( const char *descr )
{
	eDebug("ngrab sendstart requested");
	sendStr = startxml(descr);
	nGrabActive = true;
	sending();
}
Beispiel #5
0
void SMTP::sendContinueGotPassword()
{
    isWaitingForPassword = false;
    if (encryptedConnect)
        qwwSmtp->connectToHostEncrypted(host, port);
    else
        qwwSmtp->connectToHost(host, port);
    if (startTls)
        qwwSmtp->startTls();
    if (auth)
        qwwSmtp->authenticate(user, pass,
                              (startTls || encryptedConnect) ?
                              QwwSmtpClient::AuthPlain :
                              QwwSmtpClient::AuthAny);
    emit sending(); // FIXME: later
    switch (sendingMode) {
    case MODE_SMTP_DATA:
        qwwSmtp->sendMail(from, to, QString::fromUtf8(data));
        break;
    case MODE_SMTP_BURL:
        qwwSmtp->sendMailBurl(from, to, data);
        break;
    default:
        failed = true;
        emit error(tr("Unknown SMTP mode"));
        break;
    }
    qwwSmtp->disconnectFromHost();
}
Beispiel #6
0
void SMTP::sendContinueGotPassword()
{
    isWaitingForPassword = false;
    if (encryptedConnect)
        qwwSmtp->connectToHostEncrypted(host, port);
    else
        qwwSmtp->connectToHost(host, port);
    if (startTls)
        qwwSmtp->startTls();
    if (auth)
        qwwSmtp->authenticate(user, pass,
                               (startTls || encryptedConnect) ?
                               QwwSmtpClient::AuthPlain :
                               QwwSmtpClient::AuthAny);
    emit sending(); // FIXME: later
    switch (sendingMode) {
    case MODE_SMTP_DATA:
        {
            //RFC5321 specifies to prepend a period to lines starting with a period in section 4.5.2
            if (data.startsWith('.'))
                data.prepend('.');
            data.replace("\n.", "\n..");
            qwwSmtp->sendMail(from, to, QString::fromUtf8(data));
        }
        break;
    case MODE_SMTP_BURL:
        qwwSmtp->sendMailBurl(from, to, data);
        break;
    default:
        failed = true;
        emit error(tr("Unknown SMTP mode"));
        break;
    }
    qwwSmtp->disconnectFromHost();
}
Beispiel #7
0
void receiving(void)
{
	sending();

	while (1) {
		PRINT("%s: Waiting packet\n", __func__);

		if (wait_reply(__func__, unicast,
			       ipsum_len, expecting)) {
			PRINT("Waiting %d bytes -> FAIL\n",
			      ipsum_len - expecting);
		}

		sending();
	}
}
Beispiel #8
0
void test_crash1(void)
{
    ConnContext *alicecontext, *bobcontext;

    printf("\n\n*** Testing old double gcry_cipher_release case ***\n\n");

    otrl_context_forget_all(us);
    ALICEPOLICY = OTRL_POLICY_DEFAULT;
    sending(ALICE, BOB, "?OTR?");
    dispatch();

    alicecontext = otrl_context_find(us, BOB, ALICE, PROTO, 0, 0, NULL, NULL, NULL);
    bobcontext = otrl_context_find(us, ALICE, BOB, PROTO, 0, 0, NULL, NULL, NULL);

    sending(ALICE, BOB, "Hi!"); dispatch();
    sending(BOB, ALICE, "There!"); dispatch();
    sending(ALICE, BOB, "You!"); dispatch();
    otrl_context_force_plaintext(bobcontext);
    sending(BOB, ALICE, "?OTR?"); dispatch();
    sending(ALICE, BOB, "now."); dispatch();
    printf("%d %p %p\n", alicecontext->our_keyid, alicecontext->their_y, alicecontext->their_old_y);
    printf("%p %p %p %p\n",
    alicecontext->sesskeys[0][0].sendenc,
    alicecontext->sesskeys[0][1].sendenc,
    alicecontext->sesskeys[1][0].sendenc,
    alicecontext->sesskeys[1][1].sendenc);
    sending(BOB, ALICE, "then."); dispatch();
}
Beispiel #9
0
void ImapSubmit::sendImap(const QString &mailbox, const int uidValidity, const int uid,
                          const Imap::Mailbox::UidSubmitOptionsList options)
{
    Imap::Mailbox::UidSubmitTask *submitTask = m_model->sendMailViaUidSubmit(mailbox, uidValidity, uid, options);
    Q_ASSERT(submitTask);
    connect(submitTask, SIGNAL(completed(Imap::Mailbox::ImapTask*)), this, SIGNAL(sent()));
    connect(submitTask, SIGNAL(failed(QString)), this, SIGNAL(error(QString)));
    QTimer::singleShot(0, this, SIGNAL(sending()));
}
Beispiel #10
0
void Sendmail::handleStarted()
{
    // The process has started already -> +1
    emit progress(1);

    emit sending();
    proc->write(dataToSend);
    proc->closeWriteChannel();
}
Beispiel #11
0
void Channel::stopSend()
{
	if(!sending())
		return;

	mFlags &= ~Flag_Sending;

	mpNetworkManager->dispatcher().deregisterWriteFileDescriptor(*mpEndPoint);
}
Beispiel #12
0
JNIEXPORT void JNICALL Java_com_example_hellojni_HelloJni_nativeStartTcpClient
(JNIEnv *env, jobject obj, jstring ip, jint port, jstring message)
{
    sending(env, obj);


//    // Construct a new TCP socket.
//    int clientSocket = NewTcpSocket(env, obj);
//    if (NULL == env->ExceptionOccurred())
//    {
//        // Get IP address as C string
//        const char* ipAddress = env->GetStringUTFChars(ip, NULL);
//        if (NULL == ipAddress)
//            goto exit;
//
//        // Connect to IP address and port
//        ConnectToAddress(env, obj, clientSocket, ipAddress,
//                         port);
//
//        // Release the IP address
//        env->ReleaseStringUTFChars(ip, ipAddress);
//
//        // If connection was successful
//        if (NULL != env->ExceptionOccurred())
//            goto exit;
//
//        // Get message as C string
//        const char* messageText = env->GetStringUTFChars(message, NULL);
//        if (NULL == messageText)
//            goto exit;
//
//        // Get the message size
//        jsize messageSize = env->GetStringUTFLength(message);
//
//        // Send message to socket
//        SendToSocket(env, obj, clientSocket, messageText, messageSize);
//
//        // Release the message text
//        env->ReleaseStringUTFChars(message, messageText);
//
//        // If send was not successful
//        if (NULL != env->ExceptionOccurred())
//            goto exit;
//
//        char buffer[MAX_BUFFER_SIZE];
//
//        // Receive from the socket
//        ReceiveFromSocket(env, obj, clientSocket, buffer, MAX_BUFFER_SIZE);
//    }
//
//exit:
//    if (clientSocket > 0)
//    {
//        close(clientSocket);
//    }
}
Beispiel #13
0
static void test(int vers, int both)
{
    printf("\n\n*** Testing version %d, %s ***\n\n", vers,
	    both ? "simultaneous start" : "Alice start");

    otrl_context_forget_all(us);
    if (vers == 1)
	ALICEPOLICY = OTRL_POLICY_ALLOW_V1;
    else if (vers == 2)
	ALICEPOLICY = OTRL_POLICY_ALLOW_V2;
    else
	ALICEPOLICY = OTRL_POLICY_DEFAULT;
    sending(ALICE, BOB, "?OTR?");
    if (both) {
	sending(BOB, ALICE, "?OTR?");
    }
    dispatch();
    sending(ALICE, BOB, "Hi there");
    dispatch();
}
Beispiel #14
0
void test_unreadable(void)
{
    ConnContext *bobcontext;

    printf("\n\n*** Testing Bob receiving unreadable messages from "
	    "Alice ***\n\n");

    bobcontext = otrl_context_find(us, ALICE, BOB, PROTO, 0, 0, NULL, NULL, NULL);
    otrl_context_force_plaintext(bobcontext);
    sending(ALICE, BOB, "unreadable text");
    dispatch();

}
Beispiel #15
0
  void run(std::istream& streamOfMessagesToSend, std::ostream& streamForReceivedMessages) {
    try {
      std::thread sending(std::bind(&messenger::Messenger<Message>::sendMessages, this, 
        std::ref(streamOfMessagesToSend)));
      std::thread receiving(std::bind(&messenger::Messenger<Message>::receiveMessages, this, 
        std::ref(streamForReceivedMessages)));

      sending.join();
      receiving.join();
    }
    catch(const std::exception& e) {
      std::cerr << e.what() << std::endl;
    }
  }
void	        accept_file(t_server *serv, t_user *user, char *cmd)
{
  t_file	*file;
  char		*nick;

  nick = split_string(cmd, ' ', 1);
  if (nick != NULL)
    {
      file = get_file_by_fromto(serv->files, nick, user->nick);
      if (file != NULL)
	sending(serv, user, file);
      else
	swrite(user->fd, "502 ERR_USERSDONTMATCH :No file to download\r\n");
    }
  else
    swrite(user->fd, "461 ERR_NEEDMOREPARAMS :Not enough parameters\r\n");
}
Beispiel #17
0
 std::vector<int64_t> vector() const
 {
     return std::vector<int64_t>{used(), sending(), freeing(), unused()};
 }
Beispiel #18
0
 std::string percentages() const
 {
     return percentage_str(used()) + " " + percentage_str(sending()) +
            " " + percentage_str(freeing()) + " " +
            percentage_str(unused());
 }
Beispiel #19
0
void Channel::send(Bundle *pBundle)
{
	if (isDestroyed())
	{
		/*ERROR_MSG(fmt::format("Channel::send({}): channel has destroyed.\n", this->c_str()));*/
		
		this->clearBundle();

		if(pBundle)
			Bundle::ObjPool().reclaimObject(pBundle);

		return;
	}

	if(isCondemn())
	{
		this->clearBundle();

		if(pBundle)
			Bundle::ObjPool().reclaimObject(pBundle);

		return;
	}

	if(pBundle)
	{
		pBundle->finiMessage(true);
		mBundles.push_back(pBundle);
	}
	
	uint32 bundleSize = (uint32)mBundles.size();
	if(bundleSize == 0)
		return;

	if(!sending())
	{
		if(mpPacketSender == NULL)
			mpPacketSender = new TCPPacketSender(*mpEndPoint, *mpNetworkManager);

		mpPacketSender->processSend(this); // 直接发送。避免系统在可写事件上的频发虚耗

		if(mBundles.size() > 0 && !isCondemn() && !isDestroyed()) // 要是实在没发送完全,好吧,等待发送缓冲区就绪吧!
		{
			mFlags |= Flag_Sending;
			mpNetworkManager->dispatcher().registerWriteFileDescriptor(*mpEndPoint, mpPacketSender);
		}
	}

	if(gSendWindowMessagesOverflowCritical > 0 && bundleSize > gSendWindowMessagesOverflowCritical)
	{
		if(this->isExternal())
		{
			// 			WARNING_MSG(fmt::format("Channel::send[{:p}]: external channel({}), send window has overflowed({} > {}).\n", 
			// 				(void*)this, this->c_str(), bundleSize, gSendWindowMessagesOverflowCritical));

			if(gExtSendWindowMessagesOverflow > 0 && bundleSize > gExtSendWindowMessagesOverflow)
			{
				// 				ERROR_MSG(fmt::format("Channel::send[{:p}]: external channel({}), send window has overflowed({} > {}), Try adjusting the ngine_defs.xml->windowOverflow->send.\n", 
				// 					(void*)this, this->c_str(), bundleSize, gExtSendWindowMessagesOverflow));

				this->condemn();
			}
		}
		else
		{
			if(gIntSendWindowMessagesOverflow > 0 && bundleSize > gIntSendWindowMessagesOverflow)
			{
				// 				ERROR_MSG(fmt::format("Channel::send[{:p}]: internal channel({}), send window has overflowed({} > {}).\n", 
				// 					(void*)this, this->c_str(), bundleSize, gIntSendWindowMessagesOverflow));

				this->condemn();
			}
			else
			{
				// 				WARNING_MSG(fmt::format("Channel::send[{:p}]: internal channel({}), send window has overflowed({} > {}).\n", 
				// 					(void*)this, this->c_str(), bundleSize, gSendWindowMessagesOverflowCritical));
			}
		}
	}
}
Beispiel #20
0
void Channel::onSendCompleted()
{
	Assert(mBundles.size() == 0 && sending());
	stopSend();
}
Beispiel #21
0
/********************************************************************************
 * FunctionName: Tasktest
 *
 * Description : 协议发送任务
 *
 * Parameters  :
 *
 * Returns     : None.
 *******************************************************************************/
void TaskTest(void *p_arg)
{
    INT8U err ;
//    u16 i;
  //  unsigned char buf[]="0123456789abcdefghijklmnopqrstuvwxyz";
    INT32U msg;
    u8 send_sig=0;  //发送信号 标志位 1:学习成功 2:学习失败 3:正在学习中
    p_arg = p_arg;

    for (;;)
    {
    /********发射4432数据********/
    msg = (INT32U)OSQPend(TestMBox, 0, &err);
    send_sig= msg;
       if(send_sig!=0)
      {
           WatchDog_Feed(); //喂狗
          if(send_sig==1)
          {
              if (Learn_State==1)//空调学习成功
              {
                   WatchDog_Feed(); //喂狗
                 Send_LenStop(USART2);//停止学习
                  WatchDog_Feed(); //喂狗
                 Flash_Write(ARC_ADDR,u2p->data,208);//读取buf存入FLASH   存入固定器件地址的键值上ARC1_ADDR+learn_DeviceName*2080+learn_KeyCode*208
                 learn_cmd=0;//清空开始学习标志?
                 Learn_State=0;

                // SendString(" 空调学习成功!");
              }
              else if(Learn_State==2)//电视学习成功
              {
                   WatchDog_Feed(); //喂狗
                 Send_LenStop(USART2);//停止学习
                  WatchDog_Feed(); //喂狗
                 Flash_Write(URC_ADDR,u2p->data,208);//读取buf存入FLASH
                 learn_cmd=0;//清空开始学习标志?
                 Learn_State=0;

                // SendString(" 电视学习成功!");
              }
             Send_4432ID0 =  MY_ID[0];// my id
             Send_4432ID1 =  MY_ID[1];
             Send_4432ID2 =  MY_ID[2];
             Send_4432ID3 =  MY_ID[3];
             Send_4432DIR = 0x82 ;//方向
             Send_4432CMD = 0x34 ;//反馈指令
             Send_4432LENGTH= 3; //数据长度
             Send_4432DATA0 = send_sig;//学习成功
             Send_4432DATA1 = learn_DeviceName;//
             Send_4432DATA2 = learn_KeyCode;//
             Data_Encrypt(si4432cmd_senddata,18);   //
              WatchDog_Feed(); //喂狗
             sending(send_data,Send_Legth);
              WatchDog_Feed(); //喂狗
               OSTimeDly(8);
                WatchDog_Feed(); //喂狗
             sending(send_data,Send_Legth);
              WatchDog_Feed(); //喂狗
          }
          else if(send_sig==2)
          {
              learn_cmd=0;//清空开始学习标志?
              SendString(" 学习失败!");
             Send_4432ID0 =  MY_ID[0];// my id
             Send_4432ID1 =  MY_ID[1];
             Send_4432ID2 =  MY_ID[2];
             Send_4432ID3 =  MY_ID[3];
             Send_4432DIR = 0x82 ;//方向
             Send_4432CMD = 0x34 ;//反馈指令
             Send_4432LENGTH= 3; //数据长度
             Send_4432DATA0 = send_sig;//学习成功
             Send_4432DATA1 = learn_DeviceName;//
             Send_4432DATA2 = learn_KeyCode;//
             Data_Encrypt(si4432cmd_senddata,18);   //
              WatchDog_Feed(); //喂狗
             sending(send_data,Send_Legth);
              WatchDog_Feed(); //喂狗
               OSTimeDly(5);
                WatchDog_Feed(); //喂狗
             sending(send_data,Send_Legth);
              WatchDog_Feed(); //喂狗
          }
          else if(send_sig==3)
              SendString(" 正在学习!");
          else
          {
               learn_cmd=0;//清空开始学习标志?
               SendString(" 其他错误= ");
             Send_4432ID0 =  MY_ID[0];// my id
             Send_4432ID1 =  MY_ID[1];
             Send_4432ID2 =  MY_ID[2];
             Send_4432ID3 =  MY_ID[3];
             Send_4432DIR = 0x82 ;//方向
             Send_4432CMD = 0x34 ;//反馈指令
             Send_4432LENGTH= 3; //数据长度
             Send_4432DATA0 = send_sig;//学习成功
             Send_4432DATA1 = learn_DeviceName;//
             Send_4432DATA2 = learn_KeyCode;//
             Data_Encrypt(si4432cmd_senddata,18);   //
              WatchDog_Feed(); //喂狗
             sending(send_data,Send_Legth);
              WatchDog_Feed(); //喂狗
               OSTimeDly(5);
                WatchDog_Feed(); //喂狗
             sending(send_data,Send_Legth);
              WatchDog_Feed(); //喂狗
             //  Outint(send_sig);
          }


         //if((send_sig==1)||(send_sig==2))//如果学习成功或失败 清空设备号和 键值 发送学习停止信号
            if (send_sig!=3)
          {
           //Send_LenStop(USART2);
           learn_DeviceName = 0;
           learn_KeyCode = 0;
           learn_cmd=0;//清空开始学习标志位
          }
         send_sig=0;
      }
//else  //接收4432信号send_sig==0

    }
}
Beispiel #22
0
void ENgrab::sendstop()
{
	eDebug("ngrab sendstop requested");
	sendStr = stopxml();
	sending();
}