• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #define LOG_TAG "SupplicantConnectedEvent"
18 #include <cutils/log.h>
19 
20 #include "SupplicantConnectedEvent.h"
21 
SupplicantConnectedEvent(int level,char * event,size_t len)22 SupplicantConnectedEvent::SupplicantConnectedEvent(int level, char *event,
23                                                    size_t len) :
24                           SupplicantEvent(SupplicantEvent::EVENT_CONNECTED,
25                                           level) {
26     char *p;
27 
28     //  "- Connection to 00:13:46:40:40:aa completed (auth) [id=1 id_str=], 89"
29 
30     if ((p = index(event + 2, ' ')) && (++p = index(p, ' '))) {
31         mBssid = (char *) malloc(18);
32         strncpy(mBssid, ++p, 17);
33         mBssid[17] = '\0';
34 
35         //  "- Connection to 00:13:46:40:40:aa completed (auth) [id=1 id_str=], 89"
36         //                   ^
37         //                   p
38 
39         if ((p = index(p, ' ')) && ((++p = index(p, ' ')))) {
40             if (!strncmp(++p, "(auth)", 6))
41                 mReassociated = false;
42             else
43                 mReassociated = true;
44         } else
45             LOGE("Unable to decode re-assocation");
46     } else
47         LOGE("Unable to decode event");
48 }
49 
SupplicantConnectedEvent(const char * bssid,bool reassocated)50 SupplicantConnectedEvent::SupplicantConnectedEvent(const char *bssid,
51                                                    bool reassocated) :
52                           SupplicantEvent(SupplicantEvent::EVENT_CONNECTED, -1) {
53     mBssid = strdup(bssid);
54     mReassociated = reassocated;
55 }
56 
~SupplicantConnectedEvent()57 SupplicantConnectedEvent::~SupplicantConnectedEvent() {
58     if (mBssid)
59         free(mBssid);
60 }
61 
62