Remove alignment constraints.
This commit is contained in:
parent
b652a5fa66
commit
38f2d636ca
@ -62,6 +62,7 @@
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/endian.h>
|
||||
#include <sys/errno.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
@ -572,9 +573,9 @@ ng_pptpgre_xmit(hpriv_p hpriv, item_p item)
|
||||
}
|
||||
|
||||
/* Build GRE header */
|
||||
((u_int32_t *)gre)[0] = htonl(PPTP_INIT_VALUE);
|
||||
gre->length = (m != NULL) ? htons((u_short)m->m_pkthdr.len) : 0;
|
||||
gre->cid = htons(hpriv->conf.peerCid);
|
||||
be32enc(gre, PPTP_INIT_VALUE);
|
||||
be16enc(&gre->length, (m != NULL) ? m->m_pkthdr.len : 0);
|
||||
be16enc(&gre->cid, hpriv->conf.peerCid);
|
||||
|
||||
/* Include sequence number if packet contains any data */
|
||||
if (m != NULL) {
|
||||
@ -584,13 +585,13 @@ ng_pptpgre_xmit(hpriv_p hpriv, item_p item)
|
||||
= ng_pptpgre_time();
|
||||
}
|
||||
hpriv->xmitSeq++;
|
||||
gre->data[0] = htonl(hpriv->xmitSeq);
|
||||
be32enc(&gre->data[0], hpriv->xmitSeq);
|
||||
}
|
||||
|
||||
/* Include acknowledgement (and stop send ack timer) if needed */
|
||||
if (hpriv->conf.enableAlwaysAck || hpriv->xmitAck != hpriv->recvSeq) {
|
||||
gre->hasAck = 1;
|
||||
gre->data[gre->hasSeq] = htonl(hpriv->recvSeq);
|
||||
be32enc(&gre->data[gre->hasSeq], hpriv->recvSeq);
|
||||
hpriv->xmitAck = hpriv->recvSeq;
|
||||
if (hpriv->conf.enableDelayedAck)
|
||||
ng_uncallout(&hpriv->sackTimer, hpriv->node);
|
||||
@ -705,18 +706,17 @@ ng_pptpgre_rcvdata_lower(hook_p hook, item_p item)
|
||||
|
||||
/* Sanity check packet length and GRE header bits */
|
||||
extralen = m->m_pkthdr.len
|
||||
- (iphlen + grelen + gre->hasSeq * (u_int16_t)ntohs(gre->length));
|
||||
- (iphlen + grelen + gre->hasSeq * be16dec(&gre->length));
|
||||
if (extralen < 0) {
|
||||
priv->stats.recvBadGRE++;
|
||||
ERROUT(EINVAL);
|
||||
}
|
||||
if ((ntohl(*((const u_int32_t *)gre)) & PPTP_INIT_MASK)
|
||||
!= PPTP_INIT_VALUE) {
|
||||
if ((be32dec(gre) & PPTP_INIT_MASK) != PPTP_INIT_VALUE) {
|
||||
priv->stats.recvBadGRE++;
|
||||
ERROUT(EINVAL);
|
||||
}
|
||||
|
||||
hpriv = ng_pptpgre_find_session(priv, ntohs(gre->cid));
|
||||
hpriv = ng_pptpgre_find_session(priv, be16dec(&gre->cid));
|
||||
if (hpriv == NULL || hpriv->hook == NULL || !hpriv->conf.enabled) {
|
||||
priv->stats.recvBadCID++;
|
||||
ERROUT(EINVAL);
|
||||
@ -725,7 +725,7 @@ ng_pptpgre_rcvdata_lower(hook_p hook, item_p item)
|
||||
|
||||
/* Look for peer ack */
|
||||
if (gre->hasAck) {
|
||||
const u_int32_t ack = ntohl(gre->data[gre->hasSeq]);
|
||||
const u_int32_t ack = be32dec(&gre->data[gre->hasSeq]);
|
||||
const int index = ack - hpriv->recvAck - 1;
|
||||
long sample;
|
||||
long diff;
|
||||
@ -776,7 +776,7 @@ badAck:
|
||||
|
||||
/* See if frame contains any data */
|
||||
if (gre->hasSeq) {
|
||||
const u_int32_t seq = ntohl(gre->data[0]);
|
||||
const u_int32_t seq = be32dec(&gre->data[0]);
|
||||
|
||||
/* Sanity check sequence number */
|
||||
if (PPTP_SEQ_DIFF(seq, hpriv->recvSeq) <= 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user