Mercurial > hg > freeDiameter
annotate extensions/rt_ignore_dh/rt_ignore_dh.c @ 1284:38e4a7c318ac
Fix a number of compilation warnings
author | Sebastien Decugis <sdecugis@freediameter.net> |
---|---|
date | Sun, 04 Jan 2015 00:55:57 +0800 |
parents | 34265c9c1e94 |
children |
rev | line source |
---|---|
1043 | 1 /********************************************************************************************************* |
2 * Software License Agreement (BSD License) * | |
3 * Author: Thomas Klausner <tk@giga.or.at> * | |
4 * * | |
5 * Copyright (c) 2013, Thomas Klausner * | |
6 * All rights reserved. * | |
7 * * | |
8 * Written under contract by nfotex IT GmbH, http://nfotex.com/ * | |
9 * * | |
10 * Redistribution and use of this software in source and binary forms, with or without modification, are * | |
11 * permitted provided that the following conditions are met: * | |
12 * * | |
13 * * Redistributions of source code must retain the above * | |
14 * copyright notice, this list of conditions and the * | |
15 * following disclaimer. * | |
16 * * | |
17 * * Redistributions in binary form must reproduce the above * | |
18 * copyright notice, this list of conditions and the * | |
19 * following disclaimer in the documentation and/or other * | |
20 * materials provided with the distribution. * | |
21 * * | |
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED * | |
23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * | |
24 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * | |
25 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * | |
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * | |
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * | |
28 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * | |
29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * | |
30 *********************************************************************************************************/ | |
31 | |
1041
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
32 #include <freeDiameter/extension.h> |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
33 |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
34 /* |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
35 * Remove Destination-Hosts, putting it into Proxy-Info, and restore it to |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
36 * Origin-Host for answers. |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
37 */ |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
38 |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
39 struct dict_object * dh_avp_do; /* cache the Destination-Host dictionary object */ |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
40 struct dict_object * oh_avp_do; /* cache the Origin-Host dictionary object */ |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
41 struct dict_object * ph_avp_do; /* cache the Proxy-Host dictionary object */ |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
42 struct dict_object * pi_avp_do; /* cache the Proxy-Info dictionary object */ |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
43 struct dict_object * ps_avp_do; /* cache the Proxy-State dictionary object */ |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
44 |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
45 static int restore_origin_host(struct msg **msg) { |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
46 struct avp *avp, *child; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
47 struct avp *oh_avp = NULL; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
48 struct avp *pi_avp = NULL; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
49 void *ps, *new_oh; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
50 size_t ps_len, new_oh_len = 0; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
51 union avp_value val; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
52 |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
53 ps = new_oh = NULL; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
54 |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
55 CHECK_FCT(fd_msg_browse(*msg, MSG_BRW_FIRST_CHILD, &avp, NULL)); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
56 /* look for Origin-Host and Proxy-Info matching this host */ |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
57 while (avp && (!oh_avp || !pi_avp)) { |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
58 struct avp_hdr * ahdr; |
1052
b3d623f04b6d
Fix a number of remaining compilation warnings
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1043
diff
changeset
|
59 int match = 0; |
1041
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
60 |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
61 CHECK_FCT(fd_msg_avp_hdr(avp, &ahdr)); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
62 if (!(ahdr->avp_flags & AVP_FLAG_VENDOR)) { |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
63 switch (ahdr->avp_code) { |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
64 case AC_ORIGIN_HOST: |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
65 oh_avp = avp; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
66 CHECK_FCT(fd_msg_parse_dict(oh_avp, fd_g_config->cnf_dict, NULL)); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
67 break; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
68 case AC_PROXY_INFO: |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
69 ps = NULL; |
1052
b3d623f04b6d
Fix a number of remaining compilation warnings
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1043
diff
changeset
|
70 ps_len = 0; |
1041
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
71 CHECK_FCT(fd_msg_parse_dict(avp, fd_g_config->cnf_dict, NULL)); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
72 CHECK_FCT(fd_msg_browse(avp, MSG_BRW_FIRST_CHILD, &child, NULL)); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
73 while (child && (!match || !ps)) { |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
74 struct avp_hdr *chdr; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
75 CHECK_FCT(fd_msg_avp_hdr(child, &chdr)); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
76 if (!(chdr->avp_flags & AVP_FLAG_VENDOR)) { |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
77 switch (chdr->avp_code) { |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
78 case AC_PROXY_HOST: |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
79 if (fd_os_cmp(chdr->avp_value->os.data, chdr->avp_value->os.len, |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
80 fd_g_config->cnf_diamid, fd_g_config->cnf_diamid_len) == 0) { |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
81 match = 1; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
82 } |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
83 break; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
84 case AC_PROXY_STATE: |
1272 | 85 ps = chdr->avp_value->os.data; |
1041
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
86 ps_len = chdr->avp_value->os.len; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
87 break; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
88 default: |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
89 break; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
90 } |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
91 } |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
92 CHECK_FCT(fd_msg_browse(child, MSG_BRW_NEXT, &child, NULL)); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
93 } |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
94 if (match && ps) { |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
95 new_oh = ps; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
96 new_oh_len = ps_len; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
97 pi_avp = avp; |
1272 | 98 } |
1041
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
99 break; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
100 default: |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
101 break; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
102 } |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
103 } |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
104 CHECK_FCT(fd_msg_browse(avp, MSG_BRW_NEXT, &avp, NULL)); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
105 } |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
106 if (!pi_avp) |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
107 return 0; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
108 |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
109 memset(&val, 0, sizeof(val)); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
110 val.os.data = new_oh; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
111 val.os.len = new_oh_len; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
112 if (!oh_avp) { |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
113 TRACE_ERROR("Message contained no Origin-Host"); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
114 } else { |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
115 CHECK_FCT(fd_msg_avp_setvalue(oh_avp, &val)); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
116 } |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
117 fd_msg_free((msg_or_avp*)pi_avp); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
118 |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
119 fd_log_debug("Restored Origin-Host '%.*s' from Proxy-Info", (int)new_oh_len, (char *)new_oh); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
120 return 0; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
121 } |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
122 |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
123 static int stow_destination_host(struct msg **msg) { |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
124 struct avp * avp = NULL; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
125 struct avp * ph_avp = NULL; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
126 struct avp * pi_avp = NULL; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
127 struct avp * ps_avp = NULL; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
128 |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
129 /* Look for the Destination-Host AVP in the message */ |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
130 CHECK_FCT(fd_msg_search_avp(*msg, dh_avp_do, &avp)); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
131 if (avp != NULL) { |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
132 struct avp_hdr * ahdr = NULL; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
133 union avp_value val; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
134 |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
135 CHECK_FCT(fd_msg_avp_hdr(avp, &ahdr)); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
136 if (ahdr->avp_value != NULL) { |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
137 /* add Proxy-Info->{Proxy-Host, Proxy-State} using Destination-Host information */ |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
138 CHECK_FCT(fd_msg_avp_new(ph_avp_do, 0, &ph_avp)); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
139 memset(&val, 0, sizeof(val)); |
1284
38e4a7c318ac
Fix a number of compilation warnings
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1272
diff
changeset
|
140 val.os.data = (uint8_t *)(fd_g_config->cnf_diamid); |
1041
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
141 val.os.len = fd_g_config->cnf_diamid_len; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
142 CHECK_FCT(fd_msg_avp_setvalue(ph_avp, &val)); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
143 |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
144 CHECK_FCT(fd_msg_avp_new(ps_avp_do, 0, &ps_avp)); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
145 memset(&val, 0, sizeof(val)); |
1272 | 146 val.os.data = ahdr->avp_value->os.data; |
1041
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
147 val.os.len = ahdr->avp_value->os.len; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
148 CHECK_FCT(fd_msg_avp_setvalue(ps_avp, &val)); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
149 |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
150 CHECK_FCT(fd_msg_avp_new(pi_avp_do, 0, &pi_avp)); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
151 CHECK_FCT(fd_msg_avp_add(pi_avp, MSG_BRW_LAST_CHILD, ph_avp)); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
152 CHECK_FCT(fd_msg_avp_add(pi_avp, MSG_BRW_LAST_CHILD, ps_avp)); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
153 |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
154 /* remove Destination-Host from message */ |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
155 fd_msg_free((msg_or_avp*)avp); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
156 /* add Proxy-Info */ |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
157 CHECK_FCT(fd_msg_avp_add(*msg, MSG_BRW_LAST_CHILD, pi_avp)); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
158 fd_log_debug("Stowed Destination-Host '%.*s' into Proxy-Info", (int)val.os.len, (const char *)val.os.data); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
159 } |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
160 } |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
161 |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
162 return 0; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
163 } |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
164 |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
165 /* The callback for putting Destination-Host into Proxy-Info and restoring it on the way back */ |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
166 static int rt_ignore_destination_host(void * cbdata, struct msg **msg) { |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
167 struct msg_hdr * hdr; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
168 int ret; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
169 |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
170 TRACE_ENTRY("%p %p", cbdata, msg); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
171 |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
172 CHECK_PARAMS(msg && *msg); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
173 |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
174 /* Read the message header */ |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
175 CHECK_FCT(fd_msg_hdr(*msg, &hdr)); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
176 if (hdr->msg_flags & CMD_FLAG_REQUEST) { |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
177 ret = stow_destination_host(msg); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
178 } else { |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
179 ret = restore_origin_host(msg); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
180 } |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
181 |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
182 return ret; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
183 } |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
184 |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
185 /* handler */ |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
186 static struct fd_rt_fwd_hdl * rt_ignore_destination_host_hdl = NULL; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
187 |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
188 /* entry point */ |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
189 static int rt_ignore_destination_host_entry(char * conffile) |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
190 { |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
191 CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Destination-Host", &dh_avp_do, ENOENT), |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
192 { TRACE_ERROR("Unable to find 'Destination-Host' AVP in the loaded dictionaries."); }); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
193 CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Origin-Host", &oh_avp_do, ENOENT), |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
194 { TRACE_ERROR("Unable to find 'Origin-Host' AVP in the loaded dictionaries."); }); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
195 CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Proxy-Host", &ph_avp_do, ENOENT), |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
196 { TRACE_ERROR("Unable to find 'Proxy-Host' AVP in the loaded dictionaries."); }); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
197 CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Proxy-Info", &pi_avp_do, ENOENT), |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
198 { TRACE_ERROR("Unable to find 'Proxy-Info' AVP in the loaded dictionaries."); }); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
199 CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Proxy-State", &ps_avp_do, ENOENT), |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
200 { TRACE_ERROR("Unable to find 'Proxy-State' AVP in the loaded dictionaries."); }); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
201 |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
202 /* Register the callback */ |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
203 CHECK_FCT(fd_rt_fwd_register(rt_ignore_destination_host, NULL, RT_FWD_ALL, &rt_ignore_destination_host_hdl)); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
204 |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
205 TRACE_DEBUG(INFO, "Extension 'Ignore Destination Host' initialized"); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
206 return 0; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
207 } |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
208 |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
209 /* Unload */ |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
210 void fd_ext_fini(void) |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
211 { |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
212 /* Unregister the callbacks */ |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
213 CHECK_FCT_DO(fd_rt_fwd_unregister(rt_ignore_destination_host_hdl, NULL), /* continue */); |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
214 return ; |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
215 } |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
216 |
a740267f1be6
Add extension that removes Destination-Host from Requests and restores it for Answers.
Thomas Klausner <tk@giga.or.at>
parents:
diff
changeset
|
217 EXTENSION_ENTRY("rt_ignore_destination_host", rt_ignore_destination_host_entry); |