55#include <netinet/in.h>
71static void ppp_log_write(
int level,
char *
buf);
73static void ppp_vslp_printer(
void *
arg,
const char *
fmt, ...);
74static void ppp_format_packet(
const u_char *
p,
int len,
75 void (*printer) (
void *,
const char *, ...),
void *
arg);
87size_t ppp_strlcpy(
char *
dest,
const char *
src,
size_t len) {
105size_t ppp_strlcat(
char *
dest,
const char *
src,
size_t len) {
108 return dlen + ppp_strlcpy(
dest + dlen,
src, (
len > dlen?
len - dlen: 0));
120int ppp_slprintf(
char *
buf,
int buflen,
const char *
fmt, ...) {
133#define OUTCHAR(c) (buflen > 0? (--buflen, *buf++ = (c)): 0)
137 int width, prec, fillch;
139 unsigned long val = 0;
142 const unsigned char *
p;
148 static char hexchars[] =
"0123456789abcdef";
150 struct buffer_info bufinfo;
156 for (
f =
fmt; *
f !=
'%' && *
f != 0; ++
f)
194 prec = prec * 10 +
c -
'0';
271 ppp_slprintf(
num,
sizeof(
num),
"%d.%d.%d.%d", (
ip >> 24) & 0xff,
272 (
ip >> 16) & 0xff, (
ip >> 8) & 0xff,
ip & 0xff);
288 p = (
const unsigned char *)
"<NULL>";
289 if (fillch ==
'0' && prec >= 0) {
293 if (prec >= 0 &&
n > prec)
296 while (
n > 0 && buflen > 0) {
299 if (!quoted &&
c >= 0x80) {
304 if (quoted && (
c ==
'"' ||
c ==
'\\'))
306 if (
c < 0x20 || (0x7f <=
c &&
c < 0xa0)) {
310 case '\t': OUTCHAR(
't');
break;
311 case '\n': OUTCHAR(
'n');
break;
312 case '\b': OUTCHAR(
'b');
break;
313 case '\f': OUTCHAR(
'f');
break;
334 bufinfo.len = buflen + 1;
337 ppp_format_packet(
p,
n, ppp_vslp_printer, &bufinfo);
339 buflen = bufinfo.len - 1;
344 for (
n = prec;
n > 0; --
n) {
365 if (--prec <= 0 &&
val == 0)
382 if (prec >= 0 &&
len > prec)
408static void ppp_vslp_printer(
void *
arg,
const char *
fmt, ...) {
411 struct buffer_info *bi;
414 bi = (
struct buffer_info *)
arg;
415 n = ppp_vslprintf(bi->ptr, bi->len,
fmt, pvar);
436 ppp_format_packet(
p,
len, pr_log, &
level);
446static void ppp_format_packet(
const u_char *
p,
int len,
447 void (*printer) (
void *,
const char *, ...),
void *
arg) {
450 const struct protent *protp;
456 if (
proto == protp->protocol)
459 printer(
arg,
"[%s", protp->name);
460 n = (*protp->printpkt)(
p,
len, printer,
arg);
466 if (
proto == (protp->protocol & ~0x8000))
468 if (protp != 0 && protp->data_name != 0) {
469 printer(
arg,
"[%s data]", protp->data_name);
471 printer(
arg,
"%.8B ...",
p);
476 printer(
arg,
"[proto=0x%x]",
proto);
481 printer(
arg,
"%.32B ...",
p);
492static char line[256];
514 ppp_log_write(llevel,
line);
522pr_log (
void *
arg,
const char *
fmt, ...)
530 n = ppp_vslprintf(
buf,
sizeof(
buf),
fmt, pvar);
548 ppp_log_write(llevel,
line);
552 while (eol !=
NULL) {
554 ppp_log_write(llevel,
p);
572void ppp_print_string(
const u_char *
p,
int len,
void (*printer) (
void *,
const char *, ...),
void *
arg) {
578 if (
' ' <=
c &&
c <=
'~') {
579 if (
c ==
'\\' ||
c ==
'"')
581 printer(
arg,
"%c",
c);
612static void ppp_log_write(
int level,
char *
buf) {
620 if (
n > 0 &&
buf[
n-1] ==
'\n')
623 ||
write(log_to_fd,
"\n", 1) != 1)
632void ppp_fatal_impl(
const char *
fmt, ...) {
645void ppp_error_impl(
const char *
fmt, ...) {
659void ppp_warn_impl(
const char *
fmt, ...) {
670void ppp_notice_impl(
const char *
fmt, ...) {
681void ppp_info_impl(
const char *
fmt, ...) {
692void ppp_dbglog_impl(
const char *
fmt, ...) {
705void ppp_dump_packet(ppp_pcb *pcb,
const char *
tag,
unsigned char *
p,
int len) {
718 if (
proto == PPP_LCP && pcb->phase == PPP_PHASE_RUNNING &&
len >= 2 + HEADERLEN) {
719 unsigned char *lcp =
p + 2;
720 int l = (lcp[2] << 8) + lcp[3];
722 if ((lcp[0] == ECHOREQ || lcp[0] == ECHOREP)
723 &&
l >= HEADERLEN &&
l <=
len - 2)
727 ppp_dbglog((
"%s %P",
tag,
p,
len));
744 for (done = 0; done <
count; ) {
762#define LOCK_DIR "/var/lock"
765#define LOCK_DIR "/var/spool/locks"
767#define LOCK_DIR "/var/spool/lock"
786 ppp_strlcpy(lock_file,
dev,
sizeof(lock_file));
791 ppp_notice((
"Device %s is locked by pid %d",
dev,
result));
793 ppp_error((
"Can't create lock file %s", lock_file));
805 ppp_error((
"Can't get device number for %s: %m",
dev));
809 ppp_error((
"Can't lock %s: not a character device",
dev));
812 ppp_slprintf(lock_file,
sizeof(lock_file),
"%s/LK.%03d.%03d.%03d",
813 LOCK_DIR,
major(sbuf.st_dev),
831 ppp_slprintf(lock_file,
sizeof(lock_file),
"%s/LCK..%s", LOCK_DIR,
dev);
836 ppp_error((
"Can't create lock file %s: %m", lock_file));
845 ppp_error((
"Can't open existing lock file %s: %m", lock_file));
856 ppp_error((
"Can't read pid from lock file %s", lock_file));
869 if (
unlink (lock_file) == 0) {
870 ppp_notice((
"Removed stale lock on %s (pid %d)",
dev,
pid));
873 ppp_warn((
"Couldn't remove stale lock on %s",
dev));
875 ppp_notice((
"Device %s is locked by pid %d",
dev,
pid));
918 if (lock_file[0] == 0)
922 ppp_error((
"Couldn't reopen lock file %s: %m", lock_file));
947 (
void) rmlock(lock_file, (
void *) 0);
char * strstr(char *String1, char *String2)
ACPI_SIZE strlen(const char *String)
char * strchr(const char *String, int ch)
struct protocol * protocols
#define LWIP_ASSERT(message, assertion)
static unsigned int error_count
GLuint GLuint GLsizei count
GLint GLint GLsizei width
GLenum GLuint GLenum GLsizei const GLchar * buf
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define LWIP_UNUSED_ARG(x)
static const char hexchars[]
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
#define memcpy(s1, s2, n)
static void lock_buffer(struct buffer_head *bh)
const char * strerror(int err)
_CRT_RESTORE_GCC_WARNINGS _CRT_DISABLE_GCC_WARNINGS _Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
Character const *const prefix
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid