#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#define NO_NETWORK -10
#define DEBUG_REMOTE_ADDR_IP4 "217.12.3.11"
#define DEBUG_REMOTE_ADDR_IP6 "2001:638:500:101:2e0:81ff:fe24:37c6"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#define NO_NETWORK -10
#define DEBUG_REMOTE_ADDR_IP4 "123.123.123.123" //"217.12.3.11"
#define DEBUG_REMOTE_ADDR_IP6 "2001:638:500:101:2e0:81ff:fe24:37c6"
#define DEBUG_REMOTE_PORT 11111
static int default_gateway_ipv4(char *address, int size)
{
int len;
int sock_rt, on = 1;
struct sockaddr_in iface_out;
struct sockaddr_in remote;
memset(&remote, 0, sizeof(struct sockaddr_in));
remote.sin_family = AF_INET;
remote.sin_addr.s_addr = inet_addr(DEBUG_REMOTE_ADDR_IP4);
remote.sin_port = htons(DEBUG_REMOTE_PORT);
memset(&iface_out, 0, sizeof(iface_out));
sock_rt = socket(AF_INET, SOCK_DGRAM, 0);
if (setsockopt(so
Linux 获取本地IP的方法(参考exosip)
最新推荐文章于 2023-02-23 16:30:51 发布