RTEMS CPU Kit with SuperCore  4.11.3
Macros | Functions | Variables
ipcp.c File Reference
#include <stdio.h>
#include <string.h>
#include <netdb.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <resolv.h>
#include "pppd.h"
#include "fsm.h"
#include "ipcp.h"
#include "pathnames.h"
#include <rtems/bsdnet/servers.h>
Include dependency graph for ipcp.c:

Macros

#define RCSID   "$Id$"
 
#define CILEN_VOID   2
 
#define CILEN_COMPRESS   4 /* min length for compression protocol opt. */
 
#define CILEN_VJ   6 /* length for RFC1332 Van-Jacobson opt. */
 
#define CILEN_ADDR   6 /* new-style single address option */
 
#define CILEN_ADDRS   10 /* old-style dual address option */
 
#define CODENAME(x)
 
#define LENCIVJ(neg, old)   (neg ? (old? CILEN_COMPRESS : CILEN_VJ) : 0)
 
#define LENCIADDR(neg, old)   (neg ? (old? CILEN_ADDRS : CILEN_ADDR) : 0)
 
#define LENCIDNS(neg)   (neg ? (CILEN_ADDR) : 0)
 
#define ADDCIVJ(opt, neg, val, old, maxslotindex, cflag)
 
#define ADDCIADDR(opt, neg, old, val1, val2)
 
#define ADDCIDNS(opt, neg, addr)
 
#define ACKCIVJ(opt, neg, val, old, maxslotindex, cflag)
 
#define ACKCIADDR(opt, neg, old, val1, val2)
 
#define ACKCIDNS(opt, neg, addr)
 
#define NAKCIADDR(opt, neg, old, code)
 
#define NAKCIVJ(opt, neg, code)
 
#define NAKCIDNS(opt, neg, code)
 
#define REJCIADDR(opt, neg, old, val1, val2)
 
#define REJCIVJ(opt, neg, val, old, maxslot, cflag)
 
#define REJCIDNS(opt, neg, dnsaddr)
 
#define IP_HDRLEN   20 /* bytes */
 
#define IP_OFFMASK   0x1fff
 
#define IPPROTO_TCP   6
 
#define TCP_HDRLEN   20
 
#define TH_FIN   0x01
 
#define net_short(x)   (((x)[0] << 8) + (x)[1])
 
#define get_iphl(x)   (((unsigned char *)(x))[0] & 0xF)
 
#define get_ipoff(x)   net_short((unsigned char *)(x) + 6)
 
#define get_ipproto(x)   (((unsigned char *)(x))[9])
 
#define get_tcpoff(x)   (((unsigned char *)(x))[12] >> 4)
 
#define get_tcpflags(x)   (((unsigned char *)(x))[13])
 

Functions

char * ip_ntoa (uint32_t ipaddr)
 

Variables

ipcp_options ipcp_wantoptions [NUM_PPP]
 
ipcp_options ipcp_gotoptions [NUM_PPP]
 
ipcp_options ipcp_allowoptions [NUM_PPP]
 
ipcp_options ipcp_hisoptions [NUM_PPP]
 
bool disable_defaultip = 0
 
void(* ip_up_hook )(void) = NULL
 
void(* ip_down_hook )(void) = NULL
 
fsm ipcp_fsm [NUM_PPP]
 
struct protent ipcp_protent
 

Macro Definition Documentation

◆ ACKCIADDR

#define ACKCIADDR (   opt,
  neg,
  old,
  val1,
  val2 
)
Value:
if (neg) { \
int addrlen = (old? CILEN_ADDRS: CILEN_ADDR); \
uint32_t l; \
if ((len -= addrlen) < 0) \
goto bad; \
GETCHAR(citype, p); \
GETCHAR(cilen, p); \
if (cilen != addrlen || \
citype != opt) \
goto bad; \
GETLONG(l, p); \
cilong = htonl(l); \
if (val1 != cilong) \
goto bad; \
if (old) { \
GETLONG(l, p); \
cilong = htonl(l); \
if (val2 != cilong) \
goto bad; \
} \
}

◆ ACKCIDNS

#define ACKCIDNS (   opt,
  neg,
  addr 
)
Value:
if (neg) { \
uint32_t l; \
if ((len -= CILEN_ADDR) < 0) \
goto bad; \
GETCHAR(citype, p); \
GETCHAR(cilen, p); \
if (cilen != CILEN_ADDR || citype != opt) \
goto bad; \
GETLONG(l, p); \
cilong = htonl(l); \
if (addr != cilong) \
goto bad; \
}

◆ ACKCIVJ

#define ACKCIVJ (   opt,
  neg,
  val,
  old,
  maxslotindex,
  cflag 
)
Value:
if (neg) { \
int vjlen = old? CILEN_COMPRESS : CILEN_VJ; \
if ((len -= vjlen) < 0) \
goto bad; \
GETCHAR(citype, p); \
GETCHAR(cilen, p); \
if (cilen != vjlen || \
citype != opt) \
goto bad; \
GETSHORT(cishort, p); \
if (cishort != val) \
goto bad; \
if (!old) { \
GETCHAR(cimaxslotindex, p); \
if (cimaxslotindex != maxslotindex) \
goto bad; \
GETCHAR(cicflag, p); \
if (cicflag != cflag) \
goto bad; \
} \
}

◆ ADDCIADDR

#define ADDCIADDR (   opt,
  neg,
  old,
  val1,
  val2 
)
Value:
if (neg) { \
int addrlen = (old? CILEN_ADDRS: CILEN_ADDR); \
if (len >= addrlen) { \
uint32_t l; \
PUTCHAR(opt, ucp); \
PUTCHAR(addrlen, ucp); \
l = ntohl(val1); \
PUTLONG(l, ucp); \
if (old) { \
l = ntohl(val2); \
PUTLONG(l, ucp); \
} \
len -= addrlen; \
} else \
neg = 0; \
}

◆ ADDCIDNS

#define ADDCIDNS (   opt,
  neg,
  addr 
)
Value:
if (neg) { \
if (len >= CILEN_ADDR) { \
uint32_t l; \
PUTCHAR(opt, ucp); \
PUTCHAR(CILEN_ADDR, ucp); \
l = ntohl(addr); \
PUTLONG(l, ucp); \
len -= CILEN_ADDR; \
} else \
neg = 0; \
}

◆ ADDCIVJ

#define ADDCIVJ (   opt,
  neg,
  val,
  old,
  maxslotindex,
  cflag 
)
Value:
if (neg) { \
int vjlen = old? CILEN_COMPRESS : CILEN_VJ; \
if (len >= vjlen) { \
PUTCHAR(opt, ucp); \
PUTCHAR(vjlen, ucp); \
PUTSHORT(val, ucp); \
if (!old) { \
PUTCHAR(maxslotindex, ucp); \
PUTCHAR(cflag, ucp); \
} \
len -= vjlen; \
} else \
neg = 0; \
}

◆ CODENAME

#define CODENAME (   x)
Value:
((x) == CONFACK ? "ACK" : \
(x) == CONFNAK ? "NAK" : "REJ")

◆ NAKCIADDR

#define NAKCIADDR (   opt,
  neg,
  old,
  code 
)
Value:
if (go->neg && \
len >= (cilen = (old? CILEN_ADDRS: CILEN_ADDR)) && \
p[1] == cilen && \
p[0] == opt) { \
len -= cilen; \
INCPTR(2, p); \
GETLONG(l, p); \
ciaddr1 = htonl(l); \
if (old) { \
GETLONG(l, p); \
ciaddr2 = htonl(l); \
no.old_addrs = 1; \
} else \
ciaddr2 = 0; \
no.neg = 1; \
code \
}

◆ NAKCIDNS

#define NAKCIDNS (   opt,
  neg,
  code 
)
Value:
if (go->neg && \
((cilen = p[1]) == CILEN_ADDR) && \
len >= cilen && \
p[0] == opt) { \
len -= cilen; \
INCPTR(2, p); \
GETLONG(l, p); \
cidnsaddr = htonl(l); \
no.neg = 1; \
code \
}

◆ NAKCIVJ

#define NAKCIVJ (   opt,
  neg,
  code 
)
Value:
if (go->neg && \
((cilen = p[1]) == CILEN_COMPRESS || cilen == CILEN_VJ) && \
len >= cilen && \
p[0] == opt) { \
len -= cilen; \
INCPTR(2, p); \
GETSHORT(cishort, p); \
no.neg = 1; \
code \
}

◆ REJCIADDR

#define REJCIADDR (   opt,
  neg,
  old,
  val1,
  val2 
)
Value:
if (go->neg && \
len >= (cilen = old? CILEN_ADDRS: CILEN_ADDR) && \
p[1] == cilen && \
p[0] == opt) { \
uint32_t l; \
len -= cilen; \
INCPTR(2, p); \
GETLONG(l, p); \
cilong = htonl(l); \
/* Check rejected value. */ \
if (cilong != val1) \
goto bad; \
if (old) { \
GETLONG(l, p); \
cilong = htonl(l); \
/* Check rejected value. */ \
if (cilong != val2) \
goto bad; \
} \
try.neg = 0; \
}

◆ REJCIDNS

#define REJCIDNS (   opt,
  neg,
  dnsaddr 
)
Value:
if (go->neg && \
((cilen = p[1]) == CILEN_ADDR) && \
len >= cilen && \
p[0] == opt) { \
uint32_t l; \
len -= cilen; \
INCPTR(2, p); \
GETLONG(l, p); \
cilong = htonl(l); \
/* Check rejected value. */ \
if (cilong != dnsaddr) \
goto bad; \
try.neg = 0; \
}

◆ REJCIVJ

#define REJCIVJ (   opt,
  neg,
  val,
  old,
  maxslot,
  cflag 
)
Value:
if (go->neg && \
p[1] == (old? CILEN_COMPRESS : CILEN_VJ) && \
len >= p[1] && \
p[0] == opt) { \
len -= p[1]; \
INCPTR(2, p); \
GETSHORT(cishort, p); \
/* Check rejected value. */ \
if (cishort != val) \
goto bad; \
if (!old) { \
GETCHAR(cimaxslotindex, p); \
if (cimaxslotindex != maxslot) \
goto bad; \
GETCHAR(ciflag, p); \
if (ciflag != cflag) \
goto bad; \
} \
try.neg = 0; \
}

Variable Documentation

◆ ipcp_protent

struct protent ipcp_protent
Initial value:
= {
PPP_IPCP,
ipcp_init,
ipcp_input,
ipcp_protrej,
ipcp_lowerup,
ipcp_lowerdown,
ipcp_open,
ipcp_close,
ipcp_printpkt,
NULL,
1,
"IPCP",
"IP",
ipcp_option_list,
ip_check_options,
ip_demand_conf,
ip_active_pkt
}