diff options
author | YASUOKA Masahiko <yasuoka@cvs.openbsd.org> | 2012-09-19 17:50:18 +0000 |
---|---|---|
committer | YASUOKA Masahiko <yasuoka@cvs.openbsd.org> | 2012-09-19 17:50:18 +0000 |
commit | dc0d522f7aed69a5d09f5804a3bfe980fe6b418a (patch) | |
tree | ab959eba7ad241cbab5597a63da71a910b9f9b21 /sys/net | |
parent | e07638478523e3044e34296f59801b5f97c65c4e (diff) |
cleanup around the pipex. naming style, delete or update comments.
no functional changes.
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/if_pppx.c | 30 | ||||
-rw-r--r-- | sys/net/pipex.c | 51 | ||||
-rw-r--r-- | sys/net/pipex.h | 79 | ||||
-rw-r--r-- | sys/net/pipex_local.h | 6 |
4 files changed, 80 insertions, 86 deletions
diff --git a/sys/net/if_pppx.c b/sys/net/if_pppx.c index 94ed47f17b8..755a433158f 100644 --- a/sys/net/if_pppx.c +++ b/sys/net/if_pppx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pppx.c,v 1.14 2012/04/14 09:39:47 yasuoka Exp $ */ +/* $OpenBSD: if_pppx.c,v 1.15 2012/09/19 17:50:17 yasuoka Exp $ */ /* * Copyright (c) 2010 Claudio Jeker <claudio@openbsd.org> @@ -683,7 +683,7 @@ pppx_add_session(struct pppx_dev *pxd, struct pipex_session_req *req) over_ifp = ifunit(req->pr_proto.pppoe.over_ifname); if (over_ifp == NULL) return (EINVAL); - if (req->peer_address.ss_family != AF_UNSPEC) + if (req->pr_peer_address.ss_family != AF_UNSPEC) return (EINVAL); break; #endif @@ -693,24 +693,24 @@ pppx_add_session(struct pppx_dev *pxd, struct pipex_session_req *req) #ifdef PIPEX_L2TP case PIPEX_PROTO_L2TP: #endif - switch (req->peer_address.ss_family) { + switch (req->pr_peer_address.ss_family) { case AF_INET: - if (req->peer_address.ss_len != sizeof(struct sockaddr_in)) + if (req->pr_peer_address.ss_len != sizeof(struct sockaddr_in)) return (EINVAL); break; #ifdef INET6 case AF_INET6: - if (req->peer_address.ss_len != sizeof(struct sockaddr_in6)) + if (req->pr_peer_address.ss_len != sizeof(struct sockaddr_in6)) return (EINVAL); break; #endif default: return (EPROTONOSUPPORT); } - if (req->peer_address.ss_family != - req->local_address.ss_family || - req->peer_address.ss_len != - req->local_address.ss_len) + if (req->pr_peer_address.ss_family != + req->pr_local_address.ss_family || + req->pr_peer_address.ss_len != + req->pr_local_address.ss_len) return (EINVAL); break; default: @@ -754,12 +754,12 @@ pppx_add_session(struct pppx_dev *pxd, struct pipex_session_req *req) session->ip_address.sin_addr.s_addr &= session->ip_netmask.sin_addr.s_addr; - if (req->peer_address.ss_len > 0) - memcpy(&session->peer, &req->peer_address, - MIN(req->peer_address.ss_len, sizeof(session->peer))); - if (req->local_address.ss_len > 0) - memcpy(&session->local, &req->local_address, - MIN(req->local_address.ss_len, sizeof(session->local))); + if (req->pr_peer_address.ss_len > 0) + memcpy(&session->peer, &req->pr_peer_address, + MIN(req->pr_peer_address.ss_len, sizeof(session->peer))); + if (req->pr_local_address.ss_len > 0) + memcpy(&session->local, &req->pr_local_address, + MIN(req->pr_local_address.ss_len, sizeof(session->local))); #ifdef PIPEX_PPPOE if (req->pr_protocol == PIPEX_PROTO_PPPOE) session->proto.pppoe.over_ifp = over_ifp; diff --git a/sys/net/pipex.c b/sys/net/pipex.c index 63a6fbd3e02..bb2cbfd9dd2 100644 --- a/sys/net/pipex.c +++ b/sys/net/pipex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pipex.c,v 1.32 2012/09/10 07:20:58 yasuoka Exp $ */ +/* $OpenBSD: pipex.c,v 1.33 2012/09/19 17:50:17 yasuoka Exp $ */ /*- * Copyright (c) 2009 Internet Initiative Japan Inc. @@ -25,9 +25,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -/* - * PIPEX(PPPAC IP Extension) - */ #include <sys/param.h> #include <sys/proc.h> @@ -152,7 +149,7 @@ pipex_iface_init(struct pipex_iface_context *pipex_iface, struct ifnet *ifp) int s; struct pipex_session *session; - pipex_iface->pipexmode = PIPEX_DISABLE; + pipex_iface->pipexmode = 0; pipex_iface->ifnet_this = ifp; s = splnet(); @@ -180,7 +177,7 @@ pipex_iface_init(struct pipex_iface_context *pipex_iface, struct ifnet *ifp) void pipex_iface_start(struct pipex_iface_context *pipex_iface) { - pipex_iface->pipexmode |= PIPEX_ENABLED; + pipex_iface->pipexmode = 1; } void @@ -191,7 +188,7 @@ pipex_iface_stop(struct pipex_iface_context *pipex_iface) int s; s = splnet(); - pipex_iface->pipexmode = PIPEX_DISABLE; + pipex_iface->pipexmode = 0; /* * traversal all pipex sessions. * it will become heavy if the number of pppac devices bocomes large. @@ -209,13 +206,13 @@ pipex_iface_stop(struct pipex_iface_context *pipex_iface) int pipex_ioctl(struct pipex_iface_context *pipex_iface, int cmd, caddr_t data) { - int mode, ret; + int pipexmode, ret; switch (cmd) { case PIPEXSMODE: - mode = *(int *)data; - if (pipex_iface->pipexmode != mode) { - if (mode == PIPEX_ENABLE) + pipexmode = *(int *)data; + if (pipex_iface->pipexmode != pipexmode) { + if (pipexmode) pipex_iface_start(pipex_iface); else pipex_iface_stop(pipex_iface); @@ -272,7 +269,7 @@ pipex_add_session(struct pipex_session_req *req, #endif /* Checks requeted parameters. */ - if (iface->pipexmode != PIPEX_ENABLE) + if (!iface->pipexmode) return (ENXIO); switch (req->pr_protocol) { #ifdef PIPEX_PPPOE @@ -280,7 +277,7 @@ pipex_add_session(struct pipex_session_req *req, over_ifp = ifunit(req->pr_proto.pppoe.over_ifname); if (over_ifp == NULL) return (EINVAL); - if (req->peer_address.ss_family != AF_UNSPEC) + if (req->pr_peer_address.ss_family != AF_UNSPEC) return (EINVAL); break; #endif @@ -291,24 +288,26 @@ pipex_add_session(struct pipex_session_req *req, #ifdef PIPEX_L2TP case PIPEX_PROTO_L2TP: #endif - switch (req->peer_address.ss_family) { + switch (req->pr_peer_address.ss_family) { case AF_INET: - if (req->peer_address.ss_len != sizeof(struct sockaddr_in)) + if (req->pr_peer_address.ss_len != + sizeof(struct sockaddr_in)) return (EINVAL); break; #ifdef INET6 case AF_INET6: - if (req->peer_address.ss_len != sizeof(struct sockaddr_in6)) + if (req->pr_peer_address.ss_len != + sizeof(struct sockaddr_in6)) return (EINVAL); break; #endif default: return (EPROTONOSUPPORT); } - if (req->peer_address.ss_family != - req->local_address.ss_family || - req->peer_address.ss_len != - req->local_address.ss_len) + if (req->pr_peer_address.ss_family != + req->pr_local_address.ss_family || + req->pr_peer_address.ss_len != + req->pr_local_address.ss_len) return (EINVAL); break; #endif @@ -343,12 +342,12 @@ pipex_add_session(struct pipex_session_req *req, session->ip_address.sin_addr.s_addr &= session->ip_netmask.sin_addr.s_addr; - if (req->peer_address.ss_len > 0) - memcpy(&session->peer, &req->peer_address, - MIN(req->peer_address.ss_len, sizeof(session->peer))); - if (req->local_address.ss_len > 0) - memcpy(&session->local, &req->local_address, - MIN(req->local_address.ss_len, sizeof(session->local))); + if (req->pr_peer_address.ss_len > 0) + memcpy(&session->peer, &req->pr_peer_address, + MIN(req->pr_peer_address.ss_len, sizeof(session->peer))); + if (req->pr_local_address.ss_len > 0) + memcpy(&session->local, &req->pr_local_address, + MIN(req->pr_local_address.ss_len, sizeof(session->local))); #ifdef PIPEX_PPPOE if (req->pr_protocol == PIPEX_PROTO_PPPOE) session->proto.pppoe.over_ifp = over_ifp; diff --git a/sys/net/pipex.h b/sys/net/pipex.h index c2f59881893..b9bdbe51f8e 100644 --- a/sys/net/pipex.h +++ b/sys/net/pipex.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pipex.h,v 1.13 2012/07/17 03:18:57 yasuoka Exp $ */ +/* $OpenBSD: pipex.h,v 1.14 2012/09/19 17:50:17 yasuoka Exp $ */ /* * Copyright (c) 2009 Internet Initiative Japan Inc. @@ -46,32 +46,30 @@ NULL \ } -#define PIPEX_ENABLE 1 -#define PIPEX_DISABLE 0 - -#define PIPEX_PROTO_L2TP 0x0001 /* protocol L2TP */ -#define PIPEX_PROTO_PPTP 0x0002 /* protocol pptp */ -#define PIPEX_PROTO_PPPOE 0x0003 /* protocol pppoe */ +#define PIPEX_PROTO_L2TP 1 /* protocol L2TP */ +#define PIPEX_PROTO_PPTP 2 /* protocol PPTP */ +#define PIPEX_PROTO_PPPOE 3 /* protocol PPPoE */ #define PIPEX_MAX_LISTREQ 128 /* list request size */ #define PIPEX_MPPE_KEYLEN 16 /* pipex_mppe */ struct pipex_mppe_req { - int16_t stateless; /* mppe key mode */ + int16_t stateless; /* mppe key mode. + 1 for stateless */ int16_t keylenbits; /* mppe key length(in bits)*/ u_char master_key[PIPEX_MPPE_KEYLEN]; /* mppe mastter key */ }; -/* pppac ip-extension forwarded statistics */ +/* pipex statistics */ struct pipex_statistics { - uint32_t ipackets; /* tunnel to network */ - uint32_t ierrors; /* tunnel to network */ - uint64_t ibytes; /* tunnel to network */ - uint32_t opackets; /* network to tunnel */ - uint32_t oerrors; /* network to tunnel */ - uint64_t obytes; /* network to tunnel */ - - uint32_t idle_time; /* idle timer */ + uint32_t ipackets; /* packets received from tunnel */ + uint32_t ierrors; /* error packets received from tunnel */ + uint64_t ibytes; /* number of received bytes from tunnel */ + uint32_t opackets; /* packets sent to tunnel */ + uint32_t oerrors; /* error packets on sending to tunnel */ + uint64_t obytes; /* number of sent bytes to tunnel */ + + uint32_t idle_time; /* idle time in seconds */ }; struct pipex_session_req { @@ -80,16 +78,16 @@ struct pipex_session_req { uint16_t pr_session_id; /* session-id */ uint16_t pr_peer_session_id; /* peer's session-id */ uint32_t pr_ppp_flags; /* PPP configuration flags */ -#define PIPEX_PPP_ACFC_ACCEPTED 0x00000001 -#define PIPEX_PPP_PFC_ACCEPTED 0x00000002 -#define PIPEX_PPP_ACFC_ENABLED 0x00000004 -#define PIPEX_PPP_PFC_ENABLED 0x00000008 -#define PIPEX_PPP_MPPE_ACCEPTED 0x00000010 -#define PIPEX_PPP_MPPE_ENABLED 0x00000020 -#define PIPEX_PPP_MPPE_REQUIRED 0x00000040 -#define PIPEX_PPP_HAS_ACF 0x00000080 -#define PIPEX_PPP_ADJUST_TCPMSS 0x00000100 -#define PIPEX_PPP_INGRESS_FILTER 0x00000200 +#define PIPEX_PPP_ACFC_ACCEPTED 0x0001 /* ACFC accepted */ +#define PIPEX_PPP_PFC_ACCEPTED 0x0002 /* PFC accepted */ +#define PIPEX_PPP_ACFC_ENABLED 0x0004 /* ACFC enabled */ +#define PIPEX_PPP_PFC_ENABLED 0x0008 /* PFC enabled */ +#define PIPEX_PPP_MPPE_ACCEPTED 0x0010 /* MPPE accepted */ +#define PIPEX_PPP_MPPE_ENABLED 0x0020 /* MPPE enabled */ +#define PIPEX_PPP_MPPE_REQUIRED 0x0040 /* MPPE is required */ +#define PIPEX_PPP_HAS_ACF 0x0080 /* has ACF */ +#define PIPEX_PPP_ADJUST_TCPMSS 0x0100 /* do tcpmss adjustment */ +#define PIPEX_PPP_INGRESS_FILTER 0x0200 /* do ingress filter */ int8_t pr_ccp_id; /* CCP current packet id */ int pr_ppp_id; /* PPP Id. */ uint16_t pr_peer_mru; /* Peer's MRU */ @@ -111,11 +109,9 @@ struct pipex_session_req { int peer_maxwinsz; /* peer's max window size */ } pptp; struct { - /* select protocol options: 1 for enable */ uint32_t option_flags; #define PIPEX_L2TP_USE_SEQUENCING 0x00000001 - /* session keys */ uint16_t tunnel_id; /* our tunnel-id */ uint16_t peer_tunnel_id;/* peer's tunnel-id */ uint32_t ns_nxt; /* send next */ @@ -125,28 +121,31 @@ struct pipex_session_req { uint32_t ipsecflowinfo; /* IPsec flow id for NAT-T */ } l2tp; struct { - char over_ifname[IF_NAMESIZE]; /* ethernet i/f name */ + char over_ifname[IF_NAMESIZE]; /* ethernet ifname */ } pppoe; } pr_proto; - struct sockaddr_storage peer_address; - struct sockaddr_storage local_address; - struct pipex_mppe_req pr_mppe_recv; - struct pipex_mppe_req pr_mppe_send; + struct sockaddr_storage pr_peer_address; /* peer address of tunnel */ + struct sockaddr_storage pr_local_address; /* our address of tunnel */ + struct pipex_mppe_req pr_mppe_recv; /* mppe key for receive */ + struct pipex_mppe_req pr_mppe_send; /* mppe key for send */ }; struct pipex_session_stat_req { - int psr_protocol; /* tunnel protocol */ - uint16_t psr_session_id; /* session-id */ - struct pipex_statistics psr_stat; /* statistics */ + int psr_protocol; /* tunnel protocol */ + uint16_t psr_session_id; /* session-id */ + struct pipex_statistics psr_stat; /* statistics */ +}; +struct pipex_session_close_req { + int psr_protocol; /* tunnel protocol */ + uint16_t psr_session_id; /* session-id */ + struct pipex_statistics psr_stat; /* statistics */ }; -#define pipex_session_close_req pipex_session_stat_req #define pcr_protocol psr_protocol #define pcr_session_id psr_session_id #define pcr_stat psr_stat struct pipex_session_list_req { uint8_t plr_flags; -#define PIPEX_LISTREQ_NONE 0x00 #define PIPEX_LISTREQ_MORE 0x01 int plr_ppp_id_count; /* count of PPP id */ int plr_ppp_id[PIPEX_MAX_LISTREQ]; /* PPP id */ @@ -189,7 +188,7 @@ struct pipex_session; /* pipex context for a interface. */ struct pipex_iface_context { struct ifnet *ifnet_this; /* outer interface */ - u_int pipexmode; /* pppac ipex mode */ + u_int pipexmode; /* pipex mode */ /* virtual pipex_session entry for multicast routing */ struct pipex_session *multicast_session; }; diff --git a/sys/net/pipex_local.h b/sys/net/pipex_local.h index ba9fa023773..51e1eeb1ec4 100644 --- a/sys/net/pipex_local.h +++ b/sys/net/pipex_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pipex_local.h,v 1.16 2012/07/17 03:18:57 yasuoka Exp $ */ +/* $OpenBSD: pipex_local.h,v 1.17 2012/09/19 17:50:17 yasuoka Exp $ */ /* * Copyright (c) 2009 Internet Initiative Japan Inc. @@ -41,10 +41,6 @@ #define PIPEX_ENABLED 0x0001 -#ifndef LOG_PPPAC -#define LOG_PPPAC LOG_KERN -#endif - /* compile time option constants */ #ifndef PIPEX_MAX_SESSION #define PIPEX_MAX_SESSION 512 |