• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ HAGGLE_DBG函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中HAGGLE_DBG函数的典型用法代码示例。如果您正苦于以下问题:C++ HAGGLE_DBG函数的具体用法?C++ HAGGLE_DBG怎么用?C++ HAGGLE_DBG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了HAGGLE_DBG函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: toupper

void SecurityManager::onConfig(Metadata *m)
{
	const char *param = m->getParameter("security_level");
	
	if (param) {
		char *level = new char[strlen(param) + 1];
		size_t i;
		
		// Convert string to uppercase
		for (i = 0; i < strlen(param); i++) {
			level[i] = toupper(param[i]);
		}
		
		level[i] = '\0';
		
		if (strcmp(level, security_level_names[SECURITY_LEVEL_HIGH]) == 0) {
			securityLevel = SECURITY_LEVEL_HIGH;
			HAGGLE_DBG("Security level set to %s\n", security_level_names[SECURITY_LEVEL_HIGH]);
		} else if (strcmp(level, security_level_names[SECURITY_LEVEL_MEDIUM]) == 0) {
			securityLevel = SECURITY_LEVEL_MEDIUM;
			HAGGLE_DBG("Security level set to %s\n", security_level_names[SECURITY_LEVEL_MEDIUM]);
		} else if (strcmp(level, security_level_names[SECURITY_LEVEL_LOW]) == 0) {
			securityLevel = SECURITY_LEVEL_LOW;
			HAGGLE_DBG("Security level set to %s\n", security_level_names[SECURITY_LEVEL_LOW]);
		} else {
			HAGGLE_ERR("Unrecognized security level '%s'\n", level);
		}
		
		delete [] level;
	}
}
开发者ID:dmonakhov,项目名称:haggle,代码行数:31,代码来源:SecurityManager.cpp


示例2: strtoul

void Forwarder::onConfig(const Metadata& m) 
{
	if (m.getName().compare("Forwarder") != 0)
		return;
	
	const char *param = m.getParameter("max_generated_delegates");
	
	if (param) {
		char *ptr = NULL;
		unsigned long d = strtoul(param, &ptr, 10);
		
		if (ptr && ptr != param && *ptr == '\0') {
			HAGGLE_DBG("%s Setting max_generated_delegates to %lu\n", getName(), d);
			max_generated_delegates = d;
		}
	}
	
	param = m.getParameter("max_generated_targets");
	
	if (param) {
		char *ptr = NULL;
		unsigned long d = strtoul(param, &ptr, 10);
		
		if (ptr && ptr != param && *ptr == '\0') {
			HAGGLE_DBG("%s Setting max_generated_targets to %lu\n", getName(), d);
			max_generated_targets = d;
		}
	}
	
	const Metadata *md = m.getMetadata(getName());
	
	if (md) {
		onForwarderConfig(*md);
	}
}
开发者ID:SRI-CSL,项目名称:ENCODERS,代码行数:35,代码来源:Forwarder.cpp


示例3: HAGGLE_DBG

void ForwarderRank::_onForwarderConfig(const Metadata& m)
{
	if (strcmp(getName(), m.getName().c_str()) != 0)
		return;
	
	HAGGLE_DBG("Prophet forwarder configuration\n");
	
	const char *param = m.getParameter("label");
	if (param) {
		
		myLabel = string(param);
		HAGGLE_DBG("%s: Setting label to %s\n", getName(), myLabel.c_str());
	}
	
	param = m.getParameter("rank");
	if (param)
	{
		char *ptr = NULL;
		RANK_T p = strtol(param,&ptr,10);
		
		if (ptr && ptr != param && *ptr == '\0')
		{
			myRank = p;
			HAGGLE_DBG("%s: Setting rank to %ld\n", getName(), myRank);
		}
	}
	
}
开发者ID:eikoyoneki,项目名称:haggle-cambridge,代码行数:28,代码来源:ForwarderRank.cpp


示例4: HAGGLE_DBG

bool SecurityHelper::run()
{	
	HAGGLE_DBG("SecurityHelper running...\n");
	
	while (!shouldExit()) {
		QueueEvent_t qe;
		SecurityTask *task = NULL;
		
		qe = taskQ.retrieve(&task);
		
		switch (qe) {
		case QUEUE_ELEMENT:
			doTask(task);

			// Delete task here or return it with result in private event?
			//delete task;
			break;
		case QUEUE_WATCH_ABANDONED:
			HAGGLE_DBG("SecurityHelper instructed to exit...\n");
			return false;
		default:
			HAGGLE_ERR("Unknown security task queue return value\n");
		}
	}
	return false;
}
开发者ID:dmonakhov,项目名称:haggle,代码行数:26,代码来源:SecurityManager.cpp


示例5: memset

ProtocolEvent ProtocolRFCOMMClient::connectToPeer()
{
	struct sockaddr_bt peerAddr;
	BluetoothAddress *addr;
	
	if (!peerIface)
		return PROT_EVENT_ERROR;

	addr = peerIface->getAddress<BluetoothAddress>();

	if(!addr)
		return PROT_EVENT_ERROR;

	memset(&peerAddr, 0, sizeof(peerAddr));
	peerAddr.bt_family = AF_BLUETOOTH;

	BDADDR_swap(&peerAddr.bt_bdaddr, mac);
	peerAddr.bt_channel = channel & 0xff;

	HAGGLE_DBG("%s Trying to connect over RFCOMM to [%s] channel=%u\n", 
		   getName(), addr->getStr(), channel);

	ProtocolEvent ret = openConnection((struct sockaddr *) &peerAddr, sizeof(peerAddr));

	if (ret != PROT_EVENT_SUCCESS) {
		HAGGLE_DBG("%s Connection failed to [%s] channel=%u\n", 
			   getName(), addr->getStr(), channel);
		return ret;
	}

	HAGGLE_DBG("%s Connected to [%s] channel=%u\n", 
		   getName(), addr->getStr(), channel);

	return ret;
}
开发者ID:eikoyoneki,项目名称:haggle-label,代码行数:35,代码来源:ProtocolRFCOMM.cpp


示例6: HAGGLE_ERR

bool SecurityHelper::verifyDataObject(DataObjectRef& dObj, CertificateRef& cert) const
{
	RSA *key;
	
	// Cannot verify without signature
	if (!dObj->getSignature()) {
		HAGGLE_ERR("No signature in data object, cannot verify\n");
		return false;
	}	
	writeErrors("(not this): ");
	
	key = cert->getPubKey();

	if (RSA_verify(NID_sha1, dObj->getId(), sizeof(DataObjectId_t), 
		       const_cast<unsigned char *>(dObj->getSignature()), dObj->getSignatureLength(), key) != 1) {
		char *raw;
		size_t len;
		writeErrors("");
		dObj->getRawMetadataAlloc((unsigned char **)&raw, &len);
		if (raw) {
			HAGGLE_DBG("Signature is invalid:\n%s\n", raw);
			free(raw);
		}
		dObj->setSignatureStatus(DataObject::SIGNATURE_INVALID);

		return false;
	}
	
	HAGGLE_DBG("Signature is valid\n");
	dObj->setSignatureStatus(DataObject::SIGNATURE_VALID);

	return true;
}
开发者ID:dmonakhov,项目名称:haggle,代码行数:33,代码来源:SecurityManager.cpp


示例7: HAGGLE_DBG

void ProtocolManager::onNeighborInterfaceDown(Event *e)
{
	InterfaceRef& iface = e->getInterface();
	
	if (!iface)
		return;
	
	HAGGLE_DBG("Neighbor interface [%s] went away, checking for associated protocols\n", iface->getIdentifierStr());

	// Go through the protocol list
	protocol_registry_t::iterator it = protocol_registry.begin();
	
	for (;it != protocol_registry.end(); it++) {
		Protocol *p = (*it).second;
		
		/* 
		 Never bring down our application IPC protocol when
		 application interfaces go down (i.e., applications deregister).
		 */
		if (p->getLocalInterface()->getType() == Interface::TYPE_APPLICATION_PORT) {
			continue;
		}
		// Is the associated with this protocol?
		if (p->isClient() && p->isForInterface(iface)) {
			HAGGLE_DBG("Shutting down protocol %s because neighbor interface [%s] went away\n",
				   p->getName(), iface->getIdentifierStr());
			p->handleInterfaceDown(iface);
		}
	}
}
开发者ID:eikoyoneki,项目名称:haggle-label,代码行数:30,代码来源:ProtocolManager.cpp


示例8: defined

bool 
SocketWrapper::multiplySndBufferSize(int factor)
{
    bool res = false;
#if defined(OS_LINUX) 
    int ret = 0;
    long optval = 0;
    socklen_t optlen = sizeof(optval);

    ret = ::getsockopt(sock, SOL_SOCKET, SO_SNDBUF, &optval, &optlen);

    if (-1 == ret) {
        return res;
    }

    HAGGLE_DBG("Original send buffer set to %ld bytes\n", optval); 

    optval = optval * factor;

    ret = ::setsockopt(sock, SOL_SOCKET, SO_SNDBUF, &optval, optlen);

    if (-1 == ret) {
        HAGGLE_ERR("Could not set send buffer to %ld bytes\n", optval);
    } else {
        HAGGLE_DBG("Send buffer set to %ld bytes\n", optval); 
        res = true;
    }
#endif

	return res;
}
开发者ID:SRI-CSL,项目名称:ENCODERS,代码行数:31,代码来源:SocketWrapper.cpp


示例9: getQueue

ProtocolEvent ProtocolUDPGeneric::waitForEvent(
    DataObjectRef &dObj, 
    Timeval *timeout, 
    bool writeevent)
{
    QueueElement *qe = NULL;
    Queue *q = getQueue();

    if (!q) {
        return PROT_EVENT_ERROR;
    }

    SocketWrapper *sock = getReadEndOfReceiveSocket();

    if (NULL == sock) {
        HAGGLE_ERR("%s Null receive socket\n", getName());
        return PROT_EVENT_ERROR_FATAL;
    }

    HAGGLE_DBG("%s Waiting for queue element or timeout... %s\n", 
	       getName(), timeout->getAsString().c_str());

    QueueEvent_t qev = q->retrieve(&qe, 
		      sock->getSOCKET(), 
		      timeout, 
		      writeevent);

    if (QUEUE_ELEMENT == qev) {
        dObj = qe->getDataObject();
        delete qe;
        return PROT_EVENT_TXQ_NEW_DATAOBJECT;
    }

    if (QUEUE_EMPTY == qev) {
        return PROT_EVENT_TXQ_EMPTY;
    }

    if (QUEUE_WATCH_WRITE == qev) {
        return PROT_EVENT_WRITEABLE;
    }

    if (QUEUE_WATCH_ABANDONED == qev) {
        // SW: this occurs when the protocol has been shutdown via some other
        // mechanism, such as interface down
        HAGGLE_DBG("%s Waiting for event abandoned\n", getName());
        return PROT_EVENT_SHOULD_EXIT;
    }
    
    if (QUEUE_TIMEOUT == qev) {
        HAGGLE_DBG("%s Waiting for event timeout\n", getName());
        return  PROT_EVENT_TIMEOUT;
    }

    if (QUEUE_WATCH_READ == qev) {
        return PROT_EVENT_INCOMING_DATA;
    } 

    HAGGLE_ERR("%s Waiting for event unknown error\n", getName());
    return PROT_EVENT_ERROR;
}
开发者ID:SRI-CSL,项目名称:ENCODERS,代码行数:60,代码来源:ProtocolUDPGeneric.cpp


示例10: id_from_string

void ForwarderRank::_generateDelegatesFor(const DataObjectRef &dObj, const NodeRef &target, const NodeRefList *other_targets)
{
						
	List<Pair<NodeRef, bubble_metric_t> > sorted_delegate_list;
	
	// Figure out which node to look for:
	bubble_node_id_t target_id = id_from_string(target->getIdStr());
	
	LABEL_T targetLabel = rib[target_id].first;
	//RANK_T targetRank = rib[target_id].second;
	
	HAGGLE_DBG("HAGGLE_DBG:_generateDelegatesFor node %d string %s label %s\n", target_id, target->getIdStr(), targetLabel.c_str());


	for (bubble_rib_t::iterator it = rib.begin();it != rib.end(); it++)
	{
		if (it->first != this_node_id && it->first != target_id) {

			NodeRef delegate = kernel->getNodeStore()->retrieve(id_number_to_nodeid[it->first], true);

			if (delegate && !isTarget(delegate, other_targets)) {
				
				LABEL_T &neighborLabel = it->second.first;
				RANK_T &neighborRank = it->second.second;
				
				HAGGLE_DBG("HAGGLE_DBG: _generateDelegatesFor neighborLabel=%s, targetLabel=%s\n", neighborLabel.c_str(), targetLabel.c_str());
				
				if (neighborLabel.compare(targetLabel)==0)
				{
					//NodeRef delegate = Node::create_with_id(Node::TYPE_PEER, id_number_to_nodeid[it->first].c_str(), "Label delegate node");
					sortedNodeListInsert(sorted_delegate_list, delegate, it->second);
					HAGGLE_DBG("HAGGLE_DBG: _generateDelegatesFor Label same: Node '%s' is a good delegate for target '%s' [label=%s, rank=%ld]\n", 
					delegate->getName().c_str(), target->getName().c_str(), neighborLabel.c_str(), neighborRank);
					
				}
			}
		}
	}
	
	// Add up to max_generated_delegates delegates to the result in order of decreasing metric
	if (!sorted_delegate_list.empty()) {
		
		NodeRefList delegates;
		unsigned long num_delegates = max_generated_delegates;
		
		while (num_delegates && sorted_delegate_list.size()) {
			NodeRef delegate = sorted_delegate_list.front().first;
			sorted_delegate_list.pop_front();
			delegates.push_back(delegate);
			num_delegates--;
		}
		kernel->addEvent(new Event(EVENT_TYPE_DELEGATE_NODES, dObj, target, delegates));
		HAGGLE_DBG("HAGGLE_DBG: Forward Generated %lu delegates for target %s\n", delegates.size(), target->getName().c_str());
	} else {
                HAGGLE_DBG("No delegates found for target %s\n", target->getName().c_str());
    }

}
开发者ID:eikoyoneki,项目名称:haggle-cambridge,代码行数:58,代码来源:ForwarderRank.cpp


示例11: defined

ProtocolEvent ProtocolTCPClient::connectToPeer()
{
	socklen_t addrlen;
        char buf[SOCKADDR_SIZE];
        struct sockaddr *peer_addr = (struct sockaddr *)buf;
	unsigned short peerPort;
	SocketAddress *addr = NULL;
	InterfaceRef pIface;
	
        // FIXME: use other port than the default one?
        peerPort = TCP_DEFAULT_PORT;

	if (!peerIface ||
	    !(peerIface->getAddress<IPv4Address>() || 
#if defined(ENABLE_IPv6)
	      peerIface->getAddress<IPv6Address>()
#else
		  0
#endif
		  ))
		return PROT_EVENT_ERROR;

#if defined(ENABLE_IPv6)
	IPv6Address *addr6 = peerIface->getAddress<IPv6Address>();
	if (addr6) {
		addrlen = addr6->fillInSockaddr((struct sockaddr_in6 *)peer_addr, peerPort);
		addr = addr6;
		HAGGLE_DBG("Using IPv6 address %s to connect to peer\n", addr6->getStr());
	}
#endif
	
	if (!addr) {
		// Since the check above passed, we know there has to be an IPv4 or an 
		// IPv6 address associated with the interface, and since there was no IPv6...
		IPv4Address *addr4 = peerIface->getAddress<IPv4Address>();
		if (addr4) {
			addrlen = addr4->fillInSockaddr((struct sockaddr_in *)peer_addr, peerPort);
			addr = addr4;
		}
	}

	if (!addr) {
		HAGGLE_DBG("No IP address to connect to\n");
		return PROT_EVENT_ERROR;
	}
	
	ProtocolEvent ret = openConnection(peer_addr, addrlen);

	if (ret != PROT_EVENT_SUCCESS) {
		HAGGLE_DBG("%s Connection failed to [%s] tcp port=%u\n", 
			getName(), addr->getStr(), peerPort);
		return ret;
	}

	HAGGLE_DBG("%s Connected to [%s] tcp port=%u\n", getName(), addr->getStr(), peerPort);

	return ret;
}
开发者ID:eikoyoneki,项目名称:haggle-label,代码行数:58,代码来源:ProtocolTCP.cpp


示例12: isNonblock

ProtocolEvent
SocketWrapper::openConnection(
    const struct sockaddr *saddr, 
    socklen_t addrlen)
{

    bool wasNonBlock = isNonblock();

    if (INVALID_SOCKET == sock) {
        HAGGLE_ERR("Socket is invalid\n");
        return PROT_EVENT_ERROR;
    }

    if (!saddr) {
        HAGGLE_ERR("Address is invalid\n");
        return PROT_EVENT_ERROR;
    } 

    // block while connecting

    if (nonblock) {
        setNonblock(false);
    }

    bool hasError = false;

    int ret = ::connect(sock, saddr, addrlen);

    if (SOCKET_ERROR == ret) {
        hasError = true;
        HAGGLE_ERR("Problems connecting: %s\n", 
            SocketWrapper::getProtocolErrorStr());
    }

    if (wasNonBlock) {
        setNonblock(true);
    }

    if (!hasError) {
        HAGGLE_DBG("Succesfully connected to socket.\n");
        setConnected(true);
        return PROT_EVENT_SUCCESS;
    } else {
        HAGGLE_DBG("An error occurred connecting: %s\n", 
            getProtocolErrorStr());
    }

    switch (getProtocolError()) {
    case PROT_ERROR_BAD_HANDLE:
    case PROT_ERROR_INVALID_ARGUMENT:
    case PROT_ERROR_NO_MEMORY:
    case PROT_ERROR_NOT_A_SOCKET:
    case PROT_ERROR_NO_STORAGE_SPACE:
        return PROT_EVENT_ERROR_FATAL;
    default: 
        return PROT_EVENT_ERROR;
    }    
}
开发者ID:SRI-CSL,项目名称:ENCODERS,代码行数:58,代码来源:SocketWrapper.cpp


示例13: HAGGLE_DBG

ProtocolEvent ProtocolUDP::sendData(const void *buffer, size_t len, const int flags, size_t *bytes)
{
        char buf[SOCKADDR_SIZE];
        struct sockaddr *sa = (struct sockaddr *)buf;		
	socklen_t addrlen;
	SocketAddress *addr = NULL;
	ssize_t ret;
	
	if (!buffer) {
		HAGGLE_DBG("%s Send buffer is NULL\n", getName());
		return PROT_EVENT_ERROR;
	}
	
	if (!peerIface) {
		HAGGLE_DBG("%s Send interface invalid\n", getName());
		*bytes = 0;
		return PROT_EVENT_ERROR;
	}
	
#if defined(ENABLE_IPv6)
	addr = peerIface->getAddress<IPv6Address>();
#endif

	if (!addr)
		addr = peerIface->getAddress<IPv4Address>();
	
	if (!addr) {
		HAGGLE_DBG("%s Send interface has no valid address\n", getName());
		*bytes = 0;
		return PROT_EVENT_ERROR;
	}
	
	if (addr->getTransport()->getType() != Transport::TYPE_UDP) {
		HAGGLE_DBG("%s Send interface [%s] has no valid UDP port\n", getName(),
			   peerIface->getIdentifierStr());
		*bytes = 0;
		return PROT_EVENT_ERROR;
	}
	
	addrlen = addr->fillInSockaddr(sa);
	
	HAGGLE_DBG("%s sending to address %s:%d\n", 
		   getName(), addr->getURI(), 
		   reinterpret_cast<const TransportUDP *>(addr->getTransport())->getPort());
	
	ret = sendTo(buffer, len, flags, sa, addrlen);

	if (ret < 0)
		return PROT_EVENT_ERROR;
	else if (ret == 0)
		return PROT_EVENT_PEER_CLOSED;

	*bytes = ret;

	return PROT_EVENT_SUCCESS;	
}
开发者ID:SRI-CSL,项目名称:ENCODERS,代码行数:56,代码来源:ProtocolUDP.cpp


示例14: switch

/*
 This function is called after the SecurityHelper thread finished a task.
 The Security manager may act on any of the results if it wishes.
 
 */
void SecurityManager::onSecurityTaskComplete(Event *e)
{
	if (!e || !e->hasData())
		return;
        
        SecurityTask *task = static_cast<SecurityTask *>(e->getData());

        switch (task->type) {
                case SECURITY_TASK_GENERATE_CERTIFICATE:
                        HAGGLE_DBG("Certificate generated!\n");
			if (task->cert->getSubject() == kernel->getThisNode()->getIdStr()) {
				HAGGLE_DBG("Certificate is my own\n");
				
				/* Save our private key and our certificate */
				privKey = task->privKey;
				myCert = task->cert;
				signalIsReadyForStartup();
			}
			break;
                case SECURITY_TASK_VERIFY_CERTIFICATE:
			/*
			if (task->cert && task->cert->isVerified()) {
				printCertificates();
			}
			*/ 
			break;
		case SECURITY_TASK_VERIFY_DATAOBJECT:
			/*
			  NOTE:
			  Here is the possibility to generate a EVENT_TYPE_DATAOBJECT_VERIFIED
			  event even if the data object had a bad signature. In that case, the
			  Data manager will remove the data object from the bloomfilter so that
			  it can be received again (hopefully with a valid signature the next time).
			  However, this means that also the data object with the bad signature
			  can be received once more, in worst case in a never ending circle.

			  Perhaps the best solution is to hash both the data object ID and the 
			  signature (if available) into a node's bloomfilter?
			*/
			if (task->dObj->hasValidSignature()) {
				HAGGLE_DBG("DataObject %s has a valid signature!\n", 
					   task->dObj->getIdStr());
				kernel->addEvent(new Event(EVENT_TYPE_DATAOBJECT_VERIFIED, 
							   task->dObj));
			} else {
				HAGGLE_DBG("DataObject %s has an unverifiable signature!\n", 
					   task->dObj->getIdStr());
			}
			break;
                case SECURITY_TASK_SIGN_DATAOBJECT:
                        break;
        }
	delete task;
}
开发者ID:dmonakhov,项目名称:haggle,代码行数:59,代码来源:SecurityManager.cpp


示例15: signalIsReadyForStartup

void SecurityManager::onRepositoryData(Event *e)
{
	RepositoryEntryRef re;
	
	if (!e->getData()) {
		signalIsReadyForStartup();
		return;
	}
	
	HAGGLE_DBG("Got repository callback\n");
	
	DataStoreQueryResult *qr = static_cast < DataStoreQueryResult * >(e->getData());
	
	if (qr->countRepositoryEntries() == 0) {
		HAGGLE_DBG("No repository entries, generating new certificate and keypair\n");
		helper->addTask(new SecurityTask(SECURITY_TASK_GENERATE_CERTIFICATE));
		
		// Delay signalling that we are ready for startup until we get the 
		// task result indicating our certificate is ready.
		delete qr;
		return;
	}
	
	while ((re = qr->detachFirstRepositoryEntry())) {
		if (strcmp(re->getKey(), "privkey") == 0) {
			
			// Just to make sure
			if (privKey)
				RSA_free(privKey);
			
			privKey = stringToRSAKey(re->getValueStr(), KEY_TYPE_PRIVATE);
			
			HAGGLE_DBG("Read my own private key from repository\n");
		} else {
			CertificateRef c = Certificate::fromPEM(re->getValueStr());
			
			if (c) {
				if (c->getSubject() == kernel->getThisNode()->getIdStr())
					myCert = c;
				
				storeCertificate(c);
				HAGGLE_DBG("Read certificate for subject '%s' from repository\n", 
					   c->getSubject().c_str());
			} else {
				HAGGLE_ERR("Could not read certificate from repository\n");
			}
		}
	}
	
	delete qr;
	
	signalIsReadyForStartup();
}
开发者ID:dmonakhov,项目名称:haggle,代码行数:53,代码来源:SecurityManager.cpp


示例16: bluetoothDiscoveryCompleteCallback

void bluetoothDiscoveryCompleteCallback(void *userRefCon, IOBluetoothDeviceInquiryRef inquiryRef, IOReturn error, Boolean aborted)
{
	ConnectivityBluetooth *conn = (ConnectivityBluetooth *) userRefCon;

	if (aborted) {
		HAGGLE_DBG("%s: inquiry aborted\n", conn->getName());
	} else {
		HAGGLE_DBG("%s: inquiry completed\n", conn->getName());
	}
	
	conn->isInquiring = false;
}
开发者ID:SRI-CSL,项目名称:ENCODERS,代码行数:12,代码来源:ConnectivityBluetoothMacOSX.cpp


示例17: HAGGLE_ERR

bool ProtocolRFCOMM::initbase()
{
	struct sockaddr_bt localAddr;

        if (isConnected()) {
                // Nothing to do
                return true;
        }

	if (!openSocket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM, isServer())) {
		HAGGLE_ERR("Could not create RFCOMM socket\n");
                return false;
        }

	memset(&localAddr, 0, sizeof(struct sockaddr_bt));
	localAddr.bt_family = AF_BLUETOOTH;
	localAddr.bt_channel = channel & 0xff;

#ifndef OS_WINDOWS
	if (localIface) {
		BluetoothAddress *addr = localIface->getAddress<BluetoothAddress>();
		if (addr) {
                        // Binding RFCOMM sockets to a hardware address does not
                        // seem to work in Windows
			BDADDR_swap(&localAddr.bt_bdaddr, addr->getRaw());
                }
	}
#endif

	if (isServer()) {
		localAddr.bt_channel = channel & 0xff;
   
             	/* If this is a server we bing to a specific channel to listen on */
                if (!bind((struct sockaddr *)&localAddr, sizeof(localAddr))) {
                        closeSocket();
#ifdef OS_WINDOWS
                        HAGGLE_ERR("Bind failed for local address WSA error=%s\n", StrError(WSAGetLastError()));
#endif
                        
                        HAGGLE_ERR("Could not bind local address for RFCOMM socket\n");
                        
                        return false;
                }

                HAGGLE_DBG("Bound RFCOMM server to channel=%d\n", channel);
   
	} else {
		HAGGLE_DBG("Created RFCOMM client on channel=%d\n", channel);
	}

	return true;
}
开发者ID:eikoyoneki,项目名称:haggle,代码行数:52,代码来源:ProtocolRFCOMM.cpp


示例18: HAGGLE_DBG

ProtocolEvent ProtocolRFCOMMServer::acceptClient()
{
	SOCKET clientSock;
	struct sockaddr_bt clientAddr;
	socklen_t len;
	char btMac[BT_ALEN];

	HAGGLE_DBG("In RFCOMMServer receive\n");

	if (getMode() != PROT_MODE_LISTENING) {
		HAGGLE_DBG("Error: RFCOMMServer not in LISTEN mode\n");
		return PROT_EVENT_ERROR;
	}

	len = sizeof(clientAddr);

	clientSock = accept((struct sockaddr *) &clientAddr, &len);

	if (clientSock == INVALID_SOCKET)
		return PROT_EVENT_ERROR;

	/* Save address and channel information in client handle. */
	ProtocolManager *pm = static_cast<ProtocolManager *>(getManager());

	if (!pm) {
		HAGGLE_DBG("Error: No manager for protocol!\n");
		CLOSE_SOCKET(clientSock);
		return PROT_EVENT_ERROR;
	}

	BDADDR_swap(btMac, &clientAddr.bt_bdaddr);

	ProtocolRFCOMMClient *p = new ProtocolRFCOMMReceiver(clientSock, btMac,
							   (unsigned short) clientAddr.bt_channel,
							   this->getLocalInterface(), pm);

	if (!p || !p->init()) {
		HAGGLE_ERR("Could not create new RFCOMM receiver\n");
		CLOSE_SOCKET(clientSock);
                
                if (p)
                        delete p;

		return PROT_EVENT_ERROR;
	}

	p->registerWithManager();

	HAGGLE_DBG("Accepted client with socket %d, starting client thread\n", clientSock);

	return p->startTxRx();
}
开发者ID:eikoyoneki,项目名称:haggle,代码行数:52,代码来源:ProtocolRFCOMM.cpp


示例19: HAGGLE_DBG

bool 
SocketWrapper::setListen(int backlog)
{
    if (isListening()) {
        HAGGLE_DBG("Already listening.");
        return false;
    }
    
    if (SOCKET_ERROR == listen(sock, backlog)) {
        HAGGLE_DBG("Could not set listen.");
        return false;
    }
	
    setListening(true);
    return true;
}
开发者ID:SRI-CSL,项目名称:ENCODERS,代码行数:16,代码来源:SocketWrapper.cpp


示例20: HAGGLE_DBG

void DebugManager::publicEvent(Event *e)
{
	if (!e)
		return;
	
	HAGGLE_DBG("%s data=%s\n", e->getName(), e->hasData() ? "Yes" : "No");
}
开发者ID:eikoyoneki,项目名称:haggle-label,代码行数:7,代码来源:DebugManager.cpp



注:本文中的HAGGLE_DBG函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ HAGGLE_ERR函数代码示例发布时间:2022-05-30
下一篇:
C++ H5_FAILED函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap