Commit 2b983646742184e2191caa223a2580e0a2bd878b
1 parent
382518de
add code to get the ip address from a socket.
Showing
5 changed files
with
80 additions
and
6 deletions
... | ... | @@ -37,10 +37,12 @@ TR_CLASS(TR_Sock) { |
37 | 37 | int handle; |
38 | 38 | }; |
39 | 39 | |
40 | -void TR_socketConnect(TR_Sock this, const char * addr, char (*)[16]); | |
41 | -void TR_socketListen(TR_Sock this, int backlog); | |
42 | -TR_Sock TR_socketAccept(TR_Sock this, char (*remoteAddr)[16]); | |
43 | -void TR_socketNonblock(TR_Sock this); | |
40 | +void TR_socketConnect(TR_Sock this, const char * addr, char (*)[16]); | |
41 | +void TR_socketListen(TR_Sock this, int backlog); | |
42 | +TR_Sock TR_socketAccept(TR_Sock this, char (*remoteAddr)[16]); | |
43 | +void TR_socketNonblock(TR_Sock this); | |
44 | +in_addr_t TR_socketGetIp(TR_Sock this); | |
45 | +const char * const TR_socketGetIpStr(TR_Sock this); | |
44 | 46 | |
45 | 47 | #endif // __TR_SOCKET_H__ |
46 | 48 | ... | ... |
src/get_ip.c
0 → 100644
1 | +/** | |
2 | + * \file | |
3 | + * | |
4 | + * \author Georg Hopp | |
5 | + * | |
6 | + * \copyright | |
7 | + * Copyright © 2012 Georg Hopp | |
8 | + * | |
9 | + * This program is free software: you can redistribute it and/or modify | |
10 | + * it under the terms of the GNU General Public License as published by | |
11 | + * the Free Software Foundation, either version 3 of the License, or | |
12 | + * (at your option) any later version. | |
13 | + * | |
14 | + * This program is distributed in the hope that it will be useful, | |
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | + * GNU General Public License for more details. | |
18 | + * | |
19 | + * You should have received a copy of the GNU General Public License | |
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | + */ | |
22 | + | |
23 | +#include <arpa/inet.h> | |
24 | + | |
25 | +#include "trbase.h" | |
26 | +#include "tr/socket.h" | |
27 | +#include "tr/logger.h" | |
28 | + | |
29 | +in_addr_t | |
30 | +TR_socketGetIp(TR_Sock this) | |
31 | +{ | |
32 | + return this->addr.sin_addr.s_addr; | |
33 | +} | |
34 | + | |
35 | +// vim: set ts=4 sw=4: | ... | ... |
src/get_ip_str.c
0 → 100644
1 | +/** | |
2 | + * \file | |
3 | + * | |
4 | + * \author Georg Hopp | |
5 | + * | |
6 | + * \copyright | |
7 | + * Copyright © 2012 Georg Hopp | |
8 | + * | |
9 | + * This program is free software: you can redistribute it and/or modify | |
10 | + * it under the terms of the GNU General Public License as published by | |
11 | + * the Free Software Foundation, either version 3 of the License, or | |
12 | + * (at your option) any later version. | |
13 | + * | |
14 | + * This program is distributed in the hope that it will be useful, | |
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | + * GNU General Public License for more details. | |
18 | + * | |
19 | + * You should have received a copy of the GNU General Public License | |
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | + */ | |
22 | + | |
23 | +#include <arpa/inet.h> | |
24 | + | |
25 | +#include "trbase.h" | |
26 | +#include "tr/socket.h" | |
27 | +#include "tr/logger.h" | |
28 | + | |
29 | +const char * const | |
30 | +TR_socketGetIpStr(TR_Sock this) | |
31 | +{ | |
32 | + return inet_ntoa(this->addr.sin_addr); | |
33 | +} | |
34 | + | |
35 | +// vim: set ts=4 sw=4: | ... | ... |
... | ... | @@ -11,13 +11,13 @@ |
11 | 11 | #define HAVE_MEMORY_H 1 |
12 | 12 | |
13 | 13 | /* Define to 1 if you have the `memset' function. */ |
14 | -#define HAVE_MEMSET 1 | |
14 | +/* #undef HAVE_MEMSET */ | |
15 | 15 | |
16 | 16 | /* Define to 1 if you have the <stdarg.h> header file. */ |
17 | 17 | #define HAVE_STDARG_H 1 |
18 | 18 | |
19 | 19 | /* Define to 1 if stdbool.h conforms to C99. */ |
20 | -#define HAVE_STDBOOL_H 1 | |
20 | +/* #undef HAVE_STDBOOL_H */ | |
21 | 21 | |
22 | 22 | /* Define to 1 if you have the <stdint.h> header file. */ |
23 | 23 | #define HAVE_STDINT_H 1 | ... | ... |
Please
register
or
login
to post a comment