Leaked source code of windows server 2003
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.

70 lines
1.9 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) Microsoft Corporation
  4. //
  5. // SYNOPSIS
  6. //
  7. // Declares the class CPortParser.
  8. //
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef PORTPARSER_H
  11. #define PORTPARSER_H
  12. #pragma once
  13. class CPortParser
  14. {
  15. public:
  16. CPortParser(const wchar_t* portString) throw ();
  17. // Use compiler-generated version.
  18. // ~CPortParser() throw ();
  19. // IP Address in network order to listen to RADIUS requests on. Returns
  20. // S_FALSE if there are no more interfaces.
  21. HRESULT GetIPAddress(DWORD* ipAddress) throw ();
  22. // UDP Port in host order to listen to RADIUS requests on. Returns S_FALSE
  23. // if there are no more ports.
  24. HRESULT GetNextPort(WORD* port) throw ();
  25. static bool IsPortStringValid(const wchar_t* portString) throw ();
  26. static size_t CountPorts(const wchar_t* portString) throw ();
  27. private:
  28. const wchar_t* next;
  29. // Separates an IP address from a port.
  30. static const wchar_t addressPortDelim = L':';
  31. // Separates two ports.
  32. static const wchar_t portDelim = L',';
  33. // Separates two interfaces.
  34. static const wchar_t interfaceDelim = L';';
  35. // Maximum length in characters of a dotted-decimal IP address not counting
  36. // the null-terminator.
  37. static const size_t maxAddrStrLen = 15;
  38. // Allowed values for ports.
  39. static const unsigned long minPortValue = 1;
  40. static const unsigned long maxPortValue = 0xFFFF;
  41. // Not implemented.
  42. CPortParser(const CPortParser&);
  43. CPortParser& operator=(const CPortParser&);
  44. };
  45. inline CPortParser::CPortParser(const wchar_t* portString) throw ()
  46. : next(portString)
  47. {
  48. }
  49. inline bool CPortParser::IsPortStringValid(const wchar_t* portString) throw ()
  50. {
  51. return CountPorts(portString) != 0;
  52. }
  53. #endif // PORTPARSER_H