diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-01-28 13:50:12 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-01-28 13:50:12 +0100 |
commit | 5f8301275181a3349e2df231d7e3c530d6c4d8e9 (patch) | |
tree | 0ab115475baa1af9af1765eb670a2f415ba25e5a /src/nat | |
parent | 0157a38006025eecbed40d04153817a5df0d0e6a (diff) | |
download | gnunet-5f8301275181a3349e2df231d7e3c530d6c4d8e9.tar.gz gnunet-5f8301275181a3349e2df231d7e3c530d6c4d8e9.zip |
improve NAT API: allow client to store associated data with address
Diffstat (limited to 'src/nat')
-rw-r--r-- | src/nat/gnunet-nat.c | 6 | ||||
-rw-r--r-- | src/nat/nat_api.c | 8 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/nat/gnunet-nat.c b/src/nat/gnunet-nat.c index 31b6a7268..275553203 100644 --- a/src/nat/gnunet-nat.c +++ b/src/nat/gnunet-nat.c | |||
@@ -110,6 +110,8 @@ test_finished () | |||
110 | * a function to call whenever our set of 'valid' addresses changes. | 110 | * a function to call whenever our set of 'valid' addresses changes. |
111 | * | 111 | * |
112 | * @param cls closure, NULL | 112 | * @param cls closure, NULL |
113 | * @param app_ctx[in,out] location where the app can store stuff | ||
114 | * on add and retrieve it on remove | ||
113 | * @param add_remove #GNUNET_YES to add a new public IP address, | 115 | * @param add_remove #GNUNET_YES to add a new public IP address, |
114 | * #GNUNET_NO to remove a previous (now invalid) one | 116 | * #GNUNET_NO to remove a previous (now invalid) one |
115 | * @param ac address class the address belongs to | 117 | * @param ac address class the address belongs to |
@@ -118,11 +120,15 @@ test_finished () | |||
118 | */ | 120 | */ |
119 | static void | 121 | static void |
120 | address_cb (void *cls, | 122 | address_cb (void *cls, |
123 | void **app_ctx, | ||
121 | int add_remove, | 124 | int add_remove, |
122 | enum GNUNET_NAT_AddressClass ac, | 125 | enum GNUNET_NAT_AddressClass ac, |
123 | const struct sockaddr *addr, | 126 | const struct sockaddr *addr, |
124 | socklen_t addrlen) | 127 | socklen_t addrlen) |
125 | { | 128 | { |
129 | (void) cls; | ||
130 | (void) app_ctx; | ||
131 | |||
126 | fprintf (stdout, | 132 | fprintf (stdout, |
127 | "%s %s (%d)\n", | 133 | "%s %s (%d)\n", |
128 | add_remove ? "+" : "-", | 134 | add_remove ? "+" : "-", |
diff --git a/src/nat/nat_api.c b/src/nat/nat_api.c index 6ae689b63..04fa366aa 100644 --- a/src/nat/nat_api.c +++ b/src/nat/nat_api.c | |||
@@ -49,6 +49,12 @@ struct AddrEntry | |||
49 | struct AddrEntry *prev; | 49 | struct AddrEntry *prev; |
50 | 50 | ||
51 | /** | 51 | /** |
52 | * Place where the application can store data (on add, | ||
53 | * and retrieve on remove). | ||
54 | */ | ||
55 | void *app_ctx; | ||
56 | |||
57 | /** | ||
52 | * Address class of the address. | 58 | * Address class of the address. |
53 | */ | 59 | */ |
54 | enum GNUNET_NAT_AddressClass ac; | 60 | enum GNUNET_NAT_AddressClass ac; |
@@ -148,6 +154,7 @@ reconnect (struct GNUNET_NAT_Handle *nh) | |||
148 | nh->ae_tail, | 154 | nh->ae_tail, |
149 | ae); | 155 | ae); |
150 | nh->address_callback (nh->callback_cls, | 156 | nh->address_callback (nh->callback_cls, |
157 | &ae->app_ctx, | ||
151 | GNUNET_NO, | 158 | GNUNET_NO, |
152 | ae->ac, | 159 | ae->ac, |
153 | (const struct sockaddr *) &ae[1], | 160 | (const struct sockaddr *) &ae[1], |
@@ -299,6 +306,7 @@ handle_address_change_notification (void *cls, | |||
299 | GNUNET_free (ae); | 306 | GNUNET_free (ae); |
300 | } | 307 | } |
301 | nh->address_callback (nh->callback_cls, | 308 | nh->address_callback (nh->callback_cls, |
309 | &ae->app_ctx, | ||
302 | ntohl (acn->add_remove), | 310 | ntohl (acn->add_remove), |
303 | ac, | 311 | ac, |
304 | sa, | 312 | sa, |