Deleted Added
full compact
nat_cmd.c (54912) nat_cmd.c (55353)
1/*-
2 * The code in this file was written by Eivind Eklund <perhaps@yes.no>,
3 * who places it in the public domain without restriction.
4 *
1/*-
2 * The code in this file was written by Eivind Eklund <perhaps@yes.no>,
3 * who places it in the public domain without restriction.
4 *
5 * $FreeBSD: head/usr.sbin/ppp/nat_cmd.c 54912 1999-12-20 20:29:47Z brian $
5 * $FreeBSD: head/usr.sbin/ppp/nat_cmd.c 55353 2000-01-03 20:09:23Z brian $
6 */
7
8#include <sys/param.h>
9#include <netinet/in.h>
10#include <arpa/inet.h>
11#include <netdb.h>
12#include <netinet/in_systm.h>
13#include <netinet/in.h>

--- 33 unchanged lines hidden (view full) ---

47#include "mp.h"
48#include "filter.h"
49#ifndef NORADIUS
50#include "radius.h"
51#endif
52#include "bundle.h"
53
54
6 */
7
8#include <sys/param.h>
9#include <netinet/in.h>
10#include <arpa/inet.h>
11#include <netdb.h>
12#include <netinet/in_systm.h>
13#include <netinet/in.h>

--- 33 unchanged lines hidden (view full) ---

47#include "mp.h"
48#include "filter.h"
49#ifndef NORADIUS
50#include "radius.h"
51#endif
52#include "bundle.h"
53
54
55#define NAT_EXTRABUF (13)
56
55static int StrToAddr(const char *, struct in_addr *);
56static int StrToPortRange(const char *, u_short *, u_short *, const char *);
57static int StrToAddrAndPort(const char *, struct in_addr *, u_short *,
58 u_short *, const char *);
59
60static void
61lowhigh(u_short *a, u_short *b)
62{

--- 276 unchanged lines hidden (view full) ---

339nat_LayerPush(struct bundle *bundle, struct link *l, struct mbuf *bp,
340 int pri, u_short *proto)
341{
342 if (!bundle->NatEnabled || *proto != PROTO_IP)
343 return bp;
344
345 log_Printf(LogDEBUG, "nat_LayerPush: PROTO_IP -> PROTO_IP\n");
346 m_settype(bp, MB_NATOUT);
57static int StrToAddr(const char *, struct in_addr *);
58static int StrToPortRange(const char *, u_short *, u_short *, const char *);
59static int StrToAddrAndPort(const char *, struct in_addr *, u_short *,
60 u_short *, const char *);
61
62static void
63lowhigh(u_short *a, u_short *b)
64{

--- 276 unchanged lines hidden (view full) ---

341nat_LayerPush(struct bundle *bundle, struct link *l, struct mbuf *bp,
342 int pri, u_short *proto)
343{
344 if (!bundle->NatEnabled || *proto != PROTO_IP)
345 return bp;
346
347 log_Printf(LogDEBUG, "nat_LayerPush: PROTO_IP -> PROTO_IP\n");
348 m_settype(bp, MB_NATOUT);
347 bp = m_pullup(bp);
349 /* Ensure there's a bit of extra buffer for the NAT code... */
350 bp = m_pullup(m_append(bp, NULL, NAT_EXTRABUF));
348 PacketAliasOut(MBUF_CTOP(bp), bp->m_len);
351 PacketAliasOut(MBUF_CTOP(bp), bp->m_len);
352 bp->m_len = ntohs(((struct ip *)MBUF_CTOP(bp))->ip_len);
349
350 return bp;
351}
352
353static struct mbuf *
354nat_LayerPull(struct bundle *bundle, struct link *l, struct mbuf *bp,
355 u_short *proto)
356{

--- 10 unchanged lines hidden (view full) ---

367 bp = m_pullup(bp);
368 pip = (struct ip *)MBUF_CTOP(bp);
369 piip = (struct ip *)((char *)pip + (pip->ip_hl << 2));
370
371 if (pip->ip_p == IPPROTO_IGMP ||
372 (pip->ip_p == IPPROTO_IPIP && IN_CLASSD(ntohl(piip->ip_dst.s_addr))))
373 return bp;
374
353
354 return bp;
355}
356
357static struct mbuf *
358nat_LayerPull(struct bundle *bundle, struct link *l, struct mbuf *bp,
359 u_short *proto)
360{

--- 10 unchanged lines hidden (view full) ---

371 bp = m_pullup(bp);
372 pip = (struct ip *)MBUF_CTOP(bp);
373 piip = (struct ip *)((char *)pip + (pip->ip_hl << 2));
374
375 if (pip->ip_p == IPPROTO_IGMP ||
376 (pip->ip_p == IPPROTO_IPIP && IN_CLASSD(ntohl(piip->ip_dst.s_addr))))
377 return bp;
378
379 /* Ensure there's a bit of extra buffer for the NAT code... */
380 bp = m_pullup(m_append(bp, NULL, NAT_EXTRABUF));
375 ret = PacketAliasIn(MBUF_CTOP(bp), bp->m_len);
376
377 bp->m_len = ntohs(pip->ip_len);
378 if (bp->m_len > MAX_MRU) {
379 log_Printf(LogWARN, "nat_LayerPull: Problem with IP header length (%d)\n",
380 bp->m_len);
381 m_freem(bp);
382 return NULL;

--- 37 unchanged lines hidden ---
381 ret = PacketAliasIn(MBUF_CTOP(bp), bp->m_len);
382
383 bp->m_len = ntohs(pip->ip_len);
384 if (bp->m_len > MAX_MRU) {
385 log_Printf(LogWARN, "nat_LayerPull: Problem with IP header length (%d)\n",
386 bp->m_len);
387 m_freem(bp);
388 return NULL;

--- 37 unchanged lines hidden ---