Statistics
| Branch: | Revision:

napa-baselibs / include / ALTOclient.h @ 04f4dc42

History | View | Annotate | Download (5.01 KB)

1
#ifndef ALTOCLIENT_H
2
#define ALTOCLIENT_H
3

    
4
#ifdef __cplusplus
5
extern "C" {
6
#endif
7

    
8

    
9

    
10
/**
11
* @file ALTOclient.h
12
*
13
* @brief Public functions to interface with ALTO client.
14

15
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.
16
*
17
*
18
*/
19

    
20
#include <arpa/inet.h>
21

    
22
/*
23
 * Uncomment the following line to use the local reply.xml file 
24
 * instead of a real ALTO server query.
25
 */
26
/* #define USE_LOCAL_REPLY_XML */
27

    
28

    
29
/**
30
Operators relative preference.
31

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

    
47
/** Current state of asynchronous ALTO server query */
48
#define ALTO_QUERY_READY                0
49
#define ALTO_QUERY_INPROGRESS        1
50

    
51
/**
52
 * This is the struct of one element for the internal interface. Make lists out of it to interact with the client.
53
 */
54
typedef struct alto_guidance_t{
55
        struct in_addr alto_host;
56
        int prefix;
57
        int rating;
58
}ALTO_GUIDANCE_T;
59

    
60

    
61
// external API functions
62

    
63
/**
64
 *         It starts the ALTO client, initialize the internal DB and provide the API
65
 *         for upcoming requests.
66
 */
67
void start_ALTO_client();
68

    
69

    
70
/**
71
 *         It stops the ALTO server and clean-up the internal DB.
72
 */
73
void stop_ALTO_client();
74

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

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

    
102

    
103
/**
104
 *         Geck the actual URI of the ALTO server
105
 *         To assure that the settings for the upcoming ALTOrequests are right, use
106
 *         this function to assure the the actual given ALTO server is the right one.
107
 *         @return        Pointer to a string where the URI of the ALTO server is stored.
108
 */
109
char *get_ALTO_server(void);
110

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

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

    
150
/**
151
 *        Asynchronous/threaded ALTO query.
152
 *        @see get_ALTO_guidance_for_list
153
 */
154
int ALTO_query_exec(ALTO_GUIDANCE_T * list, int num, struct in_addr rc_host, int pri_rat, int sec_rat);
155

    
156
/**
157
 *        Returns current state of query (asynchronous processing).
158
 *        @return                                ALTO_QUERY_READY / ALTO_QUERY_INPROGRESS
159
 */
160
int ALTO_query_state();
161

    
162
#ifdef __cplusplus
163
}
164
#endif
165

    
166
#endif /* ALTOCLIENT_H */