mirror of
https://github.com/cjdelisle/cjdns
synced 2025-10-06 00:32:50 +02:00
Message.h * Introduce associatedFd to a message for sharing file descriptors between processes * Ability to push and pop numbers in any byte order Seccomp_test.c * Refactoring to work with changes to Pipe.h Process_test.c * Refactoring to work with changes to Pipe.h * Test passing file descriptors between processes to make sure it works Sockaddr.h * Ability to create a synthetic sockaddr which encapsulates a uint32_t handle UDPAddrIface.h * Introduce UDPAddrIface_getFd Pipe.h * Pipe_named() * Now uses fullName rather than path + name, as did Pipe_namedConnect() * Requires a logger as an argument * Now Pipe_named() only connects to a unix socket server, never creates one * Pipe_namedConnect() removed * Pipe_forFiles() * Changed to Pipe_forFd() which accepts only one fd and is easier to implement * Has an argument 'ipc' to determine whether the fd being opened can be used to pass file descriptors between processes * Requires a logger as an argument * Pipe_exists() added which checks if a unix socket exists PipeServer.h - introduced a new object which manages a unix socket server * Acts as an AddrIface similar to UDPAddrIface when messages come in from different clients of the pipe server Seccomp.c -> Allow accept4 syscall which is used by PipeServer to accept a request from a new client CString.c -> Add CString_strdup() which clones a string using an allocator Bits.h -> Add get16 and put16 which allow read and write of potentially unaligned numbers ReachabilityCollector.c -> Reduce logging make.js -> Enable diagnostic colors on GCC always TUNMessageType.h -> Introduced an enum of types of TUN devices used by linux/bsd/android/sunos TUNInterface_*.c -> Switch from Pipe_forFiles() to Pipe_forFd() SocketInterface.h -> Removed attemptToCreate which is nolonger possible BSDMessageWrapper.c -> Don't return Error_NONE which is technically zero but being returned by a function which should return a pointer AddrIfaceMuxer.h -> New interface which muxes multiple AddrIfaces into a single one, allowing Admin to be reachable via UDP and also socket AddrIface.h -> Ability to push and pop Sockaddr to/from Message UDPInterface.h -> UDPInterface_getFd() get the file descriptor underlying this interface UDPInterface_admin.c -> New RPC: UDPInterface_getFd() for getting the file descriptor of a UDP interface Iface.h -> improved documentation FramingIface.c -> Support associatedFd Janitor.c -> Reduce logging Configurator.c * Stop supporting tunfd because this should be done through RPC calls * Stop supporting socketAttemptToCreate because this is removed cjdroute2.c * Do not generate conf files with tunfd * Do not generate conf files with socketAttemptToCreate * Use a standardized socket path ( /tmp/cjdroute.sock ) rather than a randomized path * Wait for Core to create the socket server rather than creating it in the client Core.c * Allow multiple calls to Core_initTun() or Core_initTunFd() * Remove FileNo_admin * Remove socketAttemptToCreate from Core_initSocket * Create a PipeServer rather than connecting to the client * After preconfiguration is complete, launch a muxer and plug in the UDPInterface as well as the socket interface
78 lines
1.8 KiB
C
78 lines
1.8 KiB
C
/* vim: set expandtab ts=4 sw=4: */
|
|
/*
|
|
* You may redistribute this program and/or modify it under the terms of
|
|
* the GNU General Public License as published by the Free Software Foundation,
|
|
* either version 3 of the License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
#include "util/CString.h"
|
|
#include "util/Bits.h"
|
|
|
|
#include <string.h>
|
|
|
|
#if defined(Illumos) || defined(__sun)
|
|
#define _XPG4_2
|
|
#endif
|
|
#include <strings.h>
|
|
|
|
unsigned long CString_strlen(const char* str)
|
|
{
|
|
return strlen(str);
|
|
}
|
|
|
|
int CString_strcmp(const char* a, const char* b)
|
|
{
|
|
return strcmp(a,b);
|
|
}
|
|
|
|
int CString_strncmp(const char* a, const char *b, size_t n)
|
|
{
|
|
return strncmp(a, b, n);
|
|
}
|
|
|
|
char* CString_strchr(const char* a, int b)
|
|
{
|
|
return strchr(a,b);
|
|
}
|
|
|
|
char* CString_strrchr(const char* a, int b)
|
|
{
|
|
return strrchr(a,b);
|
|
}
|
|
|
|
int CString_strcasecmp(const char *a, const char *b)
|
|
{
|
|
return strcasecmp(a,b);
|
|
}
|
|
|
|
char* CString_strstr(const char* haystack, const char* needle)
|
|
{
|
|
return strstr(haystack,needle);
|
|
}
|
|
|
|
char* CString_strcpy(char* restrict dest, const char* restrict src)
|
|
{
|
|
return strcpy(dest, src);
|
|
}
|
|
|
|
char* CString_safeStrncpy(char* restrict dest, const char *restrict src, size_t n)
|
|
{
|
|
char* ret = strncpy(dest, src, n);
|
|
dest[n - 1] = '\0';
|
|
return ret;
|
|
}
|
|
|
|
char* CString_strdup(const char* string, struct Allocator* alloc)
|
|
{
|
|
int len = CString_strlen(string);
|
|
char* out = Allocator_calloc(alloc, len+1, 1);
|
|
Bits_memcpy(out, string, len);
|
|
return out;
|
|
} |