解释一下 void exitFunc(void) { syslog (LOG_PID,"Daemon terminated\n"); } int create_br(int itfnum, int payload) { int err; if(lastsock<0) { lastsock = socket(PF_ATMPVC, SOCK_DGRAM, ATM_AAL5); } if (lastsock<0) { syslog(LOG_ERR, "socket creation failed: %s",strerror(errno)); } else { /* create the device with ioctl: */ if( itfnum>=0 && itfnum<1234567890){ struct atm_newif_br2684 ni; ni.backend_num = ATM_BACKEND_BR2684; ni.media = BR2684_MEDIA_ETHERNET; if (payload == 0) ni.media |= BR2684_FLAG_ROUTED; ni.mtu = 1500; sprintf(ni.ifname, "%s%d", intf_name, itfnum); err=ioctl (lastsock, ATM_NEWBACKENDIF, &ni); if (err == 0) syslog(LOG_INFO, "Interface \"%s\" created sucessfully\n",ni.ifname); else syslog(LOG_INFO, "Interface \"%s\" could not be created, reason: %s\n", ni.ifname, strerror(errno)); lastitf=itfnum; /* even if we didn't create, because existed, assign_vcc will want to know it! */ } else { syslog(LOG_ERR,"err: strange interface number %d", itfnum ); } } return 0; }
时间: 2024-04-03 22:36:35 浏览: 69
这段代码主要是创建一个基于ATM协议的虚拟网络接口,并将其绑定到一个现有的ATM连接上。具体来说,它使用socket函数创建一个ATM socket,然后使用ioctl函数创建一个虚拟网络接口。该函数的参数包括接口号、负载类型、MTU等信息。如果创建成功,函数会输出一条日志信息;否则,它会输出一条错误信息。最后,该函数返回0表示成功创建了虚拟网络接口。
阅读全文