diff options
author | Evan Schoenberg <evands@pidgin.im> | 2007-03-25 01:29:58 +0000 |
---|---|---|
committer | Evan Schoenberg <evands@pidgin.im> | 2007-03-25 01:29:58 +0000 |
commit | 7b34d06b094184ff818ec2b67280c6084cf4eb51 (patch) | |
tree | 6b13512e89cf3884a8d51d56fbf78a88ed67769b /libpurple/nat-pmp.h | |
parent | 49c5c9c64c62e8875d743a96cdd646113bc12dd7 (diff) | |
download | pidgin-7b34d06b094184ff818ec2b67280c6084cf4eb51.tar.gz |
Cleanup and fixes for nat-pmp. We no longer do the whole 'try 10 times, doubling the delay in a blocking manner' ttempt from the original code; as I note in the comments above where the attempt is made a single time, this leads to about 8 minutes of nonresponsiveness if the router both doesn't support nat-pmp and doesn't send back a response to let the program know.
purple_pmp_create_map() and purple_pmp_destroy_map() now return a gboolean indicating success, as the internal data structures of nat-pmp are certainly not needed elsewhere.
The #includes are slightly reordered from the cleanup Mark did (thanks, Mark :) ), as with my OS X 10.3 cross-compiler, anyways, route.h needs to come after the sys includes to be properly handled.
Diffstat (limited to 'libpurple/nat-pmp.h')
-rw-r--r-- | libpurple/nat-pmp.h | 56 |
1 files changed, 19 insertions, 37 deletions
diff --git a/libpurple/nat-pmp.h b/libpurple/nat-pmp.h index 29040144df..ee3ad9caff 100644 --- a/libpurple/nat-pmp.h +++ b/libpurple/nat-pmp.h @@ -32,8 +32,9 @@ #define _PURPLE_NAT_PMP_H #include <stdint.h> +#include <glib.h> -#define PURPLE_PMP_LIFETIME 3600 /* seconds */ +#define PURPLE_PMP_LIFETIME 3600 /* 3600 seconds */ /* * uint8_t: version, opcodes @@ -46,41 +47,10 @@ typedef enum { PURPLE_PMP_TYPE_TCP } PurplePmpType; -typedef struct { - uint8_t version; - uint8_t opcode; -} PurplePmpIpRequest; - -typedef struct { - uint8_t version; - uint8_t opcode; // 128 + n - uint16_t resultcode; - uint32_t epoch; - uint32_t address; -} PurplePmpIpResponse; - -typedef struct { - uint8_t version; - uint8_t opcode; - char reserved[2]; - uint16_t privateport; - uint16_t publicport; - uint32_t lifetime; -} PurplePmpMapRequest; - -typedef struct { - uint8_t version; - uint8_t opcode; - uint16_t resultcode; - uint32_t epoch; - uint16_t privateport; - uint16_t publicport; - uint32_t lifetime; -} PurplePmpMapResponse; - /** * */ + /* * TODO: This should probably cache the result of this lookup requests * so that subsequent calls to this function do not require a @@ -89,13 +59,25 @@ typedef struct { char *purple_pmp_get_public_ip(); /** + * Remove the NAT-PMP mapping for a specified type on a specified port + * + * @param type The PurplePmpType + * @param privateport The private port on which we are listening locally + * @param publicport The public port on which we are expecting a response + * @param lifetime The lifetime of the mapping. It is recommended that this be PURPLE_PMP_LIFETIME. * + * @returns TRUE if succesful; FALSE if unsuccessful */ -PurplePmpMapResponse *purple_pmp_create_map(PurplePmpType type, uint16_t privateport, uint16_t publicport, uint32_t lifetime); +gboolean purple_pmp_create_map(PurplePmpType type, unsigned short privateport, unsigned short publicport, int lifetime); /** + * Remove the NAT-PMP mapping for a specified type on a specified port * + * @param type The PurplePmpType + * @param privateport The private port on which the mapping was previously made + * + * @returns TRUE if succesful; FALSE if unsuccessful */ -PurplePmpMapResponse *purple_pmp_destroy_map(PurplePmpType type, uint16_t privateport); - -#endif /* _PURPLE_NAT_PMP_H_ */ +gboolean purple_pmp_destroy_map(PurplePmpType type, unsigned short privateport); + +#endif
\ No newline at end of file |