Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
1.8 KiB

  1. #include <winsock2.h>
  2. #ifndef _SSDPNETWORK_
  3. #define _SSDPNETWORK_
  4. #define SSDP_NETWORK_SIGNATURE 0x1602
  5. #define INET_NTOA(a) inet_ntoa(*(struct in_addr*)&(a))
  6. typedef enum _NetworkState {
  7. NETWORK_INIT,
  8. NETWORK_CLEANUP
  9. } NetworkState, *PNetworkState;
  10. typedef struct _SSDPNetwork {
  11. LIST_ENTRY linkage;
  12. INT Type;
  13. SOCKADDR_IN IpAddress;
  14. NetworkState state;
  15. SOCKET socket;
  16. DWORD dwIndex;
  17. LONG cRef;
  18. } SSDPNetwork, *PSSDPNetwork;
  19. typedef VOID (*RECEIVE_CALLBACK_FUNC)(CHAR *szBuffer, SOCKADDR_IN *RemoteSocket);
  20. // network related functions.
  21. VOID InitializeListNetwork();
  22. INT GetNetworks();
  23. HRESULT GetIpAddress(CHAR * szName, SOCKADDR_IN *psinLocal);
  24. VOID ResetNetworkList(HWND hwnd);
  25. VOID GetNetworkLock();
  26. VOID FreeNetworkLock();
  27. VOID CleanupListNetwork(BOOL fReset);
  28. BOOL FIsSocketValid(SOCKET s);
  29. BOOL FReferenceSocket(SOCKET s);
  30. VOID UnreferenceSocket(SOCKET s);
  31. VOID SendOnAllNetworks(CHAR *szAlive, SOCKADDR_IN *RemoteAddress);
  32. VOID SocketSendWithReplacement(CHAR *szBytes, SOCKET * pSockLocal,
  33. SOCKADDR_IN *pSockRemote);
  34. INT ListenOnAllNetworks(HWND hWnd);
  35. // socket related functions
  36. INT SocketInit();
  37. VOID SocketFinish();
  38. // open the socket and bind
  39. BOOL SocketOpen(SOCKET *psocketToOpen, PSOCKADDR_IN IpAddress, DWORD dwMulticastInterfaceIndex, BOOL fRecvMcast);
  40. // close the socket
  41. BOOL SocketClose(SOCKET socketToClose);
  42. BOOL SocketReceive(SOCKET socket, CHAR **pszData, DWORD *pcbBuffer,
  43. SOCKADDR_IN *fromSocket, BOOL fMCast, BOOL *pfGotMCast);
  44. VOID SocketSend(const CHAR *szBytes, SOCKET socket, SOCKADDR_IN *RemoteAddress);
  45. VOID SocketSendErrorResponse(SOCKET socket, DWORD dwErr);
  46. LPSTR GetSourceAddress(SOCKADDR_IN fromSocket);
  47. #ifdef NEVER
  48. VOID SuspendListening();
  49. #endif // NEVER
  50. #endif // SSDPNETWORK