1fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey/*
2fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey * Copyright (C) 2014 The Android Open Source Project
3fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey *
4fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey * Licensed under the Apache License, Version 2.0 (the "License");
5fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey * you may not use this file except in compliance with the License.
6fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey * You may obtain a copy of the License at
7fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey *
8fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey *      http://www.apache.org/licenses/LICENSE-2.0
9fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey *
10fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey * Unless required by applicable law or agreed to in writing, software
11fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey * distributed under the License is distributed on an "AS IS" BASIS,
12fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey * See the License for the specific language governing permissions and
14fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey * limitations under the License.
15fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey */
16fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey
17fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey#ifndef _STRICT_CONTROLLER_H
18fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey#define _STRICT_CONTROLLER_H
19fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey
20fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey#include <string>
21fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey
229028d91fd86a2d517c7ce163c1d88b41de961ba8Lorenzo Colitti#include "NetdConstants.h"
239028d91fd86a2d517c7ce163c1d88b41de961ba8Lorenzo Colitti
24fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkeyenum StrictPenalty { INVALID, ACCEPT, LOG, REJECT };
25fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey
26fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey/*
27fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey * Help apps catch unwanted low-level networking behavior, like
28fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey * connections not wrapped in TLS.
29fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey */
30fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkeyclass StrictController {
31fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkeypublic:
32fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey    StrictController();
33fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey
34fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey    int enableStrict(void);
35fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey    int disableStrict(void);
36fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey
37fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey    int setUidCleartextPenalty(uid_t, StrictPenalty);
38fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey
39fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey    static const char* LOCAL_OUTPUT;
40fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey    static const char* LOCAL_CLEAR_DETECT;
41fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey    static const char* LOCAL_CLEAR_CAUGHT;
42fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey    static const char* LOCAL_PENALTY_LOG;
43fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey    static const char* LOCAL_PENALTY_REJECT;
449028d91fd86a2d517c7ce163c1d88b41de961ba8Lorenzo Colitti
459028d91fd86a2d517c7ce163c1d88b41de961ba8Lorenzo Colittiprotected:
469028d91fd86a2d517c7ce163c1d88b41de961ba8Lorenzo Colitti    // For testing.
479028d91fd86a2d517c7ce163c1d88b41de961ba8Lorenzo Colitti    friend class StrictControllerTest;
48e60c0a51957596788995ec57d33531cd103d8dd7Lorenzo Colitti    static int (*execIptablesRestore)(IptablesTarget target, const std::string& commands);
49fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey};
50fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey
51fbe497fcd808e4317572ad48c42545105309a347Jeff Sharkey#endif
52