summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--INSTALL.md2
-rw-r--r--README.md3
-rw-r--r--core/LAN_discovery.c58
-rw-r--r--core/LAN_discovery.h8
-rw-r--r--start_guide.md6
5 files changed, 70 insertions, 7 deletions
diff --git a/INSTALL.md b/INSTALL.md
index 90563790..a0c4165d 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -58,7 +58,7 @@ make
58<a name="homebrew" /> 58<a name="homebrew" />
59####Homebrew: 59####Homebrew:
60``` 60```
61brew install libtool automake autoconf libconfig libsodium 61brew install libtool automake autoconf libconfig libsodium cmake
62cmake . 62cmake .
63make 63make
64sudo make install 64sudo make install
diff --git a/README.md b/README.md
index 55135d03..092fe2f6 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,8 @@ With the rise of governmental monitoring programs, Tox aims to be an easy to use
12**Qt GUI**: [see nurupo's repository](https://github.com/nurupo/ProjectTox-Qt-GUI) 12**Qt GUI**: [see nurupo's repository](https://github.com/nurupo/ProjectTox-Qt-GUI)
13 13
14**How to build Tox on Linux**: [YouTube video](http://www.youtube.com/watch?v=M4WXE4VKmyg)<br /> 14**How to build Tox on Linux**: [YouTube video](http://www.youtube.com/watch?v=M4WXE4VKmyg)<br />
15**How to use Tox on Windows**: [YouTube video](http://www.youtube.com/watch?v=qg_j_sDb6WQ) 15**How to use Tox on Windows**: [YouTube video](http://www.youtube.com/watch?v=qg_j_sDb6WQ)<br />
16**For Mac OSX read INSTALL.md**
16 17
17### Objectives: 18### Objectives:
18 19
diff --git a/core/LAN_discovery.c b/core/LAN_discovery.c
index 0a23914d..6170f2fb 100644
--- a/core/LAN_discovery.c
+++ b/core/LAN_discovery.c
@@ -23,13 +23,67 @@
23 23
24#include "LAN_discovery.h" 24#include "LAN_discovery.h"
25 25
26#define MAX_INTERFACES 16
27#define ERR_INTERFACES 0
28#define ERR_IOCTL 1
26 29
27/*Return the broadcast ip 30#ifdef __linux
28 TODO: make it return the real one, not the 255.255.255.255 one.*/ 31/* get the first running interface's broadcast IP,
32 * return is higher than 0 on success
33 * ERR_IOCTL on an ioctl error
34 * ERR_INTERFACES on general error */
35uint32_t get_broadcast(void)
36{
37 /* not sure how many platforms this will
38 * run on, so it's wrapped in __linux for now */
39 struct ifconf ifconf;
40 struct ifreq i_faces[MAX_INTERFACES];
41 int count = 0;
42 int sock = 0;
43 int i = 0;
44 struct sockaddr_in *sock_holder = NULL;
45
46 /* configure ifconf for the ioctl call */
47 sock = socket(AF_INET, SOCK_STREAM, 0);
48 ifconf.ifc_buf = (char *)i_faces;
49 ifconf.ifc_len = sizeof(i_faces);
50 count = ifconf.ifc_len / sizeof(i_faces[0]);
51
52 for(i = 0; i < count; i++) {
53 /* skip the loopback interface, as it's useless */
54 if(strcmp(i_faces[i].ifr_name, "lo") != 0) {
55 if(ioctl(sock, SIOCGIFBRDADDR, &i_faces[i]) < 0) {
56 perror("[!] get_broadcast: ioctl error");
57 return 0;
58 }
59
60 /* just to clarify where we're getting the values from */
61 sock_holder = (struct sockaddr_in *)&i_faces[i].ifr_broadaddr;
62 break;
63 }
64 }
65 close(sock);
66
67 if(sock_holder == NULL)
68 return ERR_INTERFACES;
69
70 return sock_holder->sin_addr.s_addr;
71}
72#endif
73
74/* Return the broadcast ip */
29IP broadcast_ip() 75IP broadcast_ip()
30{ 76{
31 IP ip; 77 IP ip;
78 #ifdef __linux
79 ip.i = get_broadcast();
80 if(ip.i == ERR_INTERFACES)
81 ip.i = ~0;
82 else if(ip.i == ERR_IOCTL)
83 ip.i = 0;
84 #else
32 ip.i = ~0; 85 ip.i = ~0;
86 #endif
33 return ip; 87 return ip;
34} 88}
35 89
diff --git a/core/LAN_discovery.h b/core/LAN_discovery.h
index 4ca65c03..23391b90 100644
--- a/core/LAN_discovery.h
+++ b/core/LAN_discovery.h
@@ -28,6 +28,14 @@
28 28
29#include "DHT.h" 29#include "DHT.h"
30 30
31/* used for get_broadcast() */
32#ifdef __linux
33#include <sys/ioctl.h>
34#include <arpa/inet.h>
35#include <linux/netdevice.h>
36#endif
37
38
31#ifdef __cplusplus 39#ifdef __cplusplus
32extern "C" { 40extern "C" {
33#endif 41#endif
diff --git a/start_guide.md b/start_guide.md
index 31d7ca8e..2f973a3e 100644
--- a/start_guide.md
+++ b/start_guide.md
@@ -2,7 +2,7 @@
21. [Build Tox](/INSTALL.md) 21. [Build Tox](/INSTALL.md)
32. Fix errors 32. Fix errors
43. Consult IRC for help 43. Consult IRC for help
54. Go on debugging journy for devs 54. Go on debugging journey for devs
65. Build Tox for real 65. Build Tox for real
76. ??? 76. ???
8 8
@@ -22,9 +22,9 @@ Tox. Here's a user-friendly attempt at it.
22 + Now that you're on the network, you need a friend. To get one of those, 22 + Now that you're on the network, you need a friend. To get one of those,
23 you need to to send or receive a request. What's a request, you ask? 23 you need to to send or receive a request. What's a request, you ask?
24 It's like a friend request, but we use really scary and cryptic numbers 24 It's like a friend request, but we use really scary and cryptic numbers
25 instead of names. When `nTox` starts, it shows your _your_ long, scary number, 25 instead of names. When `nTox` starts, it shows _your_ long, scary number,
26 called your *public key*. Give that to people, and they can add you as 26 called your *public key*. Give that to people, and they can add you as
27 as "friend". Or, you can add someone else, with the `/f` command, if you like. 27 a "friend". Or, you can add someone else, with the `/f` command, if you like.
283. Chat it up! 283. Chat it up!
29 + Now use the `/m` command to send a message to someone. Wow, you're chatting! 29 + Now use the `/m` command to send a message to someone. Wow, you're chatting!
304. But something broke! 304. But something broke!