Statistics
| Branch: | Revision:

napa-baselibs / ALTOclient / ALTOclient.h @ 5f3adef4

History | View | Annotate | Download (4.94 KB)

1
#ifndef ALTOCLIENT_H
2
#define ALTOCLIENT_H
3

    
4
/**
5
* @file ALTOclient.h
6
*
7
* @brief Public functions to interface with ALTO client.
8

9
These functions allow the user to set up and handle the communications between ALTO client and ALTO server. Moreover, all needed functionalities to inteface ALTO client with other application modules are provided.
10
*
11
*
12
*/
13

    
14
#include <arpa/inet.h>
15

    
16
/*
17
 * Uncomment the following line to use the local reply.xml file 
18
 * instead of a real ALTO server query.
19
 */
20
/* #define USE_LOCAL_REPLY_XML */
21

    
22

    
23
/**
24
Operators relative preference.
25

26
These defines are the definitions of the RATING criteria.
27
In the PRIMARY rating criteria only ONE option can be choosen
28
For the SECOND rating criteria a mixture of these options is possible 
29
(e.g. 6 means TOP_DIST and MIN_BOUN).
30
*/
31
#define REL_PREF        1
32
/**
33
Topological distance (Number of AS hops).
34
*/
35
#define TOP_DIST        2
36
/**
37
Minimum boundary for latency.
38
*/
39
#define MIN_BOUN        4
40

    
41
/** Current state of asynchronous ALTO server query */
42
#define ALTO_QUERY_READY                0
43
#define ALTO_QUERY_INPROGRESS        1
44

    
45
/**
46
 * This is the struct of one element for the internal interface. Make lists out of it to interact with the client.
47
 */
48
typedef struct alto_guidance_t{
49
        struct in_addr alto_host;
50
        int prefix;
51
        int rating;
52
}ALTO_GUIDANCE_T;
53

    
54

    
55
// external API functions
56

    
57
/**
58
 *         It starts the ALTO client, initialize the internal DB and provide the API
59
 *         for upcoming requests.
60
 */
61
void start_ALTO_client();
62

    
63

    
64
/**
65
 *         It stops the ALTO server and clean-up the internal DB.
66
 */
67
void stop_ALTO_client();
68

    
69
/**
70
 *         This function starts the synchronization of the internal peer list
71
 *  with the ALTO server.
72
 *  This function can be called after every dedicated request to the
73
 *  client or periodically triggered from extern to keep the peer-list
74
 *  up2date.
75
 *
76
 *         @param        rc_host                The host IP from the client to which the Server
77
 *                                                 should do the rating
78
 *         @param        pri_rat                Set the primary rating criteria (only 1,2 & 4
79
 *                                                 allowed)
80
 *         @param        sec_rat                Set the secondary rating criteria (0-7 possible to
81
 *                                                 allow combined secondray rating criteria)
82
 */
83
void do_ALTO_update(struct in_addr rc_host, int pri_rat, int sec_rat);
84

    
85
/**
86
 *         Set the URI for teh ALTO server
87
 *         After calling the function, all upcoming requests are sent to the given
88
 *         URI from this call.
89
 *         Be careful, it is not tested if the ALTO server can be really reached
90
 *         here, so double check before.
91
 *
92
 *         @param        string        The URI of the ALTO server as string
93
 */
94
int set_ALTO_server(char * string);
95

    
96

    
97
/**
98
 *         Geck the actual URI of the ALTO server
99
 *         To assure that the settings for the upcoming ALTOrequests are right, use
100
 *         this function to assure the the actual given ALTO server is the right one.
101
 *         @return        Pointer to a string where the URI of the ALTO server is stored.
102
 */
103
char *get_ALTO_server(void);
104

    
105
/**
106
 *        With this function a given list of hosts in a txt file will be ALTOrated
107
 *        This function will read from a text file all given hosts, transform them into
108
 *        the internal ALTO structure and get the alto rating for them. Afterwards it
109
 *        will write teh ALTO results in a new text file which will be the same name,
110
 *        but with the ending .out.
111
 *
112
 *        ATTENTION: This function is used for functionality tests, it is not recommended
113
 *        to use it in a real ALTOclient implementation.
114
 *
115
 *         @param        rc_host                The host IP from the client to which the Server
116
 *                                                 should do the rating
117
 *         @param        pri_rat                Set the primary rating criteria (only 1,2 & 4
118
 *                                                 allowed)
119
 *         @param        sec_rat                Set the secondary rating criteria (0-7 possible to
120
 *                                                 allow combined secondray rating criteria)
121
 *         @return                                1 = SUCCESS / 0 = ERROR
122
 */
123
int get_ALTO_guidance_for_txt(char * txt, struct in_addr rc_host, int pri_rat, int sec_rat);
124

    
125
/**
126
 *        With this function a given list of hosts in the ALTOstruct (alto_guidance_t) gets
127
 *        ALTO rated.
128
 *        This function will use the given struct, transform it into the internal ALTO structure
129
 *        and get the alto rating for them. Afterwards it will return the struct where the ALTO
130
 *        rating is inserted in the int.rating of this struct.
131
 *
132
 *         @param        list                a pointer to the alto_guidance_t list
133
 *         @param        num                        the number of elements in the list which should be rated
134
 *         @param        rc_host                The host IP from the client to which the Server
135
 *                                                 should do the rating
136
 *         @param        pri_rat                Set the primary rating criteria (only 1,2 & 4
137
 *                                                 allowed)
138
 *         @param        sec_rat                Set the secondary rating criteria (0-7 possible to
139
 *                                                 allow combined secondray rating criteria)
140
 *         @return                                1 = SUCCESS / 0 = ERROR
141
 */
142
int get_ALTO_guidance_for_list(ALTO_GUIDANCE_T * list, int num, struct in_addr rc_host, int pri_rat, int sec_rat);
143

    
144
/**
145
 *        Asynchronous/threaded ALTO query.
146
 *        @see get_ALTO_guidance_for_list
147
 */
148
int ALTO_query_exec(ALTO_GUIDANCE_T * list, int num, struct in_addr rc_host, int pri_rat, int sec_rat);
149

    
150
/**
151
 *        Returns current state of query (asynchronous processing).
152
 *        @return                                ALTO_QUERY_READY / ALTO_QUERY_INPROGRESS
153
 */
154
int ALTO_query_state();
155

    
156
#endif /* ALTOCLIENT_H */