Entry point for the plugin.
952{
956 unsigned int nport;
958 int af;
959 unsigned long long nse;
960
963 "DHTU-IP",
964 "NSE",
966 {
968 "DHTU-IP",
969 "NSE");
970 return NULL;
971 }
974 "DHTU-IP",
975 "UDP_PORT",
977 {
979 "DHTU-IP",
980 "UDP_PORT");
981 return NULL;
982 }
983 {
985
986 if ( (1 != sscanf (
port,
987 "%u%c",
988 &nport,
990 (nport > UINT16_MAX) )
991 {
993 "DHTU-IP",
994 "UDP_PORT",
995 "must be number below 65536");
997 return NULL;
998 }
999 }
1003 plugin->port16 = (uint16_t) nport;
1007 {
1009 return NULL;
1010 }
1012 af = AF_INET6;
1013 else
1014 af = AF_INET;
1016 SOCK_DGRAM,
1017 IPPROTO_UDP);
1019 {
1021 "socket");
1024 return NULL;
1025 }
1026 switch (af)
1027 {
1028 case AF_INET:
1029 {
1030 int on = 1;
1031
1032 if (0 !=
1034 IPPROTO_IP,
1035 IP_PKTINFO,
1036 &on,
1037 sizeof (on)))
1038 {
1040 "setsockopt");
1041 }
1042 }
1043 {
1044 struct sockaddr_in sa = {
1045 .sin_family = AF_INET,
1046 .sin_port = htons ((uint16_t) nport)
1047 };
1048
1049 if (0 !=
1050 bind (sock,
1051 (const struct sockaddr *) &sa,
1052 sizeof (sa)))
1053 {
1055 "socket");
1057 close (sock));
1060 return NULL;
1061 }
1062 }
1063 break;
1064 case AF_INET6:
1065 {
1066 int on = 1;
1067
1068 if (0 !=
1069 setsockopt (sock,
1070 IPPROTO_IPV6,
1071 IPV6_RECVPKTINFO,
1072 &on,
1073 sizeof (on)))
1074 {
1076 "setsockopt");
1077 }
1078 }
1079 {
1080 struct sockaddr_in6 sa = {
1081 .sin6_family = AF_INET6,
1082 .sin6_port = htons ((uint16_t) nport)
1083 };
1084
1085 if (0 !=
1086 bind (sock,
1087 (const struct sockaddr *) &sa,
1088 sizeof (sa)))
1089 {
1091 "socket");
1093 close (sock));
1096 return NULL;
1097 }
1098 }
1099 break;
1100 }
1109 env->network_size_cb (
env->cls,
1111 log (
nse) / log (2),
1112 -1.0 );
1121 return api;
1122}
struct GNUNET_MQ_Envelope * env
static uint16_t port
Port number.
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
static struct GNUNET_NSE_Handle * nse
The handle to the NSE service.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_get_peer_identity(const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_PeerIdentity *dst)
Retrieve the identity of the host's peer.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
void GNUNET_log_config_invalid(enum GNUNET_ErrorType kind, const char *section, const char *option, const char *required)
Log error message about invalid configuration option value.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
@ GNUNET_ERROR_TYPE_ERROR
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_NETWORK_Handle * GNUNET_NETWORK_socket_box_native(int fd)
Box a native socket (and check that it is a socket).
enum GNUNET_GenericReturnValue GNUNET_NETWORK_test_pf(int pf)
Test if the given protocol family is supported by this system.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_read_net(struct GNUNET_TIME_Relative delay, struct GNUNET_NETWORK_Handle *rfd, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay or when the specified file descriptor is ready f...
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
static void ip_send(void *cls, struct GNUNET_DHTU_Target *target, const void *msg, size_t msg_size, GNUNET_SCHEDULER_TaskCallback finished_cb, void *finished_cb_cls)
Send message to some other participant over the network.
static void read_cb(void *cls)
UDP socket is ready to receive.
static void scan(void *cls)
Scan network interfaces for IP address changes.
static struct GNUNET_DHTU_PreferenceHandle * ip_hold(void *cls, struct GNUNET_DHTU_Target *target)
Request underlay to keep the connection to target alive if possible.
static void ip_try_connect(void *cls, const struct GNUNET_PeerIdentity *pid, const char *address)
Request creation of a session with a peer at the given address.
static void ip_drop(struct GNUNET_DHTU_PreferenceHandle *ph)
Do no long request underlay to keep the connection alive.
struct returned by the initialization function of the plugin
void(* try_connect)(void *cls, const struct GNUNET_PeerIdentity *pid, const char *address)
Request creation of a session with a peer at the given address.
void * cls
Closure to pass to all plugin functions.
struct GNUNET_DHTU_PreferenceHandle *(* hold)(void *cls, struct GNUNET_DHTU_Target *target)
Request underlay to keep the connection to target alive if possible.
void(* drop)(struct GNUNET_DHTU_PreferenceHandle *ph)
Do no longer request underlay to keep the connection alive.
void(* send)(void *cls, struct GNUNET_DHTU_Target *target, const void *msg, size_t msg_size, GNUNET_SCHEDULER_TaskCallback finished_cb, void *finished_cb_cls)
Send message to some other participant over the network.
struct GNUNET_NETWORK_Handle * sock
My UDP socket.