Don't write accounting files if not required.
[l2tpns.git] / util.c
1 /* Misc util functions */
2
3 char const *cvs_id_util = "$Id: util.c,v 1.3 2004/09/02 04:18:07 fred_nerk Exp $";
4
5 #include "l2tpns.h"
6
7 #include <sys/socket.h>
8 #include <netinet/in.h>
9 #include <arpa/inet.h>
10 #include <string.h>
11 #include <sys/mman.h>
12
13 char *inet_toa(unsigned long addr)
14 {
15 struct in_addr in;
16 memcpy(&in, &addr, sizeof(unsigned long));
17 return inet_ntoa(in);
18 }
19
20 void *shared_malloc(unsigned int size)
21 {
22 void * p;
23 p = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0);
24
25 if (p == MAP_FAILED)
26 p = NULL;
27
28 return p;
29 }