summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorng0 <ng0@n0.is>2019-09-09 09:55:18 +0000
committerng0 <ng0@n0.is>2019-09-09 09:55:18 +0000
commitc03c7227ba8ac9acc8992c2166a72bea383c09d6 (patch)
tree63d7e420f1d5cea38830a09c591aa851e345c060
parenta4543a4105ca6cea2bd558aed8d2e87981d535ea (diff)
plibc removal: sscanf, win32 socket corrections
-rw-r--r--src/credential/credential_misc.c2
-rw-r--r--src/credential/plugin_gnsrecord_credential.c4
-rw-r--r--src/nat/gnunet-helper-nat-client-windows.c14
-rw-r--r--src/nat/gnunet-helper-nat-server-windows.c26
-rw-r--r--src/transport/gnunet-transport-wlan-sender.c4
-rw-r--r--src/transport/plugin_transport_wlan.c2
-rw-r--r--src/util/os_installation.c2
-rw-r--r--src/util/os_network.c14
8 files changed, 34 insertions, 34 deletions
diff --git a/src/credential/credential_misc.c b/src/credential/credential_misc.c
index be6d124a6..bc8a28912 100644
--- a/src/credential/credential_misc.c
+++ b/src/credential/credential_misc.c
@@ -77,7 +77,7 @@ GNUNET_CREDENTIAL_credential_from_string(const char* s)
struct GNUNET_CRYPTO_EcdsaSignature *sig;
struct GNUNET_TIME_Absolute etime_abs;
- if (5 != SSCANF(s,
+ if (5 != sscanf(s,
"%52s.%253s -> %52s | %s | %" SCNu64,
issuer_pkey,
name,
diff --git a/src/credential/plugin_gnsrecord_credential.c b/src/credential/plugin_gnsrecord_credential.c
index 9207aa7ad..134153c13 100644
--- a/src/credential/plugin_gnsrecord_credential.c
+++ b/src/credential/plugin_gnsrecord_credential.c
@@ -162,7 +162,7 @@ credential_string_to_value(void *cls, uint32_t type, const char *s,
*data_size = sizeof(struct GNUNET_CREDENTIAL_DelegationRecord);
while (NULL != token)
{
- matches = SSCANF(token, "%s %s", subject_pkey, attr_str);
+ matches = sscanf(token, "%s %s", subject_pkey, attr_str);
if (0 == matches)
{
GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
@@ -195,7 +195,7 @@ credential_string_to_value(void *cls, uint32_t type, const char *s,
memset(set, 0, sizeof(struct GNUNET_CREDENTIAL_DelegationSet) * entries);
for (i = 0; i < entries; i++)
{
- matches = SSCANF(token, "%s %s", subject_pkey, attr_str);
+ matches = sscanf(token, "%s %s", subject_pkey, attr_str);
GNUNET_CRYPTO_ecdsa_public_key_from_string(
subject_pkey, strlen(subject_pkey), &set[i].subject_key);
if (2 == matches)
diff --git a/src/nat/gnunet-helper-nat-client-windows.c b/src/nat/gnunet-helper-nat-client-windows.c
index 2dac5d48e..1be31ae42 100644
--- a/src/nat/gnunet-helper-nat-client-windows.c
+++ b/src/nat/gnunet-helper-nat-client-windows.c
@@ -22,7 +22,7 @@
* @file src/nat/gnunet-helper-nat-client-windows.c
* @brief Tool to help bypass NATs using ICMP method; must run as
* administrator on W32
- * This code is forx W32.
+ * This code is for W32.
* @author Nathan Evans
*
* This program will send ONE ICMP message using RAW sockets
@@ -172,7 +172,7 @@ static boolean privilege_testing = FALSE;
/**
* Socket we use to send our ICMP packets.
*/
-static SOCKET rawsock;
+static _win_socket rawsock;
/**
* Target "dummy" address.
@@ -426,21 +426,21 @@ send_icmp(const struct in_addr *my_ip, const struct in_addr *other)
*
* @return INVALID_SOCKET on error
*/
-static SOCKET
+static _win_socket
make_raw_socket()
{
DWORD bOptVal = TRUE;
int bOptLen = sizeof(bOptVal);
- SOCKET ret;
+ _win_socket ret;
- ret = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
+ ret = _win_socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
if (INVALID_SOCKET == ret)
{
fprintf(stderr, "Error opening RAW socket: %s\n", strerror(errno));
return INVALID_SOCKET;
}
if (0 !=
- setsockopt(ret, SOL_SOCKET, SO_BROADCAST, (char *)&bOptVal, bOptLen))
+ _win_setsockopt(ret, SOL_SOCKET, SO_BROADCAST, (char *)&bOptVal, bOptLen))
{
fprintf(stderr, "Error setting SO_BROADCAST to ON: %s\n",
strerror(errno));
@@ -448,7 +448,7 @@ make_raw_socket()
return INVALID_SOCKET;
}
- if (0 != setsockopt(ret, IPPROTO_IP, IP_HDRINCL, (char *)&bOptVal, bOptLen))
+ if (0 != _win_setsockopt(ret, IPPROTO_IP, IP_HDRINCL, (char *)&bOptVal, bOptLen))
{
fprintf(stderr, "Error setting IP_HDRINCL to ON: %s\n", strerror(errno));
closesocket(rawsock);
diff --git a/src/nat/gnunet-helper-nat-server-windows.c b/src/nat/gnunet-helper-nat-server-windows.c
index 13a4d8e6f..688dde165 100644
--- a/src/nat/gnunet-helper-nat-server-windows.c
+++ b/src/nat/gnunet-helper-nat-server-windows.c
@@ -192,17 +192,17 @@ static boolean privilege_testing = FALSE;
/**
* Socket we use to receive "fake" ICMP replies.
*/
-static SOCKET icmpsock;
+static _win_socket icmpsock;
/**
* Socket we use to send our ICMP requests.
*/
-static SOCKET rawsock;
+static _win_socket rawsock;
/**
* Socket we use to send our UDP requests.
*/
-static SOCKET udpsock;
+static _win_socket udpsock;
/**
* Target "dummy" address.
@@ -438,12 +438,12 @@ process_icmp_response()
*
* @return INVALID_SOCKET on error
*/
-static SOCKET
+static _win_socket
make_icmp_socket()
{
- SOCKET ret;
+ _win_socket ret;
- ret = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
+ ret = _win_socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
if (INVALID_SOCKET == ret)
{
fprintf(stderr, "Error opening RAW socket: %s\n", strerror(errno));
@@ -458,13 +458,13 @@ make_icmp_socket()
*
* @return INVALID_SOCKET on error
*/
-static SOCKET
+static _win_socket
make_raw_socket()
{
DWORD bOptVal = TRUE;
int bOptLen = sizeof(bOptVal);
- rawsock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
+ rawsock = _win_socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
if (INVALID_SOCKET == rawsock)
{
fprintf(stderr, "Error opening RAW socket: %s\n", strerror(errno));
@@ -472,7 +472,7 @@ make_raw_socket()
}
if (0 !=
- setsockopt(rawsock, SOL_SOCKET, SO_BROADCAST, (char *)&bOptVal,
+ _win_setsockopt(rawsock, SOL_SOCKET, SO_BROADCAST, (char *)&bOptVal,
bOptLen))
{
fprintf(stderr, "Error setting SO_BROADCAST to ON: %s\n",
@@ -481,7 +481,7 @@ make_raw_socket()
return INVALID_SOCKET;
}
if (0 !=
- setsockopt(rawsock, IPPROTO_IP, IP_HDRINCL, (char *)&bOptVal, bOptLen))
+ _win_setsockopt(rawsock, IPPROTO_IP, IP_HDRINCL, (char *)&bOptVal, bOptLen))
{
fprintf(stderr, "Error setting IP_HDRINCL to ON: %s\n", strerror(errno));
closesocket(rawsock);
@@ -497,13 +497,13 @@ make_raw_socket()
* @param my_ip source address (our ip address)
* @return INVALID_SOCKET on error
*/
-static SOCKET
+static _win_socket
make_udp_socket(const struct in_addr *my_ip)
{
- SOCKET ret;
+ _win_socket ret;
struct sockaddr_in addr;
- ret = socket(AF_INET, SOCK_DGRAM, 0);
+ ret = _win_socket(AF_INET, SOCK_DGRAM, 0);
if (INVALID_SOCKET == ret)
{
fprintf(stderr, "Error opening UDP socket: %s\n", strerror(errno));
diff --git a/src/transport/gnunet-transport-wlan-sender.c b/src/transport/gnunet-transport-wlan-sender.c
index c3485ac47..be8bcdda0 100644
--- a/src/transport/gnunet-transport-wlan-sender.c
+++ b/src/transport/gnunet-transport-wlan-sender.c
@@ -123,7 +123,7 @@ main(int argc, char *argv[])
"e.g. mon0 11-22-33-44-55-66 12-34-56-78-90-ab\n");
return 1;
}
- if (6 != SSCANF(argv[2],
+ if (6 != sscanf(argv[2],
"%x-%x-%x-%x-%x-%x",
&temp[0],
&temp[1],
@@ -139,7 +139,7 @@ main(int argc, char *argv[])
}
for (i = 0; i < 6; i++)
outmac.mac[i] = temp[i];
- if (6 != SSCANF(argv[3],
+ if (6 != sscanf(argv[3],
"%x-%x-%x-%x-%x-%x",
&temp[0],
&temp[1],
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index a6d44ecb5..6cdf240c3 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -2111,7 +2111,7 @@ wlan_plugin_string_to_address(void *cls,
return GNUNET_SYSERR;
}
- if (8 != SSCANF(addr,
+ if (8 != sscanf(addr,
"%4s.%u.%X:%X:%X:%X:%X:%X",
plugin, &options,
&a[0], &a[1], &a[2],
diff --git a/src/util/os_installation.c b/src/util/os_installation.c
index 656468707..8d9c6e622 100644
--- a/src/util/os_installation.c
+++ b/src/util/os_installation.c
@@ -156,7 +156,7 @@ get_path_from_proc_maps()
return NULL;
while (NULL != fgets(line, sizeof(line), f))
{
- if ((1 == SSCANF(line,
+ if ((1 == sscanf(line,
"%*x-%*x %*c%*c%*c%*c %*x %*2x:%*2x %*u%*[ ]%1023s",
dir)) &&
(NULL != (lgu = strstr(dir, current_pd->libname))))
diff --git a/src/util/os_network.c b/src/util/os_network.c
index 6bf9d1846..4df37b9e5 100644
--- a/src/util/os_network.c
+++ b/src/util/os_network.c
@@ -109,7 +109,7 @@ try_ifconfig(GNUNET_OS_NetworkInterfaceProcessor proc,
}
if (!isspace(line[0]))
{
- have_ifc = (1 == SSCANF(line, "%11s", ifc)) ? GNUNET_YES : GNUNET_NO;
+ have_ifc = (1 == sscanf(line, "%11s", ifc)) ? GNUNET_YES : GNUNET_NO;
/* would end with ':' on OSX, fix it! */
if (ifc[strlen(ifc) - 1] == ':')
ifc[strlen(ifc) - 1] = '\0';
@@ -137,12 +137,12 @@ try_ifconfig(GNUNET_OS_NetworkInterfaceProcessor proc,
prefixlen = 0;
if ( /* Linux */
- (3 == SSCANF(start, "inet addr:%127s Bcast:%127s Mask:%127s", addrstr, bcstr, netmaskstr)) ||
- (2 == SSCANF(start, "inet addr:%127s Mask:%127s", addrstr, netmaskstr)) ||
- (2 == SSCANF(start, "inet6 addr:%127s %d", addrstr, &prefixlen)) ||
+ (3 == sscanf(start, "inet addr:%127s Bcast:%127s Mask:%127s", addrstr, bcstr, netmaskstr)) ||
+ (2 == sscanf(start, "inet addr:%127s Mask:%127s", addrstr, netmaskstr)) ||
+ (2 == sscanf(start, "inet6 addr:%127s %d", addrstr, &prefixlen)) ||
/* Solaris, OS X */
- (1 == SSCANF(start, "inet %127s", addrstr)) ||
- (1 == SSCANF(start, "inet6 %127s", addrstr)))
+ (1 == sscanf(start, "inet %127s", addrstr)) ||
+ (1 == sscanf(start, "inet6 %127s", addrstr)))
{
/* IPv4 */
if (1 == inet_pton(AF_INET, addrstr, &v4))
@@ -294,7 +294,7 @@ try_ip(GNUNET_OS_NetworkInterfaceProcessor proc,
memset(ifname, 0, 64);
memset(afstr, 0, 6);
memset(addrstr, 0, 128);
- if (4 != SSCANF(line,
+ if (4 != sscanf(line,
"%*u: %63s %5s %127s %6u",
ifname,
afstr,