1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
diff -ruN src.orig/hash.c src/hash.c
--- src.orig/hash.c 2011-12-15 19:50:59.084410154 +0400
+++ src/hash.c 2011-12-15 19:27:15.384413000 +0400
@@ -1,4 +1,5 @@
#include <stdio.h>
+#include <string.h>
#include <strings.h>
#include "hash.h"
@@ -37,7 +38,7 @@
int
hash_put(hash_t *hash, void *key, void *data, hash_entry_t **res)
{
-unsigned int index = 0;
+uintptr_t index = 0;
hash_entry_t *he = NULL;
hash_row_t *row = NULL;
int rc = 0;
@@ -48,7 +49,7 @@
if ( hash->valid != HASH_VALID ) return(EINVAL);
switch(hash->type) {
case HASH_KEY_INT:
- index = (unsigned int)key % hash->rows;
+ index = (uintptr_t)key % hash->rows;
break;
case HASH_KEY_STRING:
index = string_hash((char*)key) % hash->rows;
@@ -65,7 +66,7 @@
while ( he ) {
switch(hash->type) {
case(HASH_KEY_INT):
- if ( (int)he->key == (int)key ) {
+ if ( he->key == key ) {
rc = EEXIST;
goto done;
}
@@ -122,7 +123,7 @@
int
hash_get(hash_t *hash, void *key, hash_entry_t **he_res)
{
-unsigned int index = 0;
+uintptr_t index = 0;
hash_entry_t *he = NULL;
hash_row_t *row = NULL;
int rc = 0;
@@ -134,7 +135,7 @@
if ( hash->valid != HASH_VALID ) return(EINVAL);
switch(hash->type) {
case HASH_KEY_INT:
- index = (unsigned int)key % hash->rows;
+ index = (uintptr_t)key % hash->rows;
break;
case HASH_KEY_STRING:
index = string_hash((char*)key) % hash->rows;
@@ -155,7 +156,7 @@
}
switch(hash->type) {
case(HASH_KEY_INT):
- if ( (int)he->key == (int)key ) {
+ if ( he->key == key ) {
he->ref_count++;
*he_res = he;
goto done;
diff -ruN src.orig/icp.c src/icp.c
--- src.orig/icp.c 2011-12-15 19:50:59.097408824 +0400
+++ src/icp.c 2011-12-15 19:23:18.626418000 +0400
@@ -36,7 +36,7 @@
int version:8;
short msg_len;
} w0;
- int rq_n;
+ uintptr_t rq_n;
int opt;
int opt_data;
int sender;
@@ -45,15 +45,15 @@
struct icp_lookup {
struct sockaddr_in sa;
char type;
- int rq_n;
+ uintptr_t rq_n;
};
static struct peer *peer_by_addr(struct sockaddr_in*);
static int process_hit(struct icp_lookup *icp_lookup, struct icp_queue_elem *qe);
static void process_icp_msg(int so, char *buf, int len, struct sockaddr_in *, struct sockaddr_in *);
static int process_miss(struct icp_lookup *icp_lookup, struct icp_queue_elem *qe);
-static void send_icp_op(int so, struct sockaddr_in *sa, int op, int rq_n, char *urlp);
-static void send_icp_op_err(int so, struct sockaddr_in *sa, int rq_n);
+static void send_icp_op(int so, struct sockaddr_in *sa, int op, uintptr_t rq_n, char *urlp);
+static void send_icp_op_err(int so, struct sockaddr_in *sa, uintptr_t rq_n);
#define icp_opcode icp_hdr->w0.opcode
@@ -473,7 +473,7 @@
}
static void
-send_icp_op_err(int so, struct sockaddr_in *sa, int rq_n)
+send_icp_op_err(int so, struct sockaddr_in *sa, uintptr_t rq_n)
{
char buf[5*4];
int len = sizeof(buf);
@@ -488,7 +488,7 @@
}
static void
-send_icp_op(int so, struct sockaddr_in *sa, int op, int rq_n, char *urlp)
+send_icp_op(int so, struct sockaddr_in *sa, int op, uintptr_t rq_n, char *urlp)
{
char *buf;
int len = strlen(urlp)+1 + sizeof(struct icp_hdr);
@@ -545,7 +545,7 @@
static int
process_miss(struct icp_lookup *icp_lookup, struct icp_queue_elem *qe)
{
-int rq_n;
+uintptr_t rq_n;
if ( !qe || !icp_lookup ) return(0);
rq_n = icp_lookup->rq_n;
@@ -578,7 +578,7 @@
static int
process_hit(struct icp_lookup *icp_lookup, struct icp_queue_elem *qe)
{
-int rq_n;
+uintptr_t rq_n;
if ( !qe || !icp_lookup ) return(0);
rq_n = icp_lookup->rq_n;
diff -ruN src.orig/oops.h src/oops.h
--- src.orig/oops.h 2011-12-15 19:50:59.092410511 +0400
+++ src/oops.h 2011-12-15 19:32:49.781410000 +0400
@@ -839,8 +839,8 @@
struct acls *http;
struct acls *icp;
struct badports *badports;
- int bandwidth;
- int miss_deny; /* TRUE if deny */
+ uintptr_t bandwidth;
+ uintptr_t miss_deny; /* TRUE if deny */
struct l_string_list *auth_mods; /* auth modules */
l_mod_call_list_t *redir_mods; /* redir modules */
pthread_mutex_t group_mutex;
@@ -852,10 +852,10 @@
struct denytime *denytimes;
hash_t *dstdomain_cache; /* cashe for dstdom checks */
acl_chk_list_hdr_t *networks_acl;
- int maxreqrate; /* max request rate */
- int per_sess_bw; /* max bandw per session */
- int per_ip_bw; /* bandw per ip address (or client) */
- int per_ip_conn; /* max number of conns per ip */
+ uintptr_t maxreqrate; /* max request rate */
+ uintptr_t per_sess_bw; /* max bandw per session */
+ uintptr_t per_ip_bw; /* bandw per ip address (or client) */
+ uintptr_t per_ip_conn; /* max number of conns per ip */
struct sockaddr_in conn_from_sa; /* connect from address */
};
@@ -922,7 +922,7 @@
/* url in icp format */
char *url;
/* request number - id of request */
- int rq_n;
+ uintptr_t rq_n;
/* how much peers was sent request to *
* (we will wait that many answers) */
int requests_sent;
@@ -1014,7 +1014,7 @@
#define IS_HUPED(a) (((a)->answer)&FD_POLL_HU)
struct pollarg {
- int fd;
+ uintptr_t fd;
short request;
short answer;
};
diff -ruN src.orig/parser.y src/parser.y
--- src.orig/parser.y 2011-12-15 19:50:59.089409966 +0400
+++ src/parser.y 2011-12-15 19:45:36.266416000 +0400
@@ -69,7 +69,7 @@
%}
%union {
- int INT;
+ uintptr_t INT;
char *STRPTR;
char CHAR;
struct cidr_net *NETPTR;
@@ -907,26 +907,26 @@
new_grp->badports = ops->val;
break;
case OP_BANDWIDTH:
- new_grp->bandwidth = (int)ops->val;
+ new_grp->bandwidth = (uintptr_t)ops->val;
break;
case OP_PER_SESS_BW:
- new_grp->per_sess_bw = (int)ops->val;
+ new_grp->per_sess_bw = (uintptr_t)ops->val;
break;
case OP_PER_IP_BW:
- new_grp->per_ip_bw = (int)ops->val;
+ new_grp->per_ip_bw = (uintptr_t)ops->val;
break;
case OP_PER_IP_CONN:
- new_grp->per_ip_conn = (int)ops->val;
+ new_grp->per_ip_conn = (uintptr_t)ops->val;
break;
case OP_CONN_FROM:
memcpy(&new_grp->conn_from_sa, ops->val, sizeof(new_grp->conn_from_sa));
free(ops->val);
break;
case OP_MISS:
- new_grp->miss_deny = (int)ops->val;
+ new_grp->miss_deny = (uintptr_t)ops->val;
break;
case OP_MAXREQRATE:
- new_grp->maxreqrate = (int)ops->val;
+ new_grp->maxreqrate = (uintptr_t)ops->val;
break;
case OP_AUTH_MODS:
if ( ops->val ) {
|