diff options
author | 2012-01-18 02:53:56 +0000 | |
---|---|---|
committer | 2012-01-18 02:53:56 +0000 | |
commit | c46ae4030872bb35258853814c4d7a4820674cac (patch) | |
tree | c48e39459ad67ea310e11a9c94d8c182a0a62c28 | |
parent | Fix a problem that causes LCP keepalive timeout. In case the ack number of (diff) | |
download | wireguard-openbsd-c46ae4030872bb35258853814c4d7a4820674cac.tar.xz wireguard-openbsd-c46ae4030872bb35258853814c4d7a4820674cac.zip |
Fix compiler warnings and some styles.
ok sebastia sthen
-rw-r--r-- | usr.sbin/npppd/l2tp/l2tp.h | 14 | ||||
-rw-r--r-- | usr.sbin/npppd/l2tp/l2tp_ctrl.c | 6 | ||||
-rw-r--r-- | usr.sbin/npppd/l2tp/l2tp_subr.h | 8 | ||||
-rw-r--r-- | usr.sbin/npppd/l2tp/l2tpd.c | 30 | ||||
-rw-r--r-- | usr.sbin/npppd/npppd/npppd.c | 8 | ||||
-rw-r--r-- | usr.sbin/npppd/npppd/npppd_pool.c | 22 | ||||
-rw-r--r-- | usr.sbin/npppd/npppd/npppd_radius.c | 8 | ||||
-rw-r--r-- | usr.sbin/npppd/npppd/ppp.c | 11 | ||||
-rw-r--r-- | usr.sbin/npppd/npppd/radius+.c | 5 | ||||
-rw-r--r-- | usr.sbin/npppd/pppoe/pppoe_session.c | 8 | ||||
-rw-r--r-- | usr.sbin/npppd/pppoe/pppoed.c | 33 | ||||
-rw-r--r-- | usr.sbin/npppd/pptp/pptpd.c | 32 |
12 files changed, 97 insertions, 88 deletions
diff --git a/usr.sbin/npppd/l2tp/l2tp.h b/usr.sbin/npppd/l2tp/l2tp.h index d1927478bbd..b4896726d67 100644 --- a/usr.sbin/npppd/l2tp/l2tp.h +++ b/usr.sbin/npppd/l2tp/l2tp.h @@ -1,4 +1,4 @@ -/* $OpenBSD: l2tp.h,v 1.5 2011/10/15 03:24:11 yasuoka Exp $ */ +/* $OpenBSD: l2tp.h,v 1.6 2012/01/18 02:53:56 yasuoka Exp $ */ /*- * Copyright (c) 2009 Internet Initiative Japan Inc. @@ -30,7 +30,7 @@ /*@file * header file for the L2TP module */ -/* $Id: l2tp.h,v 1.5 2011/10/15 03:24:11 yasuoka Exp $ */ +/* $Id: l2tp.h,v 1.6 2012/01/18 02:53:56 yasuoka Exp $ */ /************************************************************************ * Protocol Constants @@ -313,7 +313,7 @@ typedef struct _l2tpd { /** timeout event context */ struct event ev_timeout; /** instance ID */ - unsigned id; + u_int id; /** listener list */ slist listener; /** state */ @@ -347,7 +347,7 @@ typedef struct _l2tpd { typedef struct _l2tp_ctrl { struct event ev_timeout; /** ID */ - unsigned id; + u_int id; /** parent L2TPD */ l2tpd *l2tpd; /** listener index number */ @@ -425,7 +425,7 @@ typedef struct _l2tp_ctrl { */ typedef struct _l2tp_call { /** ID */ - unsigned id; + u_int id; /** state */ int state; /** parent control connection */ @@ -475,10 +475,10 @@ void l2tpd_release_call (l2tpd *, l2tp_call *); int l2tpd_start (l2tpd *); void l2tpd_stop (l2tpd *); void l2tpd_stop_immediatly (l2tpd *); -l2tp_ctrl *l2tpd_get_ctrl (l2tpd *, int); +l2tp_ctrl *l2tpd_get_ctrl (l2tpd *, u_int); void l2tpd_add_ctrl (l2tpd *, l2tp_ctrl *); void l2tpd_ctrl_finished_notify(l2tpd *); -void l2tpd_remove_ctrl (l2tpd *, int); +void l2tpd_remove_ctrl (l2tpd *, u_int); int l2tpd_add_listener (l2tpd *, int, const char *, struct sockaddr *); void l2tpd_log (l2tpd *, int, const char *, ...) __attribute__((__format__ (__printf__, 3, 4))); diff --git a/usr.sbin/npppd/l2tp/l2tp_ctrl.c b/usr.sbin/npppd/l2tp/l2tp_ctrl.c index 11c9a47b4a3..f237d8f386b 100644 --- a/usr.sbin/npppd/l2tp/l2tp_ctrl.c +++ b/usr.sbin/npppd/l2tp/l2tp_ctrl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: l2tp_ctrl.c,v 1.7 2011/10/15 03:24:11 yasuoka Exp $ */ +/* $OpenBSD: l2tp_ctrl.c,v 1.8 2012/01/18 02:53:56 yasuoka Exp $ */ /*- * Copyright (c) 2009 Internet Initiative Japan Inc. @@ -26,7 +26,7 @@ * SUCH DAMAGE. */ /**@file Control connection processing functions for L2TP LNS */ -/* $Id: l2tp_ctrl.c,v 1.7 2011/10/15 03:24:11 yasuoka Exp $ */ +/* $Id: l2tp_ctrl.c,v 1.8 2012/01/18 02:53:56 yasuoka Exp $ */ #include <sys/types.h> #include <sys/param.h> #include <sys/time.h> @@ -93,7 +93,7 @@ static inline const char *l2tp_ctrl_state_string (l2tp_ctrl *); #endif /* Sequence # of l2tp_ctrl ID */ -static unsigned l2tp_ctrl_id_seq = 0; +static u_int l2tp_ctrl_id_seq = 0; #define SEQ_LT(a,b) ((int16_t)((a) - (b)) < 0) #define SEQ_GT(a,b) ((int16_t)((a) - (b)) > 0) diff --git a/usr.sbin/npppd/l2tp/l2tp_subr.h b/usr.sbin/npppd/l2tp/l2tp_subr.h index d31894ab34a..7b605a4cfbb 100644 --- a/usr.sbin/npppd/l2tp/l2tp_subr.h +++ b/usr.sbin/npppd/l2tp/l2tp_subr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: l2tp_subr.h,v 1.3 2010/07/02 21:20:57 yasuoka Exp $ */ +/* $OpenBSD: l2tp_subr.h,v 1.4 2012/01/18 02:53:56 yasuoka Exp $ */ /*- * Copyright (c) 2009 Internet Initiative Japan Inc. @@ -27,7 +27,7 @@ */ #ifndef L2TP_SUBR_H #define L2TP_SUBR_H 1 -/* $Id: l2tp_subr.h,v 1.3 2010/07/02 21:20:57 yasuoka Exp $ */ +/* $Id: l2tp_subr.h,v 1.4 2012/01/18 02:53:56 yasuoka Exp $ */ /** * structure of L2TP Attribute Value Pair (AVP) packet header @@ -83,13 +83,13 @@ avp_set_val32(struct l2tp_avp *avp, uint32_t val) static inline int short_cmp(const void *m, const void *n) { - return (int)((int)m - (int)n); + return ((intptr_t)m - (intptr_t)n); } static inline uint32_t short_hash(const void *v, int sz) { - return (int)v % sz; + return ((uintptr_t)v % sz); } /* diff --git a/usr.sbin/npppd/l2tp/l2tpd.c b/usr.sbin/npppd/l2tp/l2tpd.c index 9a2580000fc..36efccb2c34 100644 --- a/usr.sbin/npppd/l2tp/l2tpd.c +++ b/usr.sbin/npppd/l2tp/l2tpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: l2tpd.c,v 1.6 2011/03/16 09:49:11 okan Exp $ */ +/* $OpenBSD: l2tpd.c,v 1.7 2012/01/18 02:53:56 yasuoka Exp $ */ /*- * Copyright (c) 2009 Internet Initiative Japan Inc. @@ -26,7 +26,7 @@ * SUCH DAMAGE. */ /**@file L2TP(Layer Two Tunneling Protocol "L2TP") / RFC2661 */ -/* $Id: l2tpd.c,v 1.6 2011/03/16 09:49:11 okan Exp $ */ +/* $Id: l2tpd.c,v 1.7 2012/01/18 02:53:56 yasuoka Exp $ */ #include <sys/types.h> #include <sys/socket.h> #include <sys/time.h> @@ -80,7 +80,7 @@ static inline int short_cmp (const void *, const void *); static inline uint32_t short_hash (const void *, int); /* sequence # of l2tpd ID */ -static unsigned l2tpd_id_seq = 0; +static u_int l2tpd_id_seq = 0; #ifndef USE_LIBSOCKUTIL struct in_ipsec_sa_cookie { }; @@ -99,7 +99,8 @@ struct in_ipsec_sa_cookie { }; int l2tpd_init(l2tpd *_this) { - int i, id, off; + int i, off; + u_int id; struct sockaddr_in sin4; struct sockaddr_in6 sin6; @@ -143,8 +144,8 @@ l2tpd_init(l2tpd *_this) id = (i + off) % L2TP_SESSION_ID_MASK; if (id == 0) id = (off - 1) % L2TP_SESSION_ID_MASK; - if (slist_add(&_this->free_session_id_list, (void *)id) - == NULL) { + if (slist_add(&_this->free_session_id_list, + (void *)(uintptr_t)id) == NULL) { l2tpd_log(_this, LOG_ERR, "slist_add() failed on %s(): %m", __func__); return 1; @@ -254,11 +255,12 @@ l2tpd_uninit(l2tpd *_this) int l2tpd_assign_call(l2tpd *_this, l2tp_call *call) { - int shuffle_cnt, session_id; + int shuffle_cnt; + u_int session_id; shuffle_cnt = 0; do { - session_id = (int)slist_remove_first( + session_id = (uintptr_t)slist_remove_first( &_this->free_session_id_list); if (session_id != L2TP_SESSION_ID_SHUFFLE_MARK) break; @@ -284,7 +286,7 @@ l2tpd_assign_call(l2tpd *_this, l2tp_call *call) void l2tpd_release_call(l2tpd *_this, l2tp_call *call) { - slist_add(&_this->free_session_id_list, (void *)call->id); + slist_add(&_this->free_session_id_list, (void *)(uintptr_t)call->id); } @@ -861,11 +863,11 @@ l2tpd_io_event(int fd, short evtype, void *ctx) * L2TP control */ l2tp_ctrl * -l2tpd_get_ctrl(l2tpd *_this, int tunid) +l2tpd_get_ctrl(l2tpd *_this, unsigned tunid) { hash_link *hl; - hl = hash_lookup(_this->ctrl_map, (void *)tunid); + hl = hash_lookup(_this->ctrl_map, (void *)(uintptr_t)tunid); if (hl == NULL) return NULL; @@ -875,13 +877,13 @@ l2tpd_get_ctrl(l2tpd *_this, int tunid) void l2tpd_add_ctrl(l2tpd *_this, l2tp_ctrl *ctrl) { - hash_insert(_this->ctrl_map, (void *)ctrl->tunnel_id, ctrl); + hash_insert(_this->ctrl_map, (void *)(uintptr_t)ctrl->tunnel_id, ctrl); } void -l2tpd_remove_ctrl(l2tpd *_this, int tunid) +l2tpd_remove_ctrl(l2tpd *_this, unsigned tunid) { - hash_delete(_this->ctrl_map, (void *)tunid, 0); + hash_delete(_this->ctrl_map, (void *)(uintptr_t)tunid, 0); } diff --git a/usr.sbin/npppd/npppd/npppd.c b/usr.sbin/npppd/npppd/npppd.c index 6fbf4a18167..3f39ffebee0 100644 --- a/usr.sbin/npppd/npppd/npppd.c +++ b/usr.sbin/npppd/npppd/npppd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: npppd.c,v 1.12 2011/07/08 06:14:54 yasuoka Exp $ */ +/* $OpenBSD: npppd.c,v 1.13 2012/01/18 02:53:56 yasuoka Exp $ */ /*- * Copyright (c) 2009 Internet Initiative Japan Inc. @@ -29,7 +29,7 @@ * Next pppd(nppd). This file provides a npppd daemon process and operations * for npppd instance. * @author Yasuoka Masahiko - * $Id: npppd.c,v 1.12 2011/07/08 06:14:54 yasuoka Exp $ + * $Id: npppd.c,v 1.13 2012/01/18 02:53:56 yasuoka Exp $ */ #include <sys/cdefs.h> #include "version.h" @@ -1258,7 +1258,7 @@ pipex_periodic(npppd *_this) } for (i = 0; i < req.plr_ppp_id_count; i++) { ppp_id = req.plr_ppp_id[i]; - slist_add(&dlist, (void *)ppp_id); + slist_add(&dlist, (void *)(uintptr_t)ppp_id); } } while (req.plr_flags & PIPEX_LISTREQ_MORE); @@ -1275,7 +1275,7 @@ pipex_periodic(npppd *_this) slist_itr_first(&dlist); while (slist_itr_has_next(&dlist)) { /* FIXME: Linear search by PPP Id eats CPU */ - ppp_id = (int)slist_itr_next(&dlist); + ppp_id = (uintptr_t)slist_itr_next(&dlist); slist_itr_first(&users); ppp = NULL; while (slist_itr_has_next(&users)) { diff --git a/usr.sbin/npppd/npppd/npppd_pool.c b/usr.sbin/npppd/npppd/npppd_pool.c index cb71cb18cdd..e97a7515b50 100644 --- a/usr.sbin/npppd/npppd/npppd_pool.c +++ b/usr.sbin/npppd/npppd/npppd_pool.c @@ -1,4 +1,4 @@ -/* $OpenBSD: npppd_pool.c,v 1.4 2010/07/20 20:47:17 miod Exp $ */ +/* $OpenBSD: npppd_pool.c,v 1.5 2012/01/18 02:53:56 yasuoka Exp $ */ /*- * Copyright (c) 2009 Internet Initiative Japan Inc. @@ -231,8 +231,8 @@ npppd_pool_reload(npppd_pool *_this) continue; if (count >= NPPPD_MAX_POOLED_ADDRS) break; - slist_add(&_this->dyna_addrs, (void *) - (range->addr + i)); + slist_add(&_this->dyna_addrs, + (void *)(uintptr_t)(range->addr + i)); count++; } } @@ -323,7 +323,7 @@ uint32_t npppd_pool_get_dynamic(npppd_pool *_this, npppd_ppp *ppp) { int shuffle_cnt; - void *result = NULL; + uintptr_t result = 0; struct sockaddr_in sin4 = { .sin_len = sizeof(struct sockaddr_in), .sin_family = AF_INET @@ -335,8 +335,8 @@ npppd_pool_get_dynamic(npppd_pool *_this, npppd_ppp *ppp) slist_itr_first(&_this->dyna_addrs); while (slist_length(&_this->dyna_addrs) > 1 && slist_itr_has_next(&_this->dyna_addrs)) { - result = slist_itr_next(&_this->dyna_addrs); - if (result == NULL) + result = (uintptr_t)slist_itr_next(&_this->dyna_addrs); + if (result == 0) break; /* shuffle */ if ((uint32_t)result == SHUFLLE_MARK) { @@ -346,13 +346,13 @@ npppd_pool_get_dynamic(npppd_pool *_this, npppd_ppp *ppp) * If succeed to get address twice, it means no address to use. */ if (shuffle_cnt++ > 0) { - result = NULL; + result = 0; break; } NPPPD_POOL_DBG((_this, LOG_DEBUG, "shuffle")); slist_itr_remove(&_this->dyna_addrs); slist_shuffle(&_this->dyna_addrs); - slist_add(&_this->dyna_addrs, result); + slist_add(&_this->dyna_addrs, (void *)result); slist_itr_first(&_this->dyna_addrs); continue; } @@ -426,8 +426,7 @@ npppd_pool_assign_ip(npppd_pool *_this, npppd_ppp *ppp) /* If the address contains dynamic pool address list, delete it. */ slist_itr_first(&_this->dyna_addrs); while (slist_itr_has_next(&_this->dyna_addrs)) { - if ((uint32_t)slist_itr_next( - &_this->dyna_addrs) != ip4) + if ((uintptr_t)slist_itr_next(&_this->dyna_addrs) != ip4) continue; slist_itr_remove(&_this->dyna_addrs); break; @@ -499,7 +498,8 @@ npppd_pool_release_ip(npppd_pool *_this, npppd_ppp *ppp) if (_this != NULL && ppp->assign_dynapool != 0) /* return to dynamic address pool list */ slist_add(&((npppd_pool *)ppp->assigned_pool)->dyna_addrs, - (void *)ntohl(ppp->ppp_framed_ip_address.s_addr)); + (void *)(uintptr_t)ntohl( + ppp->ppp_framed_ip_address.s_addr)); if (snp != NULL && snp->snp_next != NULL) { /* diff --git a/usr.sbin/npppd/npppd/npppd_radius.c b/usr.sbin/npppd/npppd/npppd_radius.c index ccdde2c3317..e1356b66ee0 100644 --- a/usr.sbin/npppd/npppd/npppd_radius.c +++ b/usr.sbin/npppd/npppd/npppd_radius.c @@ -1,4 +1,4 @@ -/* $Id: npppd_radius.c,v 1.1 2011/07/06 20:52:28 yasuoka Exp $ */ +/* $Id: npppd_radius.c,v 1.2 2012/01/18 02:53:56 yasuoka Exp $ */ /*- * Copyright (c) 2009 Internet Initiative Japan Inc. * All rights reserved. @@ -120,7 +120,7 @@ npppd_ppp_radius_acct_reqcb(void *context, RADIUS_PACKET *pkt, int flags, { int ppp_id; - ppp_id = (int)context; + ppp_id = (uintptr_t)context; if ((flags & RADIUS_REQUEST_TIMEOUT) != 0) { log_printf(LOG_WARNING, "ppp id=%d radius accounting request " "failed: no response from the server.", ppp_id); @@ -151,7 +151,7 @@ npppd_ppp_radius_acct_reqcb(void *context, RADIUS_PACKET *pkt, int flags, sbuf, sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV) != 0) { strlcpy(hbuf, "unknown", sizeof(hbuf)); - strlcpy(sbuf, "", sizeof(hbuf)); + strlcpy(sbuf, "", sizeof(sbuf)); } log_printf(LOG_DEBUG, "ppp id=%d " "fail over to %s:%s for radius accounting request", @@ -198,7 +198,7 @@ radius_acct_request(npppd *pppd, npppd_ppp *ppp, int stop) == NULL) goto reigai; - if (radius_prepare(rad_setting, (void *)ppp->id, &radctx, + if (radius_prepare(rad_setting, (void *)(uintptr_t)ppp->id, &radctx, npppd_ppp_radius_acct_reqcb, 0) != 0) goto reigai; diff --git a/usr.sbin/npppd/npppd/ppp.c b/usr.sbin/npppd/npppd/ppp.c index 68c4aa210c5..2b205863970 100644 --- a/usr.sbin/npppd/npppd/ppp.c +++ b/usr.sbin/npppd/npppd/ppp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ppp.c,v 1.9 2011/10/15 03:24:11 yasuoka Exp $ */ +/* $OpenBSD: ppp.c,v 1.10 2012/01/18 02:53:56 yasuoka Exp $ */ /*- * Copyright (c) 2009 Internet Initiative Japan Inc. @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -/* $Id: ppp.c,v 1.9 2011/10/15 03:24:11 yasuoka Exp $ */ +/* $Id: ppp.c,v 1.10 2012/01/18 02:53:56 yasuoka Exp $ */ /**@file * This file provides PPP(Point-to-Point Protocol, RFC 1661) and * {@link :: _npppd_ppp PPP instance} related functions. @@ -388,14 +388,15 @@ ppp_stop0(npppd_ppp *_this) snprintf(mppe_str, sizeof(mppe_str), "mppe=no"); ppp_log(_this, LOG_NOTICE, "logtype=TUNNELUSAGE user=\"%s\" duration=%ldsec layer2=%s " - "layer2from=%s auth=%s data_in=%qubytes,%upackets " - "data_out=%qubytes,%upackets error_in=%u error_out=%u %s " + "layer2from=%s auth=%s data_in=%llubytes,%upackets " + "data_out=%llubytes,%upackets error_in=%u error_out=%u %s " "iface=%s", _this->username[0]? _this->username : "<unknown>", (long)(_this->end_monotime - _this->start_monotime), _this->phy_label, label, _this->username[0]? ppp_peer_auth_string(_this) : "none", - _this->ibytes, _this->ipackets, _this->obytes, _this->opackets, + (unsigned long long)_this->ibytes, _this->ipackets, + (unsigned long long)_this->obytes, _this->opackets, _this->ierrors, _this->oerrors, mppe_str, npppd_ppp_get_iface_name(_this->pppd, _this)); diff --git a/usr.sbin/npppd/npppd/radius+.c b/usr.sbin/npppd/npppd/radius+.c index bf37cb7a19f..91dbf873547 100644 --- a/usr.sbin/npppd/npppd/radius+.c +++ b/usr.sbin/npppd/npppd/radius+.c @@ -1,4 +1,4 @@ -/* $OpenBSD: radius+.c,v 1.4 2011/07/06 20:52:28 yasuoka Exp $ */ +/* $OpenBSD: radius+.c,v 1.5 2012/01/18 02:53:56 yasuoka Exp $ */ /*- * Copyright (c) 2009 Internet Initiative Japan Inc. @@ -821,7 +821,8 @@ int radius_put_message_authenticator(RADIUS_PACKET *packet, const char *secret) { if (attr->type == RADIUS_TYPE_MESSAGE_AUTHENTICATOR) { - memcpy(attr->data, md5result, sizeof(md5result)); + memcpy((u_char *)&attr->data[0], md5result, + sizeof(md5result)); break; } } diff --git a/usr.sbin/npppd/pppoe/pppoe_session.c b/usr.sbin/npppd/pppoe/pppoe_session.c index 79212a24cf2..4816c997a49 100644 --- a/usr.sbin/npppd/pppoe/pppoe_session.c +++ b/usr.sbin/npppd/pppoe/pppoe_session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pppoe_session.c,v 1.4 2011/03/16 09:48:45 okan Exp $ */ +/* $OpenBSD: pppoe_session.c,v 1.5 2012/01/18 02:53:56 yasuoka Exp $ */ /*- * Copyright (c) 2009 Internet Initiative Japan Inc. @@ -28,7 +28,7 @@ /**@file * Session management of PPPoE protocol - * $Id: pppoe_session.c,v 1.4 2011/03/16 09:48:45 okan Exp $ + * $Id: pppoe_session.c,v 1.5 2012/01/18 02:53:56 yasuoka Exp $ */ #include <sys/types.h> @@ -385,8 +385,8 @@ pppoe_session_recv_PADR(pppoe_session *_this, slist *tag_list) goto fail; _this->acookie = *(uint32_t *)(ac_cookie->value); - hash_insert(pppoed0->acookie_hash, (void *)_this->acookie, - _this); + hash_insert(pppoed0->acookie_hash, + (void *)(intptr_t)_this->acookie, _this); } if (pppoe_session_send_PADS(_this, hostuniq, service_name) != 0) diff --git a/usr.sbin/npppd/pppoe/pppoed.c b/usr.sbin/npppd/pppoe/pppoed.c index 0c975c87313..f8efdf60064 100644 --- a/usr.sbin/npppd/pppoe/pppoed.c +++ b/usr.sbin/npppd/pppoe/pppoed.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pppoed.c,v 1.7 2011/02/28 02:31:55 dlg Exp $ */ +/* $OpenBSD: pppoed.c,v 1.8 2012/01/18 02:53:56 yasuoka Exp $ */ /*- * Copyright (c) 2009 Internet Initiative Japan Inc. @@ -28,7 +28,7 @@ /**@file * This file provides the PPPoE(RFC2516) server(access concentrator) * implementaion. - * $Id: pppoed.c,v 1.7 2011/02/28 02:31:55 dlg Exp $ + * $Id: pppoed.c,v 1.8 2012/01/18 02:53:56 yasuoka Exp $ */ #include <sys/types.h> #include <sys/param.h> @@ -153,7 +153,8 @@ pppoed_init(pppoed *_this) id = (i + off) % 0xffff; if (id == 0) id = (off - 1) % 0xffff; - if (slist_add(&_this->session_free_list, (void *)id) == NULL) { + if (slist_add(&_this->session_free_list, (void *)(intptr_t)id) + == NULL) { pppoed_log(_this, LOG_ERR, "slist_add() failed on %s(): %m", __func__); goto fail; @@ -448,13 +449,15 @@ pppoed_uninit(pppoed *_this) void pppoed_pppoe_session_close_notify(pppoed *_this, pppoe_session *session) { - slist_add(&_this->session_free_list, (void *)session->session_id); + slist_add(&_this->session_free_list, + (void *)(intptr_t)session->session_id); if (_this->acookie_hash != NULL) - hash_delete(_this->acookie_hash, (void *)session->acookie, 0); + hash_delete(_this->acookie_hash, + (void *)(intptr_t)session->acookie, 0); if (_this->session_hash != NULL) - hash_delete(_this->session_hash, (void *)session->session_id, - 0); + hash_delete(_this->session_hash, + (void *)(intptr_t)session->session_id, 0); pppoe_session_fini(session); free(session); @@ -776,7 +779,8 @@ pppoed_input(pppoed_listener *_this, uint8_t shost[ETHER_ADDR_LEN], int is_disc, } if (session_id != 0) { - hl = hash_lookup(_this->self->session_hash, (void *)session_id); + hl = hash_lookup(_this->self->session_hash, + (void *)(intptr_t)session_id); if (hl != NULL) session = (pppoe_session *)hl->item; } @@ -916,7 +920,7 @@ pppoed_recv_PADR(pppoed_listener *_this, uint8_t shost[ETHER_ADDR_LEN], /* create session_id */ shuffle_cnt = 0; do { - session_id = (int)slist_remove_first( + session_id = (intptr_t)slist_remove_first( &_pppoed->session_free_list); if (session_id != PPPOED_SESSION_SHUFFLE_MARK) break; @@ -938,7 +942,8 @@ pppoed_recv_PADR(pppoed_listener *_this, uint8_t shost[ETHER_ADDR_LEN], shost) != 0) goto fail; - hash_insert(_pppoed->session_hash, (void *)session_id, session); + hash_insert(_pppoed->session_hash, (void *)(intptr_t)session_id, + session); if (pppoe_session_recv_PADR(session, tag_list) != 0) goto fail; @@ -1070,7 +1075,7 @@ pppoed_recv_PADI(pppoed_listener *_this, uint8_t shost[ETHER_ADDR_LEN], _this->self->acookie_next += 1; } while(hash_lookup(_this->self->acookie_hash, - (void *)_this->self->acookie_next) != NULL); + (void *)(intptr_t)_this->self->acookie_next) != NULL); tlv.type = htons(PPPOE_TAG_AC_COOKIE); tlv.length = ntohs(sizeof(uint32_t)); @@ -1201,8 +1206,8 @@ session_id_cmp(void *a, void *b) { int ia, ib; - ia = (int)a; - ib = (int)b; + ia = (intptr_t)a; + ib = (intptr_t)b; return ib - ia; } @@ -1212,7 +1217,7 @@ session_id_hash(void *a, size_t siz) { int ia; - ia = (int)a; + ia = (intptr_t)a; return ia % siz; } diff --git a/usr.sbin/npppd/pptp/pptpd.c b/usr.sbin/npppd/pptp/pptpd.c index fbe708a7f2f..fd6cd8e921a 100644 --- a/usr.sbin/npppd/pptp/pptpd.c +++ b/usr.sbin/npppd/pptp/pptpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pptpd.c,v 1.8 2011/01/20 23:12:33 jasper Exp $ */ +/* $OpenBSD: pptpd.c,v 1.9 2012/01/18 02:53:56 yasuoka Exp $ */ /*- * Copyright (c) 2009 Internet Initiative Japan Inc. @@ -25,12 +25,12 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -/* $Id: pptpd.c,v 1.8 2011/01/20 23:12:33 jasper Exp $ */ +/* $Id: pptpd.c,v 1.9 2012/01/18 02:53:56 yasuoka Exp $ */ /**@file * This file provides a implementation of PPTP daemon. Currently it * provides functions for PAC (PPTP Access Concentrator) only. - * $Id: pptpd.c,v 1.8 2011/01/20 23:12:33 jasper Exp $ + * $Id: pptpd.c,v 1.9 2012/01/18 02:53:56 yasuoka Exp $ */ #include <sys/types.h> #include <sys/param.h> @@ -245,20 +245,21 @@ pptpd_uninit(pptpd *_this) _this->config = NULL; } -#define CALL_MAP_KEY(call) \ - (void *)(call->id | (call->ctrl->listener_index << 16)) -#define CALL_ID(item) ((uint32_t)item & 0xffff) - +#define CALL_ID_KEY(call_id, listener_idx) \ + ((void *)((uintptr_t)(call_id) | (listener_idx) << 16)) +#define CALL_KEY(call) \ + CALL_ID_KEY((call)->id, (call)->ctrl->listener_index) int pptpd_assign_call(pptpd *_this, pptp_call *call) { - int shuffle_cnt = 0, call_id; + int shuffle_cnt = 0; + u_int call_id; shuffle_cnt = 0; slist_itr_first(&_this->call_free_list); while (slist_length(&_this->call_free_list) > 1 && slist_itr_has_next(&_this->call_free_list)) { - call_id = (int)slist_itr_next(&_this->call_free_list); + call_id = (uintptr_t)slist_itr_next(&_this->call_free_list); if (call_id == 0) break; slist_itr_remove(&_this->call_free_list); @@ -272,7 +273,7 @@ pptpd_assign_call(pptpd *_this, pptp_call *call) continue; } call->id = call_id; - hash_insert(_this->call_id_map, CALL_MAP_KEY(call), call); + hash_insert(_this->call_id_map, CALL_KEY(call), call); return 0; } @@ -286,8 +287,8 @@ void pptpd_release_call(pptpd *_this, pptp_call *call) { if (call->id != 0) - slist_add(&_this->call_free_list, (void *)call->id); - hash_delete(_this->call_id_map, CALL_MAP_KEY(call), 0); + slist_add(&_this->call_free_list, (void *)(uintptr_t)call->id); + hash_delete(_this->call_id_map, CALL_KEY(call), 0); call->id = 0; } @@ -951,8 +952,7 @@ pptpd_gre_input(pptpd_listener *listener, struct sockaddr *peer, u_char *pkt, /* route to pptp_call */ call_id = grehdr->call_id; - hl = hash_lookup(_this->call_id_map, - (void *)(call_id | (listener->index << 16))); + hl = hash_lookup(_this->call_id_map, CALL_ID_KEY(call_id, listener->index)); if (hl == NULL) { reason = "Received GRE packet has unknown call_id"; goto bad_gre; @@ -1095,13 +1095,13 @@ pptpd_log(pptpd *_this, int prio, const char *fmt, ...) static int pptp_call_cmp(const void *a0, const void *b0) { - return ((uint32_t)a0 - (uint32_t)b0); + return ((intptr_t)a0 - (intptr_t)b0); } static uint32_t pptp_call_hash(const void *ctx, int size) { - return (uint32_t)ctx % size; + return (uintptr_t)ctx % size; } /* convert GRE packet header to strings */ |