Changeset 4b5d05b46785f944e0d4ba506afeb9df499a6aac
- Timestamp:
- 06/21/11 11:08:58 (11 months ago)
- Author:
- Neutron Soutmun <neo.neutron@…>
- Children:
- 0689196636498f5ef2219550ec79bf0f7c40aa41
- Parents:
- cb5371333692435b9818b9043a26980e404202d1
- git-committer:
- Neutron Soutmun <neo.neutron@…> (06/21/11 11:08:58)
- Message:
-
Fix compiler warnings
- src/rahunasd.c:
- Declare termstring = "" instead.
- src/rh-ipset.{h, c}:
- Declare unsigned variable as unsigned int instead.
- src/rh-ipset.c (set_ipiphash_adtip):
- Fix typo which should call set_ipiphash_adtip_nb() instead.
- src/rh-serviceclass.c, src/rh-task-serviceclass.c:
- Include string.h to fix the compiler warnings.
- src/rh-serviceclass.{h,c}:
- Replace struct main_server and struct serviceclass with RHMainServer and
RHSvClass respectively.
- src/rh-task-ipset.c (set_cleanup):
- src/rh-task-memset.c (startsess):
- Fix compiler warnnings on assigning "const char *" to "char *" variable.
- src/rh-task-serviceclass.c:
- Fix compiler warnnings on rh_free().
- Free member->mapping_ip before assign new data.
- src/Makefile.am:
- Add src/ipset/*.h headers to makefile which they should included in
tarball.
- Location:
- src
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
rcb53713
|
r4b5d05b
|
|
| 29 | 29 | rh-xmlrpc-cmd.c \ |
| 30 | 30 | rh-xmlrpc-cmd.h \ |
| | 31 | ipset/ip_set_bitmaps.h \ |
| | 32 | ipset/ip_set_hashes.h \ |
| | 33 | ipset/ip_set_rahunas_ipiphash.h \ |
| | 34 | ipset/ip_set.h \ |
| | 35 | ipset/ip_set_rahunas.h \ |
| 31 | 36 | rh-ipset.c \ |
| 32 | 37 | rh-ipset.h \ |
-
|
rcb53713
|
r4b5d05b
|
|
| 24 | 24 | #include "rh-task.h" |
| 25 | 25 | |
| 26 | | const char *termstring = '\0'; |
| | 26 | const char *termstring = ""; |
| 27 | 27 | pid_t pid, sid; |
| 28 | 28 | |
-
|
rcb53713
|
r4b5d05b
|
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | | int kernel_sendto_handleerrno(unsigned op, void *data, socklen_t size) |
| | 88 | int kernel_sendto_handleerrno(unsigned int op, void *data, socklen_t size) |
| 89 | 89 | { |
| 90 | 90 | int res = wrapped_setsockopt(data, size); |
| … |
… |
|
| 230 | 230 | |
| 231 | 231 | int set_adtip(struct set *rahunas_set, const char *adtip, const char *adtmac, |
| 232 | | unsigned op) |
| | 232 | unsigned int op) |
| 233 | 233 | { |
| 234 | 234 | ip_set_ip_t ip; |
| … |
… |
|
| 241 | 241 | |
| 242 | 242 | int set_adtip_nb(struct set *rahunas_set, ip_set_ip_t *adtip, |
| 243 | | unsigned char adtmac[ETH_ALEN], unsigned op) |
| | 243 | unsigned char adtmac[ETH_ALEN], unsigned int op) |
| 244 | 244 | { |
| 245 | 245 | struct ip_set_req_adt *req_adt = NULL; |
| … |
… |
|
| 300 | 300 | |
| 301 | 301 | int set_ipiphash_adtip(struct set *rahunas_set, const char *ip, |
| 302 | | const char *ip1, unsigned op) |
| | 302 | const char *ip1, unsigned int op) |
| 303 | 303 | { |
| 304 | 304 | ip_set_ip_t _ip; |
| … |
… |
|
| 307 | 307 | parse_ip(ip1, &_ip1); |
| 308 | 308 | |
| 309 | | return set_adtip_nb(rahunas_set, &_ip, &_ip1, op); |
| | 309 | return set_ipiphash_adtip_nb(rahunas_set, &_ip, &_ip1, op); |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | int set_ipiphash_adtip_nb(struct set *rahunas_set, ip_set_ip_t *ip, |
| 313 | | ip_set_ip_t *ip1, unsigned op) |
| | 313 | ip_set_ip_t *ip1, unsigned int op) |
| 314 | 314 | { |
| 315 | 315 | struct ip_set_req_adt *req_adt = NULL; |
| … |
… |
|
| 384 | 384 | size_t load_set_list(RHVServer *vs, const char name[IP_SET_MAXNAMELEN], |
| 385 | 385 | ip_set_id_t *idx, |
| 386 | | unsigned op, unsigned cmd) |
| | 386 | unsigned int op, unsigned int cmd) |
| 387 | 387 | { |
| 388 | 388 | void *data = NULL; |
-
|
rcb53713
|
r4b5d05b
|
|
| 24 | 24 | ip_set_id_t id; /* Unique set id */ |
| 25 | 25 | ip_set_id_t index; /* Array index */ |
| 26 | | unsigned ref; /* References in kernel */ |
| | 26 | unsigned int ref; /* References in kernel */ |
| 27 | 27 | struct settype *settype; /* Pointer to set type functions */ |
| 28 | 28 | }; |
| … |
… |
|
| 75 | 75 | int wrapped_setsockopt(void *data, socklen_t size); |
| 76 | 76 | void kernel_getfrom(void *data, socklen_t * size); |
| 77 | | int kernel_sendto_handleerrno(unsigned op, void *data, socklen_t size); |
| | 77 | int kernel_sendto_handleerrno(unsigned int op, void *data, socklen_t size); |
| 78 | 78 | void kernel_sendto(void *data, size_t size); |
| 79 | 79 | int kernel_getfrom_handleerrno(void *data, socklen_t * size); |
| 80 | 80 | struct set *set_adt_get(const char *name); |
| 81 | 81 | int set_adtip(struct set *rahunas_set, const char *adtip, const char *adtmac, |
| 82 | | unsigned op); |
| | 82 | unsigned int op); |
| 83 | 83 | |
| 84 | 84 | int set_adtip_nb(struct set *rahunas_set, ip_set_ip_t *adtip, |
| 85 | | unsigned char adtmac[ETH_ALEN], unsigned op); |
| | 85 | unsigned char adtmac[ETH_ALEN], unsigned int op); |
| 86 | 86 | |
| 87 | 87 | int set_ipiphash_adtip(struct set *rahunas_set, const char *ip, |
| 88 | | const char *ip1, unsigned op); |
| | 88 | const char *ip1, unsigned int op); |
| 89 | 89 | int set_ipiphash_adtip_nb(struct set *rahunas_set, ip_set_ip_t *ip, |
| 90 | | ip_set_ip_t *ip1, unsigned op); |
| | 90 | ip_set_ip_t *ip1, unsigned int op); |
| 91 | 91 | |
| 92 | 92 | void set_flush(const char *name); |
| … |
… |
|
| 94 | 94 | size_t load_set_list(RHVServer *vs, const char name[IP_SET_MAXNAMELEN], |
| 95 | 95 | ip_set_id_t *idx, |
| 96 | | unsigned op, unsigned cmd); |
| | 96 | unsigned int op, unsigned int cmd); |
| 97 | 97 | |
| 98 | 98 | int get_header_from_set (RHVServer *vs); |
-
|
r43154f8
|
r4b5d05b
|
|
| 5 | 5 | */ |
| 6 | 6 | #include <stdio.h> |
| | 7 | #include <string.h> |
| 7 | 8 | #include <arpa/inet.h> |
| 8 | 9 | #include "rahunasd.h" |
| … |
… |
|
| 11 | 12 | #include "rh-ipset.h" |
| 12 | 13 | |
| 13 | | int serviceclass_do_init (struct main_server *ms, struct serviceclass *sc); |
| 14 | | |
| 15 | | struct serviceclass *serviceclass_exists(GList *serviceclass_list, |
| | 14 | int serviceclass_do_init (RHMainServer *ms, RHSvClass *sc); |
| | 15 | |
| | 16 | RHSvClass *serviceclass_exists(GList *serviceclass_list, |
| 16 | 17 | int serviceclass_id, |
| 17 | 18 | const char *serviceclass_name) |
| 18 | 19 | { |
| 19 | 20 | GList *runner = g_list_first(serviceclass_list); |
| 20 | | struct serviceclass *lserviceclass = NULL; |
| 21 | | |
| 22 | | while (runner != NULL) { |
| 23 | | lserviceclass = (struct serviceclass *)runner->data; |
| | 21 | RHSvClass *lserviceclass = NULL; |
| | 22 | |
| | 23 | while (runner != NULL) { |
| | 24 | lserviceclass = (RHSvClass *)runner->data; |
| 24 | 25 | |
| 25 | 26 | if (lserviceclass->serviceclass_config->serviceclass_id == serviceclass_id) |
| … |
… |
|
| 35 | 36 | } |
| 36 | 37 | |
| 37 | | struct servicclass *serviceclass_get_by_id(struct main_server *ms, |
| 38 | | int search_id) |
| | 38 | RHSvClass *serviceclass_get_by_id(RHMainServer *ms, int search_id) |
| 39 | 39 | { |
| 40 | 40 | GList *runner = g_list_first(ms->serviceclass_list); |
| 41 | | struct serviceclass *lserviceclass = NULL; |
| 42 | | |
| 43 | | while (runner != NULL) { |
| 44 | | lserviceclass = (struct serviceclass *)runner->data; |
| | 41 | RHSvClass *lserviceclass = NULL; |
| | 42 | |
| | 43 | while (runner != NULL) { |
| | 44 | lserviceclass = (RHSvClass *)runner->data; |
| 45 | 45 | |
| 46 | 46 | if (lserviceclass->serviceclass_config->serviceclass_id == search_id) { |
| … |
… |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | | int serviceclass_cleanup(struct serviceclass *sc) |
| | 55 | int serviceclass_cleanup(RHSvClass *sc) |
| 56 | 56 | { |
| 57 | 57 | if (sc == NULL) |
| … |
… |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | | int register_serviceclass(struct main_server *ms, |
| | 66 | int register_serviceclass(RHMainServer *ms, |
| 67 | 67 | const char *serviceclass_cfg_file) |
| 68 | 68 | { |
| … |
… |
|
| 73 | 73 | union rahunas_config *cfg_get = NULL; |
| 74 | 74 | struct rahunas_serviceclass_config *serviceclass_config = NULL; |
| 75 | | struct serviceclass *new_serviceclass = NULL; |
| 76 | | struct serviceclass *old_serviceclass = NULL; |
| | 75 | RHSvClass *new_serviceclass = NULL; |
| | 76 | RHSvClass *old_serviceclass = NULL; |
| 77 | 77 | |
| 78 | 78 | union rahunas_config config = { |
| … |
… |
|
| 99 | 99 | if (old_serviceclass->dummy_config != NULL) { |
| 100 | 100 | DP("Cleanup old dummy config"); |
| 101 | | rh_free(&old_serviceclass->dummy_config); |
| | 101 | rh_free((void **) &old_serviceclass->dummy_config); |
| 102 | 102 | } |
| 103 | 103 | |
| … |
… |
|
| 134 | 134 | memcpy(serviceclass_config, &config, sizeof(struct rahunas_serviceclass_config)); |
| 135 | 135 | |
| 136 | | new_serviceclass = (struct serviceclass *) rh_malloc(sizeof(struct serviceclass)); |
| | 136 | new_serviceclass = (RHSvClass *) rh_malloc(sizeof(RHSvClass)); |
| 137 | 137 | |
| 138 | 138 | if (new_serviceclass == NULL) |
| 139 | 139 | return -1; |
| 140 | 140 | |
| 141 | | memset(new_serviceclass, 0, sizeof(struct serviceclass)); |
| | 141 | memset(new_serviceclass, 0, sizeof(RHSvClass)); |
| 142 | 142 | |
| 143 | 143 | new_serviceclass->serviceclass_config = serviceclass_config; |
| … |
… |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | | int unregister_serviceclass(struct main_server *ms, int serviceclass_id) |
| 151 | | { |
| 152 | | GList *serviceclass_list = ms->serviceclass_list; |
| 153 | | GList *runner = g_list_first(serviceclass_list); |
| 154 | | struct serviceclass *lserviceclass = NULL; |
| 155 | | |
| 156 | | while (runner != NULL) { |
| 157 | | lserviceclass = (struct serviceclass *)runner->data; |
| | 150 | int unregister_serviceclass(RHMainServer *ms, int serviceclass_id) |
| | 151 | { |
| | 152 | GList *serviceclass_list = ms->serviceclass_list; |
| | 153 | GList *runner = g_list_first(serviceclass_list); |
| | 154 | RHSvClass *lserviceclass = NULL; |
| | 155 | |
| | 156 | while (runner != NULL) { |
| | 157 | lserviceclass = (RHSvClass *)runner->data; |
| 158 | 158 | if (lserviceclass->serviceclass_config->serviceclass_id == serviceclass_id) { |
| 159 | 159 | serviceclass_cleanup(lserviceclass); |
| … |
… |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | | int unregister_serviceclass_all(struct main_server *ms) |
| | 170 | int unregister_serviceclass_all(RHMainServer *ms) |
| 171 | 171 | { |
| 172 | 172 | GList *serviceclass_list = ms->serviceclass_list; |
| 173 | 173 | GList *runner = g_list_first(serviceclass_list); |
| 174 | 174 | GList *deleting = NULL; |
| 175 | | struct serviceclass *lserviceclass = NULL; |
| 176 | | |
| 177 | | while (runner != NULL) { |
| 178 | | lserviceclass = (struct serviceclass *)runner->data; |
| | 175 | RHSvClass *lserviceclass = NULL; |
| | 176 | |
| | 177 | while (runner != NULL) { |
| | 178 | lserviceclass = (RHSvClass *)runner->data; |
| 179 | 179 | serviceclass_cleanup(lserviceclass); |
| 180 | 180 | deleting = runner; |
| … |
… |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | | int walk_through_serviceclass(int (*callback)(void *, void *), struct main_server *ms) |
| 191 | | { |
| 192 | | GList *serviceclass_list = ms->serviceclass_list; |
| 193 | | GList *runner = g_list_first(serviceclass_list); |
| 194 | | struct serviceclass *sc = NULL; |
| 195 | | |
| 196 | | while (runner != NULL) { |
| 197 | | sc = (struct serviceclass *)runner->data; |
| | 190 | int walk_through_serviceclass(int (*callback)(void *, void *), RHMainServer *ms) |
| | 191 | { |
| | 192 | GList *serviceclass_list = ms->serviceclass_list; |
| | 193 | GList *runner = g_list_first(serviceclass_list); |
| | 194 | RHSvClass *sc = NULL; |
| | 195 | |
| | 196 | while (runner != NULL) { |
| | 197 | sc = (RHSvClass *)runner->data; |
| 198 | 198 | |
| 199 | 199 | (*callback)(ms, sc); |
| … |
… |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | | void serviceclass_init(struct main_server *ms, struct serviceclass *sc) |
| | 207 | void serviceclass_init(RHMainServer *ms, RHSvClass *sc) |
| 208 | 208 | { |
| 209 | 209 | struct rahunas_serviceclass_config *sc_config = NULL; |
| … |
… |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | | void serviceclass_reload(struct main_server *ms, struct serviceclass *sc) |
| | 223 | void serviceclass_reload(RHMainServer *ms, RHSvClass *sc) |
| 224 | 224 | { |
| 225 | 225 | if (sc->serviceclass_config->init_flag == SC_DONE) { |
| … |
… |
|
| 257 | 257 | memcpy(sc->serviceclass_config, sc->dummy_config, |
| 258 | 258 | sizeof(struct rahunas_serviceclass_config)); |
| 259 | | rh_free(&sc->dummy_config); |
| | 259 | rh_free((void **) &sc->dummy_config); |
| 260 | 260 | } |
| 261 | 261 | |
| … |
… |
|
| 269 | 269 | |
| 270 | 270 | |
| 271 | | void serviceclass_unused_cleanup(struct main_server *ms) |
| 272 | | { |
| 273 | | GList *serviceclass_list = ms->serviceclass_list; |
| 274 | | GList *runner = g_list_first(serviceclass_list); |
| 275 | | struct serviceclass *lserviceclass = NULL; |
| 276 | | |
| 277 | | while (runner != NULL) { |
| 278 | | lserviceclass = (struct serviceclass *)runner->data; |
| | 271 | void serviceclass_unused_cleanup(RHMainServer *ms) |
| | 272 | { |
| | 273 | GList *serviceclass_list = ms->serviceclass_list; |
| | 274 | GList *runner = g_list_first(serviceclass_list); |
| | 275 | RHSvClass *lserviceclass = NULL; |
| | 276 | |
| | 277 | while (runner != NULL) { |
| | 278 | lserviceclass = (RHSvClass *)runner->data; |
| 279 | 279 | if (lserviceclass->serviceclass_config->init_flag == SC_NONE) { |
| 280 | 280 | logmsg(RH_LOG_NORMAL, "[%s] - Service class config removed", |
| … |
… |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | | int serviceclass_do_init (struct main_server *ms, struct serviceclass *sc) |
| | 292 | int serviceclass_do_init (RHMainServer *ms, RHSvClass *sc) |
| 293 | 293 | { |
| 294 | 294 | struct rahunas_serviceclass_config *sc_config = sc->serviceclass_config; |
-
|
rcb53713
|
r4b5d05b
|
|
| 8 | 8 | |
| 9 | 9 | #include <glib.h> |
| | 10 | #include "rh-server.h" |
| 10 | 11 | #include "rh-config.h" |
| 11 | 12 | |
| … |
… |
|
| 20 | 21 | |
| 21 | 22 | |
| 22 | | struct serviceclass *serviceclass_exists(GList *serviceclass_list, |
| 23 | | int serviceclass_id, |
| 24 | | const char *servicclass_name); |
| | 23 | RHSvClass *serviceclass_exists (GList *serviceclass_list, |
| | 24 | int serviceclass_id, |
| | 25 | const char *serviceclass_name); |
| 25 | 26 | |
| 26 | | struct servicclass *serviceclass_get_by_id(struct main_server *ms, |
| 27 | | int search_id); |
| 28 | | int serviceclass_cleanup(struct serviceclass *sc); |
| | 27 | RHSvClass *serviceclass_get_by_id (RHMainServer *ms, int search_id); |
| | 28 | int serviceclass_cleanup (RHSvClass *sc); |
| 29 | 29 | |
| 30 | | int register_serviceclass(struct main_server *ms, |
| 31 | | const char *serviceclass_cfg_file); |
| 32 | | int unregister_serviceclass(struct main_server *ms, int serviceclass_id); |
| 33 | | int unregister_serviceclass_all(struct main_server *ms); |
| | 30 | int register_serviceclass (RHMainServer *ms, |
| | 31 | const char *serviceclass_cfg_file); |
| | 32 | int unregister_serviceclass (RHMainServer *ms, int serviceclass_id); |
| | 33 | int unregister_serviceclass_all (RHMainServer *ms); |
| 34 | 34 | |
| 35 | | void serviceclass_init(struct main_server *ms, struct serviceclass *sc); |
| 36 | | void serviceclass_reload(struct main_server *ms, struct serviceclass *sc); |
| 37 | | void serviceclass_unused_cleanup(struct main_server *ms); |
| | 35 | void serviceclass_init (RHMainServer *ms, RHSvClass *sc); |
| | 36 | void serviceclass_reload (RHMainServer *ms, RHSvClass *sc); |
| | 37 | void serviceclass_unused_cleanup (RHMainServer *ms); |
| 38 | 38 | |
| 39 | 39 | #endif // __RH_SERVICECLASS_H |
-
|
rcb53713
|
r4b5d05b
|
|
| 32 | 32 | |
| 33 | 33 | offset = sizeof(struct ip_set_list) + setlist->header_size; |
| 34 | | table = (struct ip_set_rahunas *)(process->list + offset); |
| | 34 | table = (struct ip_set_rahu *)(process->list + offset); |
| 35 | 35 | |
| 36 | 36 | while (runner != NULL) { |
-
|
rcb53713
|
r4b5d05b
|
|
| 155 | 155 | free(member->serviceclass_name); |
| 156 | 156 | |
| 157 | | if (member->mapping_ip && member->mapping_ip != termstring) |
| 158 | | free(member->mapping_ip); |
| | 157 | if (member->mapping_ip) |
| | 158 | { |
| | 159 | free(member->mapping_ip); |
| | 160 | member->mapping_ip = NULL; |
| | 161 | } |
| 159 | 162 | |
| 160 | 163 | member->username = strdup(req->username); |
| … |
… |
|
| 169 | 172 | member->serviceclass_description = termstring; |
| 170 | 173 | member->serviceclass_slot_id = 0; |
| 171 | | member->mapping_ip = termstring; |
| | 174 | member->mapping_ip = strdup(termstring); |
| 172 | 175 | |
| 173 | 176 | if (req->session_start == 0) { |
-
|
rcb53713
|
r4b5d05b
|
|
| 5 | 5 | */ |
| 6 | 6 | |
| | 7 | #include <string.h> |
| 7 | 8 | #include <syslog.h> |
| 8 | 9 | #include <libgda/libgda.h> |
| … |
… |
|
| 86 | 87 | logmsg(RH_LOG_NORMAL, "Service Class: Flushing set ..."); |
| 87 | 88 | set_flush (SERVICECLASS_SET_NAME); |
| 88 | | rh_free(&rh_serviceclass_set); |
| | 89 | rh_free((void **) &rh_serviceclass_set); |
| 89 | 90 | } |
| 90 | 91 | |
| … |
… |
|
| 160 | 161 | member->serviceclass_description = sc_config->description; |
| 161 | 162 | member->serviceclass_slot_id = req->serviceclass_slot_id; |
| | 163 | |
| | 164 | if (member->mapping_ip) |
| | 165 | { |
| | 166 | free (member->mapping_ip); |
| | 167 | member->mapping_ip = NULL; |
| | 168 | } |
| 162 | 169 | |
| 163 | 170 | member->mapping_ip = strdup (ip_tostring(ip1)); |