00001 /** @file 00002 00003 A brief file description 00004 00005 @section license License 00006 00007 Licensed to the Apache Software Foundation (ASF) under one 00008 or more contributor license agreements. See the NOTICE file 00009 distributed with this work for additional information 00010 regarding copyright ownership. The ASF licenses this file 00011 to you under the Apache License, Version 2.0 (the 00012 "License"); you may not use this file except in compliance 00013 with the License. You may obtain a copy of the License at 00014 00015 http://www.apache.org/licenses/LICENSE-2.0 00016 00017 Unless required by applicable law or agreed to in writing, software 00018 distributed under the License is distributed on an "AS IS" BASIS, 00019 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00020 See the License for the specific language governing permissions and 00021 limitations under the License. 00022 */ 00023 00024 #ifndef _SRV_h_ 00025 #define _SRV_h_ 00026 00027 #include "libts.h" 00028 #include "I_HostDBProcessor.h" 00029 00030 struct HostDBInfo; 00031 00032 #define HOST_DB_MAX_ROUND_ROBIN_INFO 16 00033 #define RAND_INV_RANGE(r) ((int) ((RAND_MAX + 1) / (r))) 00034 00035 struct SRV 00036 { 00037 unsigned int weight; 00038 unsigned int port; 00039 unsigned int priority; 00040 unsigned int ttl; 00041 unsigned int host_len; 00042 unsigned int key; 00043 char host[MAXDNAME]; 00044 00045 SRV():weight(0), port(0), priority(0), ttl(0), host_len(0), key(0) 00046 { 00047 host[0] = '\0'; 00048 } 00049 }; 00050 00051 inline bool 00052 operator<(const SRV &left, const SRV &right) 00053 { 00054 // lower priorities first, then the key 00055 return (left.priority == right.priority) ? (left.key < right.key) : (left.priority < right.priority); 00056 } 00057 00058 00059 struct SRVHosts 00060 { 00061 unsigned srv_host_count; 00062 unsigned srv_hosts_length; 00063 SRV hosts[HOST_DB_MAX_ROUND_ROBIN_INFO]; 00064 00065 ~SRVHosts() 00066 { 00067 } 00068 00069 SRVHosts():srv_host_count(0), srv_hosts_length(0) 00070 { 00071 } 00072 }; 00073 00074 #endif