📄 libslp_handle.c
字号:
#endif G_OpenSLPHandleCount ++; *phSLP = (SLPHandle)handle; FINISHED: if(result) { *phSLP = 0; } return result;}/*=========================================================================*/void SLPAPI SLPClose(SLPHandle hSLP) /* *//* Frees all resources associated with the handle. If the handle was *//* invalid, the function returns silently. Any outstanding synchronous *//* or asynchronous operations are cancelled so their callback functions *//* will not be called any further. *//* *//* SLPHandle A SLPHandle handle returned from a call to SLPOpen(). *//*=========================================================================*/{ PSLPHandleInfo handle; /*------------------------------*/ /* check for invalid parameters */ /*------------------------------*/ if(hSLP == 0 || *(unsigned int*)hSLP != SLP_HANDLE_SIG) { return; } handle = (PSLPHandleInfo)hSLP; if(handle->isAsync) { /* TODO: stop the usage of this handle (kill threads, etc) */ } if(handle->langtag) { xfree(handle->langtag); } if(handle->dasock >=0) {#ifdef _WIN32 closesocket(handle->dasock);#else close(handle->dasock);#endif } if(handle->dascope) { xfree(handle->dascope); } if(handle->sasock >=0) {#ifdef _WIN32 closesocket(handle->sasock);#else close(handle->sasock);#endif } if(handle->sascope) { xfree(handle->sascope); }#ifdef ENABLE_SLPv2_SECURITY if(handle->hspi) SLPSpiClose(handle->hspi);#endif handle->sig = 0; /* If they use the handle again, it won't be valid */ xfree(hSLP); G_OpenSLPHandleCount --; #if DEBUG /* Free additional resources if this is the last handle open */ if(G_OpenSLPHandleCount <= 0) { G_OpenSLPHandleCount = 0; SLPPropertyFreeAll(); KnownDAFreeAll(); xmalloc_deinit(); }#endif}#ifndef MI_NOT_SUPPORTED/*=========================================================================*/SLPError SLPAssociateIFList( SLPHandle hSLP, const char* McastIFList)/* *//* Associates a list of interfaces McastIFList on which multicast needs to *//* be done with a particular SLPHandle hSLP. McastIFList is a comma *//* separated list of host interface IP addresses. *//* *//* hSLP The SLPHandle with which the interface list is to *//* be associated with. *//* *//* McastIFList A comma separated list of host interface IP *//* addresses on which multicast needs to be done. *//* *//* Returns SLPError code *//*=========================================================================*/{ PSLPHandleInfo handle; /*------------------------------*/ /* check for invalid parameters */ /*------------------------------*/ if(hSLP == 0 || *(unsigned int*)hSLP != SLP_HANDLE_SIG || McastIFList == 0 || *McastIFList == 0) /* interface list can't be empty string */ { return SLP_PARAMETER_BAD; } handle = (PSLPHandleInfo)hSLP;#ifdef DEBUG fprintf(stderr, "SLPAssociateIFList(): McastIFList = %s\n", McastIFList);#endif handle->McastIFList = McastIFList; return SLP_OK;}#endif /* MI_NOT_SUPPORTED */#ifndef UNICAST_NOT_SUPPORTED/*=========================================================================*/SLPError SLPAssociateIP( SLPHandle hSLP, const char* unicast_ip)/* *//* Associates an IP address unicast_ip with a particular SLPHandle hSLP. *//* unicast_ip is the IP address of the SA/DA from which service is *//* requested. *//* *//* hSLP The SLPHandle with which the unicast_ip address is *//* to be associated with. *//* *//* unicast_ip IP address of the SA/DA from which service is *//* requested. *//* *//* Returns SLPError code *//*=========================================================================*/{ PSLPHandleInfo handle; /*------------------------------*/ /* check for invalid parameters */ /*------------------------------*/ if(hSLP == 0 || *(unsigned int*)hSLP != SLP_HANDLE_SIG || unicast_ip == 0 || *unicast_ip == 0) /* unicast address not specified */ { return SLP_PARAMETER_BAD; } handle = (PSLPHandleInfo)hSLP;#ifdef DEBUG fprintf(stderr, "SLPAssociateIP(): unicast_ip = %s\n", unicast_ip);#endif handle->dounicast = 1; handle->unicastaddr.sin_family = AF_INET; if (inet_aton(unicast_ip, ((struct in_addr *)(&handle->unicastaddr.sin_addr))) == 0 ) { return SLP_PARAMETER_BAD; } handle->unicastaddr.sin_port = htons(SLP_RESERVED_PORT); return SLP_OK;}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -