comparison libpurple/protocols/bonjour/mdns_win32.c @ 17506:bbe9248337ea

Fix network byte order issues with win32 bonjour stuff. Also copy the buddy's ip address so that subsequent calls don't overwrite it (it already is being copied and freed because of the howl implementation).
author Daniel Atallah <daniel.atallah@gmail.com>
date Tue, 05 Jun 2007 22:30:06 +0000
parents 9ccec98b8ca9
children a8aa651f341f
comparison
equal deleted inserted replaced
17505:9ccec98b8ca9 17506:bbe9248337ea
70 else 70 else
71 { 71 {
72 struct sockaddr_in *addr = (struct sockaddr_in*)g_slist_nth_data(hosts, 1); 72 struct sockaddr_in *addr = (struct sockaddr_in*)g_slist_nth_data(hosts, 1);
73 BonjourBuddy* buddy = args->buddy; 73 BonjourBuddy* buddy = args->buddy;
74 74
75 buddy->ip = inet_ntoa(addr->sin_addr); 75 buddy->ip = g_strdup(inet_ntoa(addr->sin_addr));
76 76
77 /* finally, set up the continuous txt record watcher, and add the buddy to purple */ 77 /* finally, set up the continuous txt record watcher, and add the buddy to purple */
78 78
79 if (kDNSServiceErr_NoError == DNSServiceQueryRecord(&buddy->txt_query, 0, 0, args->fqn, 79 if (kDNSServiceErr_NoError == DNSServiceQueryRecord(&buddy->txt_query, 0, 0, args->fqn,
80 kDNSServiceType_TXT, kDNSServiceClass_IN, _mdns_text_record_query_callback, buddy)) 80 kDNSServiceType_TXT, kDNSServiceClass_IN, _mdns_text_record_query_callback, buddy))
114 bonjour_buddy_delete(args->buddy); 114 bonjour_buddy_delete(args->buddy);
115 g_free(args); 115 g_free(args);
116 } 116 }
117 else 117 else
118 { 118 {
119 args->buddy->port_p2pj = port; 119 args->buddy->port_p2pj = ntohs(port);
120 120
121 /* parse the text record */ 121 /* parse the text record */
122 _mdns_parse_text_record(args->buddy, txtRecord, txtLen); 122 _mdns_parse_text_record(args->buddy, txtRecord, txtLen);
123 123
124 /* set more arguments, and start the host resolver */ 124 /* set more arguments, and start the host resolver */
260 260
261 switch (type) 261 switch (type)
262 { 262 {
263 case PUBLISH_START: 263 case PUBLISH_START:
264 err = DNSServiceRegister(&data->advertisement, 0, 0, purple_account_get_username(data->account), ICHAT_SERVICE, 264 err = DNSServiceRegister(&data->advertisement, 0, 0, purple_account_get_username(data->account), ICHAT_SERVICE,
265 NULL, NULL, data->port_p2pj, TXTRecordGetLength(&dns_data), TXTRecordGetBytesPtr(&dns_data), 265 NULL, NULL, htons(data->port_p2pj), TXTRecordGetLength(&dns_data), TXTRecordGetBytesPtr(&dns_data),
266 _mdns_service_register_callback, NULL); 266 _mdns_service_register_callback, NULL);
267 break; 267 break;
268 268
269 case PUBLISH_UPDATE: 269 case PUBLISH_UPDATE:
270 err = DNSServiceUpdateRecord(data->advertisement, NULL, 0, TXTRecordGetLength(&dns_data), TXTRecordGetBytesPtr(&dns_data), 0); 270 err = DNSServiceUpdateRecord(data->advertisement, NULL, 0, TXTRecordGetLength(&dns_data), TXTRecordGetBytesPtr(&dns_data), 0);