Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
halo
system_netd
Commits
6d631575
Commit
6d631575
authored
10 years ago
by
Dan Albert
Committed by
Android Git Automerger
10 years ago
Browse files
Options
Download
Plain Diff
am
e3734499
: Merge "Update for libbase."
* commit '
e3734499
': Update for libbase.
parents
32fa9ba0
e3734499
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
18 deletions
+31
-18
server/Android.mk
server/Android.mk
+1
-0
server/InterfaceController.cpp
server/InterfaceController.cpp
+11
-7
server/RouteController.cpp
server/RouteController.cpp
+4
-2
server/SoftapController.cpp
server/SoftapController.cpp
+9
-6
server/TetherController.cpp
server/TetherController.cpp
+6
-3
No files found.
server/Android.mk
View file @
6d631575
...
...
@@ -37,6 +37,7 @@ LOCAL_SHARED_LIBRARIES := \
libnetutils
\
libnl
\
libsysutils
\
libbase
\
libutils
\
LOCAL_STATIC_LIBRARIES
:=
\
...
...
This diff is collapsed.
Click to expand it.
server/InterfaceController.cpp
View file @
6d631575
...
...
@@ -19,14 +19,18 @@
#include <malloc.h>
#define LOG_TAG "InterfaceController"
#include <base/file.h>
#include <base/stringprintf.h>
#include <cutils/log.h>
#include <logwrap/logwrap.h>
#include <utils/file.h>
#include <utils/stringprintf.h>
#include "InterfaceController.h"
#include "RouteController.h"
using
android
::
base
::
ReadFileToString
;
using
android
::
base
::
StringPrintf
;
using
android
::
base
::
WriteStringToFile
;
const
char
ipv6_proc_path
[]
=
"/proc/sys/net/ipv6/conf"
;
const
char
sys_net_path
[]
=
"/sys/class/net"
;
...
...
@@ -55,8 +59,8 @@ int InterfaceController::writeIPv6ProcPath(const char *interface, const char *se
errno
=
ENOENT
;
return
-
1
;
}
std
::
string
path
(
android
::
StringPrintf
(
"%s/%s/%s"
,
ipv6_proc_path
,
interface
,
setting
));
return
android
::
WriteStringToFile
(
value
,
path
);
std
::
string
path
(
StringPrintf
(
"%s/%s/%s"
,
ipv6_proc_path
,
interface
,
setting
));
return
WriteStringToFile
(
value
,
path
);
}
int
InterfaceController
::
setEnableIPv6
(
const
char
*
interface
,
const
int
on
)
{
...
...
@@ -133,7 +137,7 @@ void InterfaceController::setAcceptRA(const char *value) {
// ID to get the table. If it's set to -1000, routes from interface ID 5 will go into
// table 1005, etc.
void
InterfaceController
::
setAcceptRARouteTable
(
int
tableOrOffset
)
{
std
::
string
value
(
android
::
StringPrintf
(
"%d"
,
tableOrOffset
));
std
::
string
value
(
StringPrintf
(
"%d"
,
tableOrOffset
));
setOnAllInterfaces
(
"accept_ra_rt_table"
,
value
.
c_str
());
}
...
...
@@ -143,8 +147,8 @@ int InterfaceController::setMtu(const char *interface, const char *mtu)
errno
=
ENOENT
;
return
-
1
;
}
std
::
string
path
(
android
::
StringPrintf
(
"%s/%s/mtu"
,
sys_net_path
,
interface
));
return
android
::
WriteStringToFile
(
mtu
,
path
);
std
::
string
path
(
StringPrintf
(
"%s/%s/mtu"
,
sys_net_path
,
interface
));
return
WriteStringToFile
(
mtu
,
path
);
}
void
InterfaceController
::
setIPv6OptimisticMode
(
const
char
*
value
)
{
...
...
This diff is collapsed.
Click to expand it.
server/RouteController.cpp
View file @
6d631575
...
...
@@ -30,12 +30,14 @@
#include "Fwmark.h"
#include "UidRanges.h"
#include "base/file.h"
#define LOG_TAG "Netd"
#include "log/log.h"
#include "logwrap/logwrap.h"
#include "utils/file.h"
#include "resolv_netid.h"
using
android
::
base
::
WriteStringToFile
;
namespace
{
// BEGIN CONSTANTS --------------------------------------------------------------------------------
...
...
@@ -164,7 +166,7 @@ void updateTableNamesFile() {
addTableName
(
entry
.
second
,
entry
.
first
,
&
contents
);
}
if
(
!
android
::
WriteStringToFile
(
contents
,
RT_TABLES_PATH
,
RT_TABLES_MODE
,
AID_SYSTEM
,
AID_WIFI
))
{
if
(
!
WriteStringToFile
(
contents
,
RT_TABLES_PATH
,
RT_TABLES_MODE
,
AID_SYSTEM
,
AID_WIFI
))
{
ALOGE
(
"failed to write to %s (%s)"
,
RT_TABLES_PATH
,
strerror
(
errno
));
return
;
}
...
...
This diff is collapsed.
Click to expand it.
server/SoftapController.cpp
View file @
6d631575
...
...
@@ -34,16 +34,19 @@
#include <openssl/sha.h>
#define LOG_TAG "SoftapController"
#include <base/file.h>
#include <base/stringprintf.h>
#include <cutils/log.h>
#include <netutils/ifc.h>
#include <private/android_filesystem_config.h>
#include <utils/file.h>
#include <utils/stringprintf.h>
#include "wifi.h"
#include "ResponseCode.h"
#include "SoftapController.h"
using
android
::
base
::
StringPrintf
;
using
android
::
base
::
WriteStringToFile
;
static
const
char
HOSTAPD_CONF_FILE
[]
=
"/data/misc/wifi/hostapd.conf"
;
static
const
char
HOSTAPD_BIN_FILE
[]
=
"/system/bin/hostapd"
;
...
...
@@ -136,7 +139,7 @@ int SoftapController::setSoftap(int argc, char *argv[]) {
channel
=
AP_CHANNEL_DEFAULT
;
}
std
::
string
wbuf
(
android
::
StringPrintf
(
"interface=%s
\n
"
std
::
string
wbuf
(
StringPrintf
(
"interface=%s
\n
"
"driver=nl80211
\n
"
"ctrl_interface=/data/misc/wifi/hostapd
\n
"
"ssid=%s
\n
"
...
...
@@ -152,10 +155,10 @@ int SoftapController::setSoftap(int argc, char *argv[]) {
char
psk_str
[
2
*
SHA256_DIGEST_LENGTH
+
1
];
if
(
!
strcmp
(
argv
[
6
],
"wpa-psk"
))
{
generatePsk
(
argv
[
3
],
argv
[
7
],
psk_str
);
fbuf
=
android
::
StringPrintf
(
"%swpa=3
\n
wpa_pairwise=TKIP CCMP
\n
wpa_psk=%s
\n
"
,
wbuf
.
c_str
(),
psk_str
);
fbuf
=
StringPrintf
(
"%swpa=3
\n
wpa_pairwise=TKIP CCMP
\n
wpa_psk=%s
\n
"
,
wbuf
.
c_str
(),
psk_str
);
}
else
if
(
!
strcmp
(
argv
[
6
],
"wpa2-psk"
))
{
generatePsk
(
argv
[
3
],
argv
[
7
],
psk_str
);
fbuf
=
android
::
StringPrintf
(
"%swpa=2
\n
rsn_pairwise=CCMP
\n
wpa_psk=%s
\n
"
,
wbuf
.
c_str
(),
psk_str
);
fbuf
=
StringPrintf
(
"%swpa=2
\n
rsn_pairwise=CCMP
\n
wpa_psk=%s
\n
"
,
wbuf
.
c_str
(),
psk_str
);
}
else
if
(
!
strcmp
(
argv
[
6
],
"open"
))
{
fbuf
=
wbuf
;
}
...
...
@@ -167,7 +170,7 @@ int SoftapController::setSoftap(int argc, char *argv[]) {
fbuf
=
wbuf
;
}
if
(
!
android
::
WriteStringToFile
(
fbuf
,
HOSTAPD_CONF_FILE
,
0660
,
AID_SYSTEM
,
AID_WIFI
))
{
if
(
!
WriteStringToFile
(
fbuf
,
HOSTAPD_CONF_FILE
,
0660
,
AID_SYSTEM
,
AID_WIFI
))
{
ALOGE
(
"Cannot write to
\"
%s
\"
: %s"
,
HOSTAPD_CONF_FILE
,
strerror
(
errno
));
return
ResponseCode
::
OperationFailed
;
}
...
...
This diff is collapsed.
Click to expand it.
server/TetherController.cpp
View file @
6d631575
...
...
@@ -27,16 +27,19 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <base/file.h>
#define LOG_TAG "TetherController"
#include <cutils/log.h>
#include <cutils/properties.h>
#include <utils/file.h>
#include "Fwmark.h"
#include "NetdConstants.h"
#include "Permission.h"
#include "TetherController.h"
using
android
::
base
::
ReadFileToString
;
using
android
::
base
::
WriteStringToFile
;
TetherController
::
TetherController
()
{
mInterfaces
=
new
InterfaceCollection
();
mDnsNetId
=
0
;
...
...
@@ -67,7 +70,7 @@ int TetherController::setIpFwdEnabled(bool enable) {
return
0
;
}
if
(
!
android
::
WriteStringToFile
(
enable
?
"1"
:
"0"
,
"/proc/sys/net/ipv4/ip_forward"
))
{
if
(
!
WriteStringToFile
(
enable
?
"1"
:
"0"
,
"/proc/sys/net/ipv4/ip_forward"
))
{
ALOGE
(
"Failed to write ip_forward (%s)"
,
strerror
(
errno
));
return
-
1
;
}
...
...
@@ -77,7 +80,7 @@ int TetherController::setIpFwdEnabled(bool enable) {
bool
TetherController
::
getIpFwdEnabled
()
{
std
::
string
enabled
;
if
(
!
android
::
ReadFileToString
(
"/proc/sys/net/ipv4/ip_forward"
,
&
enabled
))
{
if
(
!
ReadFileToString
(
"/proc/sys/net/ipv4/ip_forward"
,
&
enabled
))
{
ALOGE
(
"Failed to read ip_forward (%s)"
,
strerror
(
errno
));
return
-
1
;
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment