Line data Source code
1 : /*
2 : Copyright (c) 2007, Adobe Systems, Incorporated
3 : Copyright (c) 2013, Mozilla
4 :
5 : All rights reserved.
6 :
7 : Redistribution and use in source and binary forms, with or without
8 : modification, are permitted provided that the following conditions are
9 : met:
10 :
11 : * Redistributions of source code must retain the above copyright
12 : notice, this list of conditions and the following disclaimer.
13 :
14 : * Redistributions in binary form must reproduce the above copyright
15 : notice, this list of conditions and the following disclaimer in the
16 : documentation and/or other materials provided with the distribution.
17 :
18 : * Neither the name of Adobe Systems, Network Resonance, Mozilla nor
19 : the names of its contributors may be used to endorse or promote
20 : products derived from this software without specific prior written
21 : permission.
22 :
23 : THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 : "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 : LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 : A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 : OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 : SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 : LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 : DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 : THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 : (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 : OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 : */
35 :
36 : #include "nr_api.h"
37 : #include "nr_interface_prioritizer.h"
38 : #include "transport_addr.h"
39 :
40 0 : int nr_interface_prioritizer_create_int(void *obj,
41 : nr_interface_prioritizer_vtbl *vtbl,nr_interface_prioritizer **ifpp)
42 : {
43 : int _status;
44 0 : nr_interface_prioritizer *ifp=0;
45 :
46 0 : if(!(ifp=RCALLOC(sizeof(nr_interface_prioritizer))))
47 0 : ABORT(R_NO_MEMORY);
48 :
49 0 : ifp->obj = obj;
50 0 : ifp->vtbl = vtbl;
51 :
52 0 : *ifpp = ifp;
53 :
54 0 : _status=0;
55 : abort:
56 0 : return(_status);
57 : }
58 :
59 0 : int nr_interface_prioritizer_destroy(nr_interface_prioritizer **ifpp)
60 : {
61 : nr_interface_prioritizer *ifp;
62 :
63 0 : if (!ifpp || !*ifpp)
64 0 : return(0);
65 :
66 0 : ifp = *ifpp;
67 0 : *ifpp = 0;
68 0 : ifp->vtbl->destroy(&ifp->obj);
69 0 : RFREE(ifp);
70 0 : return(0);
71 : }
72 :
73 0 : int nr_interface_prioritizer_add_interface(nr_interface_prioritizer *ifp,
74 : nr_local_addr *addr)
75 : {
76 0 : return ifp->vtbl->add_interface(ifp->obj, addr);
77 : }
78 :
79 0 : int nr_interface_prioritizer_get_priority(nr_interface_prioritizer *ifp,
80 : const char *key, UCHAR *interface_preference)
81 : {
82 0 : return ifp->vtbl->get_priority(ifp->obj,key,interface_preference);
83 : }
84 :
85 0 : int nr_interface_prioritizer_sort_preference(nr_interface_prioritizer *ifp)
86 : {
87 0 : return ifp->vtbl->sort_preference(ifp->obj);
88 : }
|