SoftapController.cpp revision 5af38c360587ca2eef0badf6137ccf018f8cd4aa
1/* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#include <stdlib.h> 18#include <errno.h> 19#include <fcntl.h> 20 21#include <sys/socket.h> 22#include <sys/stat.h> 23#include <sys/types.h> 24#include <sys/wait.h> 25 26#include <netinet/in.h> 27#include <arpa/inet.h> 28 29#define LOG_TAG "SoftapController" 30#include <cutils/log.h> 31 32#include "SoftapController.h" 33 34SoftapController::SoftapController() { 35 mPid = 0; 36} 37 38SoftapController::~SoftapController() { 39} 40 41int SoftapController::startSoftap() { 42 pid_t pid = 1; 43 44 LOGD("Softap start"); 45 if (mPid) { 46 LOGE("Softap already started"); 47 errno = EBUSY; 48 return -1; 49 } 50#if 0 51 if ((pid = fork()) < 0) { 52 LOGE("fork failed (%s)", strerror(errno)); 53 return -1; 54 } 55#endif 56 if (!pid) { 57 LOGE("Softap Started"); 58 return 0; 59 } else { 60 mPid = pid; 61 } 62 return 0; 63 64} 65 66int SoftapController::stopSoftap() { 67 LOGD("Softap stop"); 68 if (mPid == 0) { 69 LOGE("Softap already stopped"); 70 return 0; 71 } 72#if 0 73 LOGD("Stopping Softap service"); 74 kill(mPid, SIGTERM); 75 waitpid(mPid, NULL, 0); 76#endif 77 mPid = 0; 78 LOGD("Softap service stopped"); 79 return 0; 80} 81 82bool SoftapController::isSoftapStarted() { 83 return (mPid != 0 ? true : false); 84} 85 86int SoftapController::setSoftap(int argc, char *argv[]) { 87 LOGD("Softap set"); 88 return 0; 89} 90