本文整理汇总了C++中NETDEBUG函数的典型用法代码示例。如果您正苦于以下问题:C++ NETDEBUG函数的具体用法?C++ NETDEBUG怎么用?C++ NETDEBUG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NETDEBUG函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: CmdWorker
int
CmdWorker(q_msg *m)
{
char *c = &(m->cmd[0]);
char s[MAX_MSGLEN];
int rc;
NETDEBUG(MEXECD, NETLOG_DEBUG2, ("To: %x From: %x Flag: %x Cmd: %s\n",
m->self_id, m->peer_id, m->flag, c));
if (ISSET_BIT(m, OUT_BIT)) {
rc = System(c, s, MAX_CMDLEN);
}
else {
rc = System(c, NULL, 0);
s[0]='\0';
}
NETDEBUG(MEXECD, NETLOG_DEBUG2, ("Cmd returned %d\n", rc));
if (ISSET_BIT(m, REQ_BIT)) {
strncpy(c, s, MAX_CMDLEN);
SendResp(m, rc);
}
free(m);
return(rc);
}
开发者ID:AkankshaGovil,项目名称:Automation,代码行数:29,代码来源:main.c
示例2: HelloProtMainLoop
static void
HelloProtMainLoop()
{
int numus = 0;
int rval = 0;
exec_hsm_event(HSM_EVENT_START);
for(;;) {
numus = NetFdsSetupPoll(&hcp->nfs, MRSD, NETLOG_DEBUG4);
NETDEBUG(MRSD, NETLOG_DEBUG4, ("%d ready for Hello Protocol\n", numus));
rval = poll(hcp->nfs.pollA, numus, -1);
switch (rval) {
case -1:
NETDEBUG(MRSD, NETLOG_DEBUG4, ("poll failure - %d", errno));
break;
case 0:
NETDEBUG(MRSD, NETLOG_DEBUG4, ("poll timeout"));
break;
default:
NETDEBUG(MRSD, NETLOG_DEBUG4, ("poll process"));
rval = NetFdsProcessPoll(&hcp->nfs, MRSD, NETLOG_DEBUG4);
if (rval < 0) {
NETERROR(MRSD, ("found a bad fd %d, deactivating it!\n", -rval));
NetFdsDeactivate(&hcp->nfs, -rval, FD_RW);
}
break;
}
}
}
开发者ID:AkankshaGovil,项目名称:Automation,代码行数:30,代码来源:hello.c
示例3: err_doit
static void
err_doit(int errnoflag, int level, const char *fmt, va_list ap)
{
int errno_save, n;
char buf[MAXLINE];
errno_save = errno; /* value caller might want printed */
#ifdef HAVE_VSNPRINTF
vsnprintf(buf, sizeof(buf), fmt, ap); /* this is safe */
#else
vsprintf(buf, fmt, ap); /* this is not safe */
#endif
n = strlen(buf);
if (errnoflag)
snprintf(buf+n, sizeof(buf)-n, ": %s", strerror(errno_save));
strcat(buf, "\n");
if (daemon_proc) {
// syslog(level, buf);
if (level == LOG_ERR) {
NETERROR(MRSD, ("%s", buf));
}
if (level == LOG_INFO) {
NETDEBUG(MRSD, NETLOG_DEBUG2, ("%s", buf));
}
if (level == LOG_WARNING) {
NETDEBUG(MRSD, NETLOG_DEBUG3, ("%s", buf));
}
} else {
fflush(stdout); /* in case stdout and stderr are the same */
fputs(buf, stderr);
fflush(stderr);
}
return;
}
开发者ID:AkankshaGovil,项目名称:Automation,代码行数:35,代码来源:error.c
示例4: allocPort
/**
* returns the next available port in the range, returns -1 if no ports are available
* if reqport is not 0 then assigns the requested port
*/
int
allocPort (PortAlloc *ptr, int reqport, dirxn d)
{
int port = -1;
int count, index = 0;
NETDEBUG(MFCE, NETLOG_DEBUG4, ("allocPort: request to allocate port %d for %s\n", reqport, dirxn2str(d)));
if (!ptr->inited)
{
NETERROR(MFCE, ("allocPort: trying to allocate port before initialization\n"));
return -1;
}
if (reqport) {
index = (reqport - ptr->low)/2;
}
else {
if ((index = nextIndex(ptr)) == -1) {
NETERROR(MFCE, ("allocPort: cannot allocate port, no more ports available in the range %d - %d\n", ptr->low, ptr->high));
return -1; // no ports available in the port range
}
incrementIndex(ptr); /* get ready for the next request */
reqport = (index * 2) + ptr->low;
}
/* set the current port as used */
if (d == rx) {
if (GET_RX_CNT(ptr->bArray[index])) {
/* port is already allocated */
NETERROR(MFCE, ("allocPort: can not allocate rx port on %d.\n", reqport));
return port;
}
SET_RX_CNT(ptr->bArray[index], 1);
}
else if (d == tx) {
count = GET_TX_CNT(ptr->bArray[index]);
count++;
if (count <= MAX_TX_CNT) {
SET_TX_CNT(ptr->bArray[index], count);
}
else {
NETERROR(MFCE, ("allocPort: can not allocate %d tx ports on %d.\n", count, reqport));
return port; // no ports available in the port range
}
}
else {
NETERROR(MFCE, ("allocPort: can not allocate port for %s(%d).\n", dirxn2str(d), d));
return port;
}
port = reqport;
NETDEBUG(MFCE, NETLOG_DEBUG4, ("allocPort: allocating port %d for %s\n", port, dirxn2str(d)));
return port;
}
开发者ID:AkankshaGovil,项目名称:Automation,代码行数:62,代码来源:portalloc.c
示例5: HelloHandleTimers
void *
HelloHandleTimers(void *arg)
{
int rval = 0;
static struct timeval tout;
int msec = -1;
int numus = 0;
timerThread = pthread_self();
#ifndef NETOID_LINUX
ThreadSetRT();
#endif // NETOID_LINUX
// ThreadSetPriority(timerThread, SCHED_RR, 50);
for (;;) {
rval = HelloSetupTimeout(&tout);
if (rval < 0) {
NETDEBUG(MRSD, NETLOG_DEBUG4, ("Timer already timed out\n"));
HelloProcessTimeout();
continue;
}
msec = INFTIM;
if (rval) { /* Find the timeout */
HelloAdjustTimeout(&tout, &msec);
}
numus = NetFdsSetupPoll(&Hellotimerfds, MRSD, NETLOG_DEBUG4);
NETDEBUG(MRSD, NETLOG_DEBUG4, ("%d ready for Hello Protocol\n", numus));
rval = poll(Hellotimerfds.pollA, numus, msec);
switch (rval) {
case -1:
NETDEBUG(MSEL, NETLOG_DEBUG4, ("poll failure %d", errno));
break;
case 0:
NETDEBUG(MSEL, NETLOG_DEBUG4, ("poll timeout"));
break;
default:
//fprintf(stdout, "Timer activated: %d\n", rval);
NETDEBUG(MSEL, NETLOG_DEBUG4, ("poll process"));
rval = NetFdsProcessPoll(&Hellotimerfds, MSEL, NETLOG_DEBUG4);
if (rval < 0) {
NETERROR(MSEL,
("Found a bad fd %d, deactivating it!\n", -rval));
NetFdsDeactivate(&Hellotimerfds, -rval, FD_RW);
}
break;
}
}
return 0;
}
开发者ID:AkankshaGovil,项目名称:Automation,代码行数:56,代码来源:hello.c
示例6: System
int
System(const char *cmdstr, char *buf, int buflen)
{
int status;
int rval = -128;
#ifdef USE_SYS_POPEN
int cmdfd;
int nbytes;
if ( (cmdfd = sys_popen(cmdstr, 1)) >= 0) {
if (buf) {
if ((nbytes = read(cmdfd, buf, buflen-1)) >=0) {
*(buf+nbytes) = '\0'; // terminate the string
NETDEBUG(MEXECD, NETLOG_DEBUG4, ("Cmd Output: %s", buf));
}
else {
NETERROR(MEXECD, ("read: %s, for output of - %s\n", strerror(errno),
cmdstr));
status = 1;
}
}
status = sys_pclose(cmdfd);
}
else {
NETERROR(MEXECD, ("sys_popen: failed for cmd %s, error: %s\n", cmdstr,
strerror(errno)));
status = 1;
}
#else
status = system(cmdstr);
#endif
if (WIFEXITED(status)) {
NETDEBUG(MEXECD, NETLOG_DEBUG3, ("normal termination, exit status = %d\n",
WEXITSTATUS(status)));
rval = (WEXITSTATUS(status)) - ( ((WEXITSTATUS(status)) & 0x80) ? 0x100 : 0 );
}
else if (WIFSIGNALED(status)) {
NETDEBUG(MEXECD, NETLOG_DEBUG3, ("abnormal termination, signal number = %d%s\n",
WTERMSIG(status), WCOREDUMP(status) ? " (core file generated)" : ""));
rval = -128;
}
else if (WIFSTOPPED(status)) {
NETDEBUG(MEXECD, NETLOG_DEBUG3, ("child stopped. signal number = %d\n",
WSTOPSIG(status)));
rval = -128;
}
return(rval);
}
开发者ID:AkankshaGovil,项目名称:Automation,代码行数:51,代码来源:main.c
示例7: SipRegProcessEventWorker
/* UA Event processor code */
int
SipRegProcessEventWorker(SipEventHandle *evHandle)
{
char fn[] = "SipRegProcessEventWorker():";
SipRegSMEntry *smEntry = NULL;
CallHandle *callHandle = NULL;
SipAppMsgHandle *appMsgHandle = NULL;
int state = SipReg_sIdle;
appMsgHandle = SipEventAppHandle(evHandle);
/* change state */
SipRegChangeState(evHandle, appMsgHandle, &state);
smEntry = &SipRegSM[state][evHandle->event];
if (smEntry == NULL)
{
NETERROR(MSIP, ("%s No State Machine Entry found\n", fn));
SipFreeEventHandle(evHandle);
goto _release_locks;
}
/* Call the action routine */
if (smEntry->action)
{
if ((smEntry->action)(evHandle) < 0)
{
/* Action routine failed */
NETDEBUG(MSIP, NETLOG_DEBUG1,
("%s Action routine failed\n", fn));
goto _error;
}
}
else
{
// No action routine ?? Event must be freed
SipFreeEventHandle(evHandle);
}
return 0;
_release_locks:
_error:
NETDEBUG(MSIP, NETLOG_DEBUG1, ("%s Returning Error\n", fn));
return -1;
}
开发者ID:AkankshaGovil,项目名称:Automation,代码行数:50,代码来源:regevp.c
示例8: frag_kmalloc
static struct ipq *ip_create(struct sk_buff *skb, struct iphdr *iph, struct device *dev)
{
struct ipq *qp;
int ihlen;
qp = (struct ipq *) frag_kmalloc(sizeof(struct ipq), GFP_ATOMIC);
if (qp == NULL)
{
NETDEBUG(printk("IP: create: no memory left !\n"));
return(NULL);
}
memset(qp, 0, sizeof(struct ipq));
/*
* Allocate memory for the IP header (plus 8 octets for ICMP).
*/
ihlen = iph->ihl * 4;
qp->iph = (struct iphdr *) frag_kmalloc(64 + 8, GFP_ATOMIC);
if (qp->iph == NULL)
{
NETDEBUG(printk("IP: create: no memory left !\n"));
frag_kfree_s(qp, sizeof(struct ipq));
return(NULL);
}
memcpy(qp->iph, iph, ihlen + 8);
qp->len = 0;
qp->ihlen = ihlen;
qp->fragments = NULL;
qp->dev = dev;
/* Start a timer for this entry. */
qp->timer.expires = jiffies + IP_FRAG_TIME; /* about 30 seconds */
qp->timer.data = (unsigned long) qp; /* pointer to queue */
qp->timer.function = ip_expire; /* expire function */
add_timer(&qp->timer);
/* Add this entry to the queue. */
qp->prev = NULL;
cli();
qp->next = ipqueue;
if (qp->next != NULL)
qp->next->prev = qp;
ipqueue = qp;
sti();
return(qp);
}
开发者ID:shattered,项目名称:linux-m68k,代码行数:48,代码来源:ip_fragment.c
示例9: RunHelloProtocol
int
RunHelloProtocol(int argc, char **argv)
{
// ThreadSetUniprocessorMode();
NETDEBUG(MRSD, NETLOG_DEBUG1, ("starting hello protocol ... \n"));
libavl_init(1);
timerLibInit();
// hcp_lock = LockAlloc();
// LockInit(hcp_lock, 0); /* Not sharing with other processes */
hcpInit();
timerInit(&hcp->Mtimer, 128, 0);
NetFdsInit(&Hellotimerfds);
IpcInit();
ThreadLaunch(HelloHandleTimers, NULL, 1);
pthread_mutex_lock(&(hellocv.mutex));
hellocv.value = 1;
pthread_cond_signal(&(hellocv.cond));
pthread_mutex_unlock(&(hellocv.mutex));
/* Main Loop */
HelloProtMainLoop();
return(0);
}
开发者ID:AkankshaGovil,项目名称:Automation,代码行数:32,代码来源:hello.c
示例10: LeaderChanged
int
LeaderChanged(void)
{
host_rec *hitem;
IPADDRESS prev_ldr, cur_ldr, ldr;
struct in_addr lead;
char buf[INET_ADDRSTRLEN];
hitem = listGetFirstItem(hcp->hrecs);
if (hitem == NULL) {
/* We should never come here */
NETERROR(MRSD, ("Fatal: Can not find self host record. Exiting... \n"));
kill(getpid(), SIGTERM);
}
prev_ldr = hitem->primary;
cur_ldr = UpdateSelfRec();
ldr = cur_ldr;
memcpy(&lead, &ldr, sizeof(ldr));
if ( prev_ldr != cur_ldr ) {
NETDEBUG(MRSD, NETLOG_DEBUG1, ("Leader changed to %s\n", inet_ntop( AF_INET, &lead, buf, INET_ADDRSTRLEN)));
NETINFOMSG(MRSD, ("Leader changed to %s based on priority calculations\n", inet_ntop( AF_INET, &lead, buf, INET_ADDRSTRLEN)));
hcp->printflag = 1;
publish_host_table();
return(1);
}
else
return(0);
}
开发者ID:AkankshaGovil,项目名称:Automation,代码行数:32,代码来源:hello.c
示例11: hsm_init
int
hsm_init(void)
{
struct itimerval hellotmr, selftmr;
char fn[] = "hsm_init";
NETDEBUG(MRSD, NETLOG_DEBUG2, ("%s: called \n", fn));
/* DOWN State */
hcp->nsm_list = listInit();
/* Add an interval timer which wakes up and sends a hello message */
memset(&hellotmr, 0, sizeof(hellotmr));
hellotmr.it_interval.tv_sec = HELLO_INTERVAL;
hcp->hellotid = timerAddToList(&hcp->Mtimer, &hellotmr, 0, \
PSOS_TIMER_REL, "HelloTimer", SendHello, NULL);
/* Add a timer which makes the host master if there is no response seen */
memset(&selftmr, 0, sizeof(selftmr));
selftmr.it_value.tv_sec = HELLO_INTERVAL*DEAD_FACTOR;
hcp->selftid = timerAddToList(&hcp->Mtimer, &selftmr, 0, \
PSOS_TIMER_REL, "SelfTimer", (TimerFn)HostIsLeader, NULL);
return(1);
}
开发者ID:AkankshaGovil,项目名称:Automation,代码行数:25,代码来源:hello.c
示例12: get_msg
Uint32 get_msg(t_client *client)
{
int result;
static char *data = 0;
if (!data) // can't be dealloced, so using malloc system
if (!(data = (char*)malloc(sizeof(*data) * NET_MSS)))
{
fprintf(stderr, "Not enough memory\n");
exit(43);
}
result = my_recv(client->sock, data, NET_MSS);
if (result <= 0)
{
if (SDLNet_GetError() && strlen(SDLNet_GetError()))
{
NETDEBUG(SDLNet_GetError());
}
client->state = (unsigned long)STATE_FAIL_RECV;
fprintf(stderr, "loss state :%s, %d, %d\n",
strerror(errno), result, (int)data);
// met dans list deadclient, avec un etat 'fail_recv'
// (essaie donc d'ecrire qd meme sur la socket)
// ou la liste de commandes est trop importante..
return (0);
}
if (cut_trame_in_msg(client, data, result))
return (1);
return (0);
}
开发者ID:BackupTheBerlios,项目名称:doomstools-svn,代码行数:31,代码来源:recv.c
示例13: NotifyHelloProt
int
NotifyHelloProt(void *data)
{
char fn[] = "NotifyHelloProt():";
TimerNotifyCBData *tcbdata = (TimerNotifyCBData *)data;
if (tcbdata->wnotify != tcbdata->rnotify) {
// already notification in queue
NETDEBUG(MRSD, NETLOG_DEBUG4, ("%s Already Notified r=%x w=%x\n",
fn, tcbdata->rnotify, tcbdata->wnotify));
return 0;
}
if (write(tcbdata->notifyPipe[NOTIFY_WRITE]," ",1) < 0) {
// Check the error
if (errno == EAGAIN) {
NETERROR(MRSD, ("Blocking error in notification\n"));
}
}
else {
tcbdata->wnotify ++;
}
return(0);
}
开发者ID:AkankshaGovil,项目名称:Automation,代码行数:25,代码来源:hello.c
示例14: frag_kmalloc
/* Create a new fragment entry. */
static struct ipfrag *ip_frag_create(int offset, int end,
struct sk_buff *skb, unsigned char *ptr)
{
struct ipfrag *fp;
fp = (struct ipfrag *) frag_kmalloc(sizeof(struct ipfrag), GFP_ATOMIC);
if (fp == NULL)
goto out_nomem;
/* Fill in the structure. */
fp->offset = offset;
fp->end = end;
fp->len = end - offset;
fp->skb = skb;
fp->ptr = ptr;
fp->next = fp->prev = NULL;
/* Charge for the SKB as well. */
atomic_add(skb->truesize, &ip_frag_mem);
return(fp);
out_nomem:
NETDEBUG(printk(KERN_ERR "IP: frag_create: no memory left !\n"));
return(NULL);
}
开发者ID:GNUHurdTR,项目名称:hurd,代码行数:27,代码来源:ip_fragment.c
示例15: nsm_kill
int
nsm_kill(nbr_info *nbrp)
{
host_rec *nbr_rec;
List tmp;
char fn[] = "nsm_kill";
struct in_addr nbr_ip_addr;
char buf[INET_ADDRSTRLEN];
if (nbrp == NULL) {
return(1);
}
NETDEBUG(MRSD, NETLOG_DEBUG2, ("%s: called \n", fn));
nbr_rec = (host_rec *)listGetFirstItem(nbrp->records);
if ((tmp = SearchListforMatch(hcp->hrecs, (void *)nbr_rec, \
match_rec_nbr)) == NULL) {
NETDEBUG(MRSD, NETLOG_DEBUG1, ("host does not contain record for neigbour which died\n"));
}
else {
nbr_ip_addr.s_addr = nbr_rec->host;
NETINFOMSG(MRSD, ("Neighbour %s died \n",
inet_ntop( AF_INET, &nbr_ip_addr, buf, INET_ADDRSTRLEN) ));
listDeleteItem(hcp->hrecs, tmp->item);
}
hcp->printflag = 1; /* Print list is true */
publish_host_table();
Free(nbrp->sa);
Free(nbrp->curpkt);
listDestroy(nbrp->records);
listDeleteItem(hcp->nsm_list, nbrp);
Free(nbrp);
if (LeaderChanged())
exec_hsm_event(HSM_EVENT_NBRCHNG);
if (CheckNSMStates() && LeaderAgreed()) {
/* A kludgy way to give system some time before we call init */
msleep(500);
exec_hsm_event(HSM_EVENT_FULLCONN);
}
return(1);
}
开发者ID:AkankshaGovil,项目名称:Automation,代码行数:47,代码来源:hello.c
示例16: hsm_ignore
int
hsm_ignore(void)
{
char fn[] = "hsm_ignore";
NETDEBUG(MRSD, NETLOG_DEBUG3, ("%s: called \n", fn));
return(1);
}
开发者ID:AkankshaGovil,项目名称:Automation,代码行数:8,代码来源:hello.c
示例17: hsm_negt
int
hsm_negt(void)
{
char fn[] = "hsm_negt";
NETDEBUG(MRSD, NETLOG_DEBUG2, ("%s: called \n", fn));
hcp->reg->cb_kill(hcp->reg->kill_arg, (void *)hcp->role);
return(1);
}
开发者ID:AkankshaGovil,项目名称:Automation,代码行数:9,代码来源:hello.c
示例18: HelloRegCb
int
HelloRegCb(AppCB *appcb)
{
memcpy(hcp->reg, appcb, sizeof(AppCB));
NETDEBUG(MRSD, NETLOG_DEBUG3, ("Application in thread %d registered callback with hello protocol\n", pthread_self()));
return(0);
}
开发者ID:AkankshaGovil,项目名称:Automation,代码行数:9,代码来源:hello.c
示例19: hsm_kill
int
hsm_kill(void)
{
char fn[] = "hsm_kill";
NETDEBUG(MRSD, NETLOG_DEBUG2, ("%s: called \n", fn));
HelloDeleteLocks();
return(1);
}
开发者ID:AkankshaGovil,项目名称:Automation,代码行数:9,代码来源:hello.c
示例20: publish_host_table
int
publish_host_table(void)
{
List list = hcp->hrecs;
host_rec *item, *hitem;
char cmd[RS_LINELEN];
int len, flag;
int rval;
NETDEBUG(MRSD, NETLOG_DEBUG2, ("publish_host_table called - printflag = %d\n", hcp->printflag));
if (!(hcp->printflag))
return(0);
snprintf(cmd, RS_LINELEN, "%s rsd clear", RS_CLI_CMD_STR);
// rval = ExecuteCliCommand(cmd);
// hcp->printflag = rval;
rval = System(cmd);
hcp->printflag = rval;
NETDEBUG(MRSD, NETLOG_DEBUG2, ("executed - %s, rval =%d\n", cmd, rval));
for (item = listGetFirstItem(list), hitem = item; item; \
item = listGetNextItem(list, item)) {
flag = (memcmp(&(hitem->primary), &(item->host), sizeof(IPADDRESS))==0);
len = 0;
//len += snprintf(cmd, RS_LINELEN, "%s rsd add ", RS_CLI_CMD_STR);
//len += snprintf(cmd, RS_LINELEN, "%d", ntohs(item->port));
len += snprintf(cmd+len, RS_LINELEN-len, "%s rsd add ", RS_CLI_CMD_STR);
len += snprintf(cmd+len, RS_LINELEN-len, "%d", (atoi(rs_port)));
len += snprintf(cmd+len, RS_LINELEN-len, " ");
FormatIpAddress(ntohl(item->host), cmd+len);
strcat(cmd+len, flag?" master":" slave");
// rval = ExecuteCliCommand(cmd);
// hcp->printflag = rval;
rval = System(cmd);
hcp->printflag = rval;
NETDEBUG(MRSD, NETLOG_DEBUG2, ("executed - %s, rval = %d\n", cmd, rval));
}
/* We should check the status of all the system() and return an
appropriate status */
return(0);
}
开发者ID:AkankshaGovil,项目名称:Automation,代码行数:44,代码来源:hello.c
注:本文中的NETDEBUG函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论