本文整理汇总了C++中PDU类的典型用法代码示例。如果您正苦于以下问题:C++ PDU类的具体用法?C++ PDU怎么用?C++ PDU使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PDU类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sendPdu
void SmppClient::sendPdu(PDU &pdu)
{
checkConnection();
boost::optional<boost::system::error_code> ioResult;
boost::optional<boost::system::error_code> timerResult;
if (verbose) {
*log << pdu;
}
deadline_timer timer(getIoService());
timer.expires_from_now(boost::posix_time::milliseconds(socketWriteTimeout));
timer.async_wait(boost::bind(&SmppClient::handleTimeout, this, &timerResult, _1));
async_write(*socket, buffer(pdu.getOctets().get(), pdu.getSize()),
boost::bind(&SmppClient::writeHandler, this, &ioResult, _1));
socketExecute();
if (ioResult) {
timer.cancel();
} else if (timerResult) {
socket->cancel();
}
socketExecute();
}
示例2: onDebug
void DecodeCallBack::onDebug ( const PDU& pdu)
{
const uint8 *buf = pdu.data ();
size_t len = pdu.size ();
#ifdef THREADING_WORKAROUND
CriticalSection::Lock cs_lock (cs);
#endif
#if 0
ASSERT (len != 0);
if (buf[len - 1] == NUL)
{
printlf ("debug");
printlf (" \"");
while (len--)
{
printChar (*buf++);
}
printlf ("\"\n");
}
else
{
printlf ("debug");
for (; len != 0; --len)
{
printlf (" 0x%02x", *buf++);
}
printlf ("\n");
}
#else
decodeDebug(buf, len);
#endif
}
示例3: checkState
SMS SmppClient::readSms()
{
// see if we're bound correct.
checkState(BOUND_RX);
// if there are any messages in the queue pop the first usable one off and return it
if (!pdu_queue.empty()) return parseSms();
// fill queue until we get a DELIVER_SM command
try {
bool b = false;
while (!b) {
PDU pdu = readPdu(true);
if (pdu.getCommandId() == ENQUIRE_LINK) {
PDU resp = PDU(ENQUIRE_LINK_RESP, 0, pdu.getSequenceNo());
sendPdu(resp);
continue;
}
if (pdu.null) {
break;
}
if (!pdu.null) pdu_queue.push_back(pdu); // save pdu for reading later
b = pdu.getCommandId() == DELIVER_SM;
}
} catch (std::exception &e) {
throw smpp::TransportException(e.what());
}
return parseSms();
}
示例4: eventPdu
void DecodeCallBack::onHCIEvent(const PDU &pdu)
{
HCIEventPDU eventPdu(pdu);
BadPDUReason failCode;
uint32 length = HCIPDUFactory::decomposeEventPDU(pdu, 0, failCode);
if ( length == 0 )
{
printBadPDU (failCode, pdu.data(), pdu.size() );
return;
}
if (eventPdu.get_event_code() == HCI_EV_NUMBER_COMPLETED_PKTS)
{
aclEngine->nocp(pdu);
}
else if (eventPdu.get_event_code() == HCI_EV_COMMAND_COMPLETE)
{
HCICommandCompletePDU cc_pdu(pdu);
if (cc_pdu.get_op_code() == HCI_READ_BUFFER_SIZE)
{
HCI_READ_BUFFER_SIZE_RET_T_PDU rbs_pdu(cc_pdu);
aclEngine->setBufferSizes(rbs_pdu);
scoEngine->setBufferSizes(rbs_pdu);
}
}
if (length != 0)
{
uint32 *pa = new uint32 [length];
if (pa == 0)
{
return;
}
pa [0] = length;
length = HCIPDUFactory::decomposeEventPDU(pdu, pa, failCode);
#ifdef THREADING_WORKAROUND
CriticalSection::Lock cs_lock (cs);
#endif
#if 0
unsigned i;
ASSERT (pa[0] >= 2);
ASSERT (ec == pa[1]);
printlf ("App: received event, code 0x%02x, pa[] =", ec);
for (i = 2; i < pa[0]; ++i)
{
printlf (" 0x%lx", (ul) pa[i]);
}
printlf (" [%u args]\n", pa[0] - 2);
#else
decodeEvt (pa);
#endif
}
}
示例5: while
// blocks until response is read
PDU SmppClient::readPduResponse(const uint32_t &sequence, const uint32_t &commandId)
{
uint32_t response = GENERIC_NACK | commandId;
list<PDU>::iterator it = pdu_queue.begin();
while (it != pdu_queue.end()) {
PDU pdu = (*it);
if (pdu.getSequenceNo() == sequence && pdu.getCommandId() == response) {
it = pdu_queue.erase(it);
return pdu;
}
it++;
}
while (true) {
PDU pdu = readPdu(true);
if (!pdu.null) {
if ((pdu.getSequenceNo() == sequence
&& (pdu.getCommandId() == response || pdu.getCommandId() == GENERIC_NACK))
|| (pdu.getSequenceNo() == 0 && pdu.getCommandId() == GENERIC_NACK)) return pdu;
}
}
PDU pdu;
return pdu;
}
示例6: checkConnection
void SmppClient::unbind()
{
checkConnection();
PDU pdu(smpp::UNBIND, 0, nextSequenceNumber());
PDU resp = sendCommand(pdu);
uint32_t pduStatus = resp.getCommandStatus();
if (pduStatus != smpp::ESME_ROK) throw smpp::SmppException(smpp::getEsmeStatus(pduStatus));
state = OPEN;
}
示例7: open_l3_socket
void PacketSender::send_l3(PDU &pdu, struct sockaddr* link_addr, uint32_t len_addr, SocketType type) {
open_l3_socket(type);
int sock = _sockets[type];
PDU::serialization_type buffer = pdu.serialize();
if(sendto(sock, (const char*)&buffer[0], buffer.size(), 0, link_addr, len_addr) == -1)
throw socket_write_error(make_error_string());
}
示例8: while
// Send a PDU that requires HCI tunnelling for manufacturer extensions
void BlueCoreTransportImplementation::sendTunnel ( const PDU& aPacket )
{
if (tunnel)
{
uint8 data[HCI_TUNNEL_HEADER_SIZE+HCI_TUNNEL_MAX_PAYLOAD];
size_t offset = 0;
while ( offset < aPacket.size() )
{
size_t lLength = aPacket.size() - offset;
while (1)
{
// Calculate the payload length and descriptor
uint8 descriptor = aPacket.channel();
if (offset == 0)
descriptor |= HCI_TUNNEL_FIRST;
if (HCI_TUNNEL_MAX_PAYLOAD < lLength)
lLength = HCI_TUNNEL_MAX_PAYLOAD;
if (offset + lLength == aPacket.size())
descriptor |= HCI_TUNNEL_LAST;
// Build and send the HCI command for this fragment
data[0] = uint8(HCI_TUNNEL_COMMAND & 0xff);
data[1] = uint8(HCI_TUNNEL_COMMAND >> 8);
data[2] = uint8(lLength + 1);
data[3] = descriptor;
memcpy(data + HCI_TUNNEL_HEADER_SIZE, aPacket.data() + offset, lLength);
PDU p(PDU::hciCommand, data, HCI_TUNNEL_HEADER_SIZE + lLength);
if (pdu_size_forbidden(p))
{
// can't send pdu of this length. try one size smaller.
--lLength;
}
else
{
sendpdu(p);
break;
}
}
offset += lLength;
}
}
}
示例9: generic_response_handler
bool PacketSenderGeneric::generic_response_handler(PDU& rpdu)
{
if (sent_pdu->matches_response_generic(rpdu))
{
response_pdu = rpdu.clone();
return false;
}
return true;
}
示例10: aclpdu
void DecodeCallBack::onHCIACLData(const PDU &pdu)
{
HCIACLPDU aclpdu(pdu);
#if 0
uint16 ch = pdu.get_handle ();
bool pb = pdu.get_pbf () == HCIACLPDU::start;
BROADCAST_TYPE bf = conv (pdu.get_bct ());
const uint8 *data = pdu.get_dataPtr ();
uint16 length = pdu.get_length ();
unsigned u;
ASSERT (bf <= 2);
printlf ("App: received data [%s%s], data =", pb ? "start" : "contin", bf == 0 ? "" : bf == 1 ? "; active broadcast" : "; piconet broadcast");
for (u = 0; u < length; ++u)
{
printlf (" %02x", data[u]);
}
printlf (" [len %lu]\n", (ul) length);
pdd->sendHCIData (ch, pb, bf, data, length);
#else
{
btcli_enter_critical_section();
if (fastpipeEngineIsConnected(aclpdu.get_handle()))
{
fastpipeEngineReceive(aclpdu);
btcli_leave_critical_section();
}
else
{
// Leave critical section before entering aclEngine.
// AclEngine isn't very hygeinic about its threads, so printlf
// (which needs locking) is called from various different threads.
// CriticalSection::Lock on Linux can't be obtained recursively, so
// just drop the lock now to make life easier.
btcli_leave_critical_section();
aclEngine->receive(aclpdu);
}
}
#endif
}
示例11: ignoresFlowControl
static bool ignoresFlowControl ( const PDU& pdu )
{
switch ( pdu.channel() )
{
case PDU::hciCommand :
{
HCICommandPDU cmd ( pdu.data() , pdu.size() );
switch ( cmd.get_op_code() )
{
case HCI_ACCEPT_CONNECTION_REQ:
case HCI_REJECT_CONNECTION_REQ:
case HCI_LINK_KEY_REQ_REPLY:
case HCI_LINK_KEY_REQ_NEG_REPLY:
case HCI_PIN_CODE_REQ_REPLY:
case HCI_PIN_CODE_REQ_NEG_REPLY:
case HCI_ACCEPT_SYNCHRONOUS_CONN_REQ:
case HCI_REJECT_SYNCHRONOUS_CONN_REQ:
case HCI_IO_CAPABILITY_RESPONSE:
case HCI_USER_CONFIRMATION_REQUEST_REPLY:
case HCI_USER_CONFIRMATION_REQUEST_NEG_REPLY:
case HCI_USER_PASSKEY_REQUEST_REPLY:
case HCI_USER_PASSKEY_REQUEST_NEG_REPLY:
case HCI_REMOTE_OOB_DATA_REQUEST_REPLY:
case HCI_REMOTE_OOB_DATA_REQUEST_NEG_REPLY:
case HCI_IO_CAPABILITY_REQUEST_NEG_REPLY:
case HCI_RESET:
case HCI_HOST_NUM_COMPLETED_PACKETS:
case HCI_ULP_LONG_TERM_KEY_REQUESTED_REPLY:
case HCI_ULP_LONG_TERM_KEY_REQUESTED_NEGATIVE_REPLY:
case 0xFC00:
return true;
break;
default:
break;
}
break;
}
default:
break;
};
return false;
}
示例12: onLMPdebug
void DecodeCallBack::onLMPdebug(const PDU &pdu)
{
const uint8 *buf = pdu.data ();
size_t len = pdu.size ();
#ifdef THREADING_WORKAROUND
CriticalSection::Lock cs_lock (cs);
#endif
#if 0
ASSERT (len != 0);
printlf ("lmp");
for (; len != 0; --len)
{
printlf (" 0x%02x", *buf++);
}
printlf ("\n");
#else
decodeLMPdebug (buf, len, NULL);
#endif
}
示例13: printBadPDU
void DecodeCallBack::onHQRequest(const PDU &pdu)
{
BadPDUReason failCode;
uint32 length = HCIPDUFactory::decomposeHQ_PDU (pdu, 0, failCode);
if (length == 0)
{
printBadPDU (failCode, pdu.data(), pdu.size() );
}
else
{
uint32 *pa = new uint32 [length];
if (pa == 0)
{
return;
}
pa [0] = length;
length = HCIPDUFactory::decomposeHQ_PDU(pdu, pa, failCode);
#ifdef THREADING_WORKAROUND
CriticalSection::Lock cs_lock (cs);
#endif
#if 0
size_t i;
ASSERT (pa[0] >= 4);
printlf ("App: received hq indication; cmd 0x%lx with seqno 0x%lx, status %lu, pa[] =", (ul) pa[1], (ul) pa[2], (ul) pa[3]);
for (i = 4; i < pa[0]; ++i)
{
printlf (" 0x%lx", (ul) pa[i]);
}
printlf (" [%u args]\n", pa[0] - 4);
#else
decodeHQ (pa);
#endif
}
}
示例14: get_ether_socket
void PacketSender::send_l2(PDU &pdu, struct sockaddr* link_addr,
uint32_t len_addr, const NetworkInterface &iface)
{
int sock = get_ether_socket(iface);
PDU::serialization_type buffer = pdu.serialize();
if(!buffer.empty()) {
#if defined(BSD) || defined(__FreeBSD_kernel__)
if(::write(sock, &buffer[0], buffer.size()) == -1)
#else
if(::sendto(sock, &buffer[0], buffer.size(), 0, link_addr, len_addr) == -1)
#endif
throw socket_write_error(make_error_string());
}
}
示例15: getRawString
bool InfoWriter::callback(PDU& pdu) {
QString info = "", src_addr = "", dst_addr = "";
QString detailInfo;
QString rawInfo = getRawString(&pdu);
bool foundOurPDUs = false;
if (EthernetII *eth = pdu.find_pdu<EthernetII>()) {
info = "EthernetII";
detailInfo += getEthernetIIString(eth) + "\r\n";
src_addr = QString::fromStdString(eth->src_addr().to_string());
dst_addr = QString::fromStdString(eth->dst_addr().to_string());
}
if (IPv6 *ipv6 = pdu.find_pdu<IPv6>()) {
info = "IPv6";
detailInfo += getIpv6String(ipv6) + "\r\n";
src_addr = QString::fromStdString(ipv6->src_addr().to_string());
dst_addr = QString::fromStdString(ipv6->dst_addr().to_string());
}
if (IP *ip = pdu.find_pdu<IP>()) {
info = "IP";
detailInfo += getIpString(ip) + "\r\n";
src_addr = QString::fromStdString(ip->src_addr().to_string());
dst_addr = QString::fromStdString(ip->dst_addr().to_string());
}
if (ICMP *icmp = pdu.find_pdu<ICMP>()) {
info = "ICMP";
detailInfo += getIcmpString(icmp) + "\r\n";
foundOurPDUs = true;
} else if (UDP *udp = pdu.find_pdu<UDP>()) {
info = "UDP";
detailInfo += getUdpString(udp) + "\r\n";
foundOurPDUs = true;
} else if (TCP *tcp = pdu.find_pdu<TCP>()) {
info = "TCP";
detailInfo += getTcpString(tcp) + "\r\n";
foundOurPDUs = true;
}
if (foundOurPDUs) {
if (RawPDU *rawpdu = pdu.find_pdu<RawPDU>())
detailInfo += getData(rawpdu);
pduVector->push_back(StringPacket(rawInfo,detailInfo));
int length = pdu.size();
QStringList row;
row << src_addr << dst_addr << info << QString::number(length);
emit addRow(row);
}
return true;
}