00001 00029 #ifndef LL_LLSRV_H 00030 #define LL_LLSRV_H 00031 00032 class LLSRV; 00033 00034 class LLSRVRecord 00035 { 00036 friend class LLSRV; 00037 00038 protected: 00039 U16 mPriority; 00040 U16 mWeight; 00041 std::string mTarget; 00042 U16 mPort; 00043 00044 public: 00045 LLSRVRecord(U16 priority, U16 weight, const std::string& target, 00046 U16 port) : 00047 mPriority(priority), 00048 mWeight(weight), 00049 mTarget(target), 00050 mPort(port) { 00051 } 00052 00053 U16 priority() const { return mPriority; } 00054 U16 weight() const { return mWeight; } 00055 const std::string& target() const { return mTarget; } 00056 U16 port() const { return mPort; } 00057 00058 struct ComparePriorityLowest 00059 { 00060 bool operator()(const LLSRVRecord& lhs, const LLSRVRecord& rhs) 00061 { 00062 return lhs.mPriority < rhs.mPriority; 00063 } 00064 }; 00065 }; 00066 00067 class LLSRV 00068 { 00069 protected: 00070 #ifndef LL_WINDOWS 00071 static std::vector<LLSRVRecord> parseResponse(const unsigned char *response, 00072 int resp_len); 00073 #endif 00074 static std::vector<LLSRVRecord> reorder(std::vector<LLSRVRecord>& recs); 00075 00076 public: 00077 static std::vector<LLSRVRecord> query(const std::string& name); 00078 static std::vector<std::string> rewriteURI(const std::string& uri); 00079 }; 00080 00081 #endif // LL_LLSRV_H