|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: ApnSettings.app |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <string> |
|
21 #include<stdio.h> |
|
22 #include <sys/types.h> |
|
23 #include <sys/socket.h> |
|
24 #include <net/if.h> |
|
25 #include "logger.h" |
|
26 #include "apnsettings.h" |
|
27 |
|
28 using namespace java; |
|
29 |
|
30 int ApnSettings::setDefaultApn(int aType, int aApn) |
|
31 { |
|
32 struct ifreq ifr; |
|
33 int def = 0; |
|
34 |
|
35 #ifdef RD_JAVA_OPENC_BETA_PATCH |
|
36 if (aType == 2 || aType == 3) |
|
37 { |
|
38 if (aType == 3) // IAP ID |
|
39 { |
|
40 char * interfacename = new char[512]; |
|
41 |
|
42 char * fret = if_indextoname(aApn,interfacename); |
|
43 strcpy(ifr.ifr_name, interfacename); |
|
44 ILOG1(ESOCKET, "interface name is %s",interfacename); |
|
45 } |
|
46 else |
|
47 { |
|
48 if (aType == 2) // SNAP ID |
|
49 { |
|
50 memset(&ifr, 0, sizeof(struct ifreq)); |
|
51 ifr.ifr_ifru.snap_id = aApn; |
|
52 } |
|
53 } |
|
54 def = setdefaultif(&ifr); |
|
55 ILOG(ESOCKET, "sedefaultif called"); |
|
56 } |
|
57 ILOG1(ESOCKET, "sedefaultif returned %d",def); |
|
58 // if(def == -1) |
|
59 //{ |
|
60 // LOG(ESOCKET, "default access point interface is removed"); |
|
61 // setdefaultif(NULL); |
|
62 //} |
|
63 #endif |
|
64 |
|
65 |
|
66 return def; |
|
67 } |
|
68 |
|
69 void ApnSettings::removeDefaultApn() |
|
70 { |
|
71 |
|
72 int def = 0; |
|
73 |
|
74 #ifdef RD_JAVA_OPENC_BETA_PATCH |
|
75 def = setdefaultif(NULL); |
|
76 ILOG(ESOCKET, "sedefaultif called"); |
|
77 #endif |
|
78 (void)def; //just to suppress a warning |
|
79 ILOG1(ESOCKET, "remove default apn returned %d",def); |
|
80 |
|
81 } |