/*-------------------------------------------------------------------------*/ int KnownDADiscoverFromIPC() /* Ask Slpd if it knows about a DA */ /* */ /* Returns: number of *new* DAs found */ /*-------------------------------------------------------------------------*/ { struct sockaddr_in peeraddr; int sockfd; int result = 0; sockfd = NetworkConnectToSlpd(&peeraddr); if(sockfd >= 0) { result = KnownDADiscoveryRqstRply(sockfd, &peeraddr, 0, ""); close(sockfd); } return result; }
/*-------------------------------------------------------------------------*/ SLPError ProcessSrvDeReg(PSLPHandleInfo handle) /*-------------------------------------------------------------------------*/ { struct sockaddr_in peeraddr; int sock = 0; int bufsize = 0; char* buf = 0; char* curpos = 0; SLPError result = 0; /*-------------------------------------------------------------------*/ /* determine the size of the fixed portion of the SRVREG */ /*-------------------------------------------------------------------*/ bufsize += handle->params.dereg.scopelistlen + 2; /* 2 bytes for len field*/ bufsize += handle->params.dereg.urllen + 8; /* 1 byte for reserved */ /* 2 bytes for lifetime */ /* 2 bytes for urllen */ /* 1 byte for authcount */ bufsize += 2; /* 2 bytes for taglistlen*/ /* TODO: Fix this for authentication */ buf = curpos = (char*)malloc(bufsize); if(buf == 0) { result = SLP_MEMORY_ALLOC_FAILED; goto FINISHED; } /*------------------------------------------------------------*/ /* Build a buffer containing the fixed portion of the SRVDEREG*/ /*------------------------------------------------------------*/ /* scope list */ ToUINT16(curpos,handle->params.dereg.scopelistlen); curpos = curpos + 2; memcpy(curpos, handle->params.dereg.scopelist, handle->params.dereg.scopelistlen); curpos = curpos + handle->params.dereg.scopelistlen; /* url-entry reserved */ *curpos = 0; curpos = curpos + 1; /* url-entry lifetime */ ToUINT16(curpos, 0); curpos = curpos + 2; /* url-entry urllen */ ToUINT16(curpos,handle->params.dereg.urllen); curpos = curpos + 2; /* url-entry url */ memcpy(curpos, handle->params.dereg.url, handle->params.dereg.urllen); curpos = curpos + handle->params.dereg.urllen; /* url-entry authcount */ *curpos = 0; curpos = curpos + 1; /* TODO: put in urlentry authentication stuff */ /* tag list */ /* TODO: put in taglist stuff */ ToUINT16(curpos,0); /*---------------------------------------*/ /* Connect to slpd or a DA */ /*---------------------------------------*/ sock = NetworkConnectToSlpd(&peeraddr); if(sock < 0) { sock = NetworkConnectToDA(handle->params.findsrvs.scopelist, handle->params.findsrvs.scopelistlen, &peeraddr); { result = SLP_NETWORK_INIT_FAILED; goto FINISHED; } } result = NetworkRqstRply(sock, &peeraddr, handle->langtag, buf, SLP_FUNCT_SRVDEREG, bufsize, CallbackSrvDeReg, handle); FINISHED: if(buf) free(buf); return result; }