/* **++ ** ROUTINE: netlib___get_nameservers ** ** FUNCTIONAL DESCRIPTION: ** ** Obtains the list of DNS servers configured for this TCP/IP package. ** ** RETURNS: int ** ** PROTOTYPE: ** ** NETLIB___GET_NAMESERVERS nsq ** ** IMPLICIT INPUTS: None. ** ** IMPLICIT OUTPUTS: None. ** ** COMPLETION CODES: ** ** ** SIDE EFFECTS: None. ** **-- */ int netlib___get_nameservers (QUEUE *nsq) { struct NAMESERVER *ns; struct INADDRDEF a; struct CTX *tmpctx; struct dsc$descriptor dsc, lognamdsc; ITMLST lnmlst[2]; char name[256], lognam[256], *cp, *anchor; unsigned int status, size, maxidx; unsigned short namlen; int index, i, remain; int v5, count; static unsigned int one = 1; tmpctx = 0; count = 0; ITMLST_INIT(lnmlst[0], LNM$_STRING, sizeof(name), name, &namlen); ITMLST_INIT(lnmlst[1], 0, 0, 0, 0); INIT_SDESC(lognamdsc, 0, lognam); for (v5 = 1; (count == 0) && (v5 >= 0); v5--) { for (index = 0; index <= 16; index++) { lognamdsc.dsc$w_length = sprintf(lognam, (v5 == 0 ? "UCX$BIND_SERVER%03d" : "TCPIP$BIND_SERVER%03d"), index); status = sys$trnlnm(0, &nameserver_tabnam, &lognamdsc, 0, lnmlst); if (!OK(status) || namlen == 0) continue; for (anchor = name, remain = namlen; remain > 0; remain -= i+1, anchor = cp+1) { cp = memchr(anchor, ',', remain); if (cp == 0) i = remain; else i = cp - anchor; INIT_SDESC(dsc, i, anchor); if (!OK(netlib_strtoaddr(&dsc, &a))) { if (tmpctx == 0) { if (!OK(netlib_socket(&tmpctx, 0, 0))) continue; } if (!OK(netlib_name_to_address(&tmpctx, 0, &dsc, &a, &one, 0, 0, 0, 0))) continue; } size = sizeof(struct NAMESERVER); status = lib$get_vm(&size, &ns); if (!OK(status)) break; ns->addr = a; queue_insert(ns, nsq->tail); count += 1; } } } if (tmpctx != 0) netlib_close(&tmpctx); return count; } /* netlib___get_nameservers */
struct netemu_sender_udp* netemu_sender_udp_new(netlib_sockaddr* addr, int addr_len) { NETLIB_SOCKET socket; struct netemu_sender_udp* sender; sender = malloc(sizeof(struct netemu_sender_udp)); socket = netlib_socket(NETLIB_AF_INET,NETLIB_SOCK_DGRAM); if (socket == NETLIB_INVALID_SOCKET) { sender->error = netlib_get_last_platform_error(); } sender->addr_len = addr_len; sender->addr = addr; sender->socket = socket; return sender; }
RpcServer::RpcServer(uint16_t port) { printf("rpc server init\n"); int fd = netlib_socket(); if (fd < 0) { printf("netlib_socket error:%d\n",errno); exit(EXIT_FAILURE); } if(netlib_bind(fd, port) < 0) { printf("netlib_bind error:%d\n",errno); exit(EXIT_FAILURE); } if (netlib_listen(fd,5)) { printf("netlib_listen error:%d\n",errno); exit(EXIT_FAILURE); } listen_fd_ = fd; }