This does NOT delete the msg.
| 349 | |
| 350 | // This does NOT delete the msg. |
| 351 | void SipInterface::siWrite(const struct sockaddr_in* dest, SipMessage *msg) |
| 352 | { |
| 353 | string msgstr = msg->smGenerate(); |
| 354 | string firstLine = msgstr.substr(0,msgstr.find('\n')); |
| 355 | |
| 356 | // For debug purposes dump the address assuming IPv4. |
| 357 | //uint32_t addr = ntohl(dest->sin_addr.s_addr); |
| 358 | char netbuf[102]; |
| 359 | inet_ntop(AF_INET,&(dest->sin_addr),netbuf,100); |
| 360 | uint16_t port = ntohs(dest->sin_port); |
| 361 | |
| 362 | //WATCHF("SIP write %s:%d %s to=%s\n",netbuf,port,firstLine.c_str(),msg->msmToValue.c_str()); |
| 363 | WATCH("SIP write "<<msg->smGetPrecis()); |
| 364 | LOG(INFO) << "write " << firstLine; |
| 365 | LOG(DEBUG) << "write " <<netbuf <<":"<<port <<" " <<msgstr; |
| 366 | |
| 367 | if (random()%100 < gConfig.getNum("Test.SIP.SimulatedPacketLoss")) { |
| 368 | LOG(NOTICE) << "simulating dropped outbound SIP packet: " << firstLine; |
| 369 | return; |
| 370 | } |
| 371 | |
| 372 | // We think that large packets will probably be fragmented automatically and the underlying |
| 373 | // send or sendto will return an error if the packet is too long. So dont check the length here. |
| 374 | //int size = msgstr.size(); |
| 375 | //if (size > MAX_UDP_LENGTH) { |
| 376 | // LOG(NOTICE) << "SIP Message length exceeds UDP limit, dropped; message:"<<msgstr; |
| 377 | //} |
| 378 | |
| 379 | mSocketLock.lock(); |
| 380 | mSIPSocket->send((const struct sockaddr*)dest,msgstr.c_str(),msgstr.size()); |
| 381 | mSocketLock.unlock(); |
| 382 | } |
| 383 | |
| 384 | // If this message is handled by an existing TransactonUser return true; |
| 385 | // We only create client TUs [Transaction Users] so only replies are sent to TUs. |
no test coverage detected