Mercurial > pidgin.yaz
comparison src/stun.h @ 12686:5f65a0cca87c
[gaim-migrate @ 15029]
Clean up the STUN / SRV API a bit.
I don't use this stuff, so there was no testing beyond compiling it. I think it's right, though I couldn't find where the STUN discovery status was ever set to 1 (discovering). Anyone know something about that?
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Tue, 03 Jan 2006 00:23:24 +0000 |
parents | fc464a0abccc |
children | 6ef1cdc26b40 |
comparison
equal
deleted
inserted
replaced
12685:e9f279f0ef02 | 12686:5f65a0cca87c |
---|---|
28 /**************************************************************************/ | 28 /**************************************************************************/ |
29 /** @name STUN API */ | 29 /** @name STUN API */ |
30 /**************************************************************************/ | 30 /**************************************************************************/ |
31 /*@{*/ | 31 /*@{*/ |
32 | 32 |
33 struct stun_nattype { | 33 typedef struct _GaimStunNatDiscovery GaimStunNatDiscovery; |
34 gint status; /* 0 - unknown (no STUN server reachable) */ | |
35 /* 1 - discovering */ | |
36 /* 2 - discovered */ | |
37 | 34 |
38 gint type; /* 0 - public ip */ | 35 typedef enum { |
39 /* 1 - NAT (unknown type) */ | 36 GAIM_STUN_STATUS_UNDISCOVERED = -1, |
40 /* 2 - full cone */ | 37 GAIM_STUN_STATUS_UNKNOWN, /* no STUN server reachable */ |
41 /* 3 - restricted cone */ | 38 GAIM_STUN_STATUS_DISCOVERING, |
42 /* 4 - port restricted cone */ | 39 GAIM_STUN_STATUS_DISCOVERED |
43 /* 5 - symmetric */ | 40 } GaimStunStatus; |
44 | 41 |
42 typedef enum { | |
43 GAIM_STUN_NAT_TYPE_PUBLIC_IP, | |
44 GAIM_STUN_NAT_TYPE_UNKNOWN_NAT, | |
45 GAIM_STUN_NAT_TYPE_FULL_CONE, | |
46 GAIM_STUN_NAT_TYPE_RESTRICTED_CONE, | |
47 GAIM_STUN_NAT_TYPE_PORT_RESTRICTED_CONE, | |
48 GAIM_STUN_NAT_TYPE_SYMMETRIC | |
49 } GaimStunNatType; | |
50 | |
51 struct _GaimStunNatDiscovery { | |
52 GaimStunStatus status; | |
53 GaimStunNatType type; | |
45 char publicip[16]; | 54 char publicip[16]; |
46 }; | 55 }; |
47 | 56 |
48 struct stun_header { | 57 typedef void (*StunCallback) (GaimStunNatDiscovery *); |
49 short type; | |
50 short len; | |
51 int transid[4]; | |
52 }; | |
53 | |
54 struct stun_attrib { | |
55 short type; | |
56 short len; | |
57 }; | |
58 | |
59 struct stun_change { | |
60 struct stun_header hdr; | |
61 struct stun_attrib attrib; | |
62 char value[4]; | |
63 }; | |
64 | |
65 typedef void (*StunCallback) (struct stun_nattype *); | |
66 | 58 |
67 /** | 59 /** |
68 * Starts a NAT discovery. It returns a struct stun_nattype if the discovery | 60 * Starts a NAT discovery. It returns a GaimStunNatDiscovery if the discovery |
69 * is already done. Otherwise the callback is called when the discovery is over | 61 * is already done. Otherwise the callback is called when the discovery is over |
70 * and NULL is returned. | 62 * and NULL is returned. |
71 * | 63 * |
72 * @param cb A callback | 64 * @param cb The callback to call when the STUN discovery is finished if the |
65 * discovery would block. If the discovery is done, this is NOT | |
66 * called. | |
73 * | 67 * |
74 * @return a struct stun_nattype which includes the public IP and the type | 68 * @return a GaimStunNatDiscovery which includes the public IP and the type |
75 * of NAT or NULL is discovery would block | 69 * of NAT or NULL is discovery would block |
76 */ | 70 */ |
77 struct stun_nattype *gaim_stun_discover(StunCallback cb); | 71 GaimStunNatDiscovery *gaim_stun_discover(StunCallback cb); |
78 | 72 |
79 void gaim_stun_init(void); | 73 void gaim_stun_init(void); |
80 | 74 |
81 /*@}*/ | 75 /*@}*/ |
82 | 76 |
83 #endif /* _GAIM_STUN_H_ */ | 77 #endif /* _GAIM_STUN_H_ */ |
84 |