Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
BC
public
external
sofia-sip
Commits
4a79fa66
Commit
4a79fa66
authored
Feb 27, 2008
by
Michael Jerris
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
line endings
darcs-hash:20080227213604-16063-850c768c098b4c6d833080213bba4c8e82aa774d.gz
parent
1e871a6b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
148 additions
and
148 deletions
+148
-148
libsofia-sip-ua/su/inet_ntop.c
libsofia-sip-ua/su/inet_ntop.c
+1
-1
libsofia-sip-ua/su/su_open_c_localinfo.cpp
libsofia-sip-ua/su/su_open_c_localinfo.cpp
+147
-147
No files found.
libsofia-sip-ua/su/inet_ntop.c
View file @
4a79fa66
...
...
@@ -79,7 +79,7 @@ inet_ntop4(const unsigned char *src, char *dst, size_t size)
static
const
char
fmt
[]
=
"%u.%u.%u.%u"
;
char
tmp
[
sizeof
"255.255.255.255"
];
if
(
snprintf
(
tmp
,
sizeof
tmp
,
fmt
,
if
(
snprintf
(
tmp
,
sizeof
tmp
,
fmt
,
src
[
0
],
src
[
1
],
src
[
2
],
src
[
3
])
>=
size
)
{
su_seterrno
(
ENOSPC
);
return
NULL
;
...
...
libsofia-sip-ua/su/su_open_c_localinfo.cpp
View file @
4a79fa66
/*
* This file is part of the Sofia-SIP package
*
* Copyright (C) 2005 Nokia Corporation.
*
* Contact: Pekka Pessi <pekka.pessi@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
/**@ingroup su_open_c_localinfo.cpp
*
* @CFILE su_open_c_localinfo.cpp
* Functionality for choosing an access point for sockets on Symbian.
*
* @author Martti Mela <Martti.Mela@nokia.com>
* @date Created: Fri May 18 14:31:41 2007 mela
*
*/
#include "config.h"
#include <unistd.h>
#include <in_sock.h>
#include <es_sock.h>
#include <e32base.h>
#include <s32mem.h>
#include <s32strm.h>
#include <commdbconnpref.h>
#include <sofia-sip/su.h>
su_sockaddr_t
sa_global
[
1
];
/* Copy IP address for the sockaddr structure.
*
* @param su pointer to allocated su_sockaddr_t structure
*
* @return 0 if successful.
*/
extern
"C"
int
su_get_local_ip_addr
(
su_sockaddr_t
*
su
)
{
su
->
su_sin
.
sin_addr
.
s_addr
=
sa_global
->
su_sin
.
sin_addr
.
s_addr
;
su
->
su_family
=
sa_global
->
su_family
;
su
->
su_len
=
sa_global
->
su_len
;
return
0
;
}
/* Set up the access point for the stack. Code adapted from Forum Nokia,
* http://wiki.forum.nokia.com/index.php/LocalDeviceIpAddress.
*
* @param su su_sockaddr_t structure
* @param ifindex pointer to interface index
*
* @return Connection object
*/
extern
"C"
void
*
su_localinfo_ap_set
(
su_sockaddr_t
*
su
,
int
*
ifindex
)
{
TCommDbConnPref
iPref
;
RSocketServ
aSocketServ
;
RSocket
sock
;
/* Get the IAP id of the underlying interface of this RConnection */
TUint32
iapId
;
iPref
.
SetDirection
(
ECommDbConnectionDirectionOutgoing
);
iPref
.
SetDialogPreference
(
ECommDbDialogPrefPrompt
);
iPref
.
SetBearerSet
(
KCommDbBearerUnknown
/*PSD*/
);
aSocketServ
=
RSocketServ
();
aSocketServ
.
Connect
();
RConnection
*
aConnection
=
new
RConnection
();
aConnection
->
Open
(
aSocketServ
);
aConnection
->
Start
(
iPref
);
User
::
LeaveIfError
(
sock
.
Open
(
aSocketServ
,
KAfInet
,
KSockStream
,
KProtocolInetTcp
));
User
::
LeaveIfError
(
aConnection
->
GetIntSetting
(
_L
(
"IAP
\\
Id"
),
iapId
));
/* Get IP information from the socket */
TSoInetInterfaceInfo
ifinfo
;
TPckg
<
TSoInetInterfaceInfo
>
ifinfopkg
(
ifinfo
);
TSoInetIfQuery
ifquery
;
TPckg
<
TSoInetIfQuery
>
ifquerypkg
(
ifquery
);
/* To find out which interfaces are using our current IAP, we
* must enumerate and go through all of them and make a query
* by name for each. */
User
::
LeaveIfError
(
sock
.
SetOpt
(
KSoInetEnumInterfaces
,
KSolInetIfCtrl
));
while
(
sock
.
GetOpt
(
KSoInetNextInterface
,
KSolInetIfCtrl
,
ifinfopkg
)
==
KErrNone
)
{
ifquery
.
iName
=
ifinfo
.
iName
;
TInt
err
=
sock
.
GetOpt
(
KSoInetIfQueryByName
,
KSolInetIfQuery
,
ifquerypkg
);
/* IAP ID is index 1 of iZone */
if
(
err
==
KErrNone
&&
ifquery
.
iZone
[
1
]
==
iapId
)
{
/* We have found an interface using the IAP we are interested in. */
if
(
ifinfo
.
iAddress
.
Address
()
>
0
)
{
/* found a IPv4 address */
su
->
su_sin
.
sin_addr
.
s_addr
=
htonl
(
ifinfo
.
iAddress
.
Address
());
sa_global
->
su_sin
.
sin_addr
.
s_addr
=
su
->
su_sin
.
sin_addr
.
s_addr
;
sa_global
->
su_family
=
su
->
su_family
=
AF_INET
;
sa_global
->
su_len
=
su
->
su_len
=
28
;
*
ifindex
=
iapId
;
return
(
void
*
)
aConnection
;
}
}
else
if
(
err
!=
KErrNone
)
break
;
}
sock
.
Close
();
}
/* Deinitialize the access point in use.
*
* @param aconn Pointer to connection object
*
* @return 0 if successful.
*/
extern
"C"
int
su_localinfo_ap_deinit
(
void
*
aconn
)
{
RConnection
*
aConnection
=
(
RConnection
*
)
aconn
;
aConnection
->
Stop
();
aConnection
->
Close
();
delete
aConnection
;
return
0
;
}
/*
* This file is part of the Sofia-SIP package
*
* Copyright (C) 2005 Nokia Corporation.
*
* Contact: Pekka Pessi <pekka.pessi@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
/**@ingroup su_open_c_localinfo.cpp
*
* @CFILE su_open_c_localinfo.cpp
* Functionality for choosing an access point for sockets on Symbian.
*
* @author Martti Mela <Martti.Mela@nokia.com>
* @date Created: Fri May 18 14:31:41 2007 mela
*
*/
#include "config.h"
#include <unistd.h>
#include <in_sock.h>
#include <es_sock.h>
#include <e32base.h>
#include <s32mem.h>
#include <s32strm.h>
#include <commdbconnpref.h>
#include <sofia-sip/su.h>
su_sockaddr_t
sa_global
[
1
];
/* Copy IP address for the sockaddr structure.
*
* @param su pointer to allocated su_sockaddr_t structure
*
* @return 0 if successful.
*/
extern
"C"
int
su_get_local_ip_addr
(
su_sockaddr_t
*
su
)
{
su
->
su_sin
.
sin_addr
.
s_addr
=
sa_global
->
su_sin
.
sin_addr
.
s_addr
;
su
->
su_family
=
sa_global
->
su_family
;
su
->
su_len
=
sa_global
->
su_len
;
return
0
;
}
/* Set up the access point for the stack. Code adapted from Forum Nokia,
* http://wiki.forum.nokia.com/index.php/LocalDeviceIpAddress.
*
* @param su su_sockaddr_t structure
* @param ifindex pointer to interface index
*
* @return Connection object
*/
extern
"C"
void
*
su_localinfo_ap_set
(
su_sockaddr_t
*
su
,
int
*
ifindex
)
{
TCommDbConnPref
iPref
;
RSocketServ
aSocketServ
;
RSocket
sock
;
/* Get the IAP id of the underlying interface of this RConnection */
TUint32
iapId
;
iPref
.
SetDirection
(
ECommDbConnectionDirectionOutgoing
);
iPref
.
SetDialogPreference
(
ECommDbDialogPrefPrompt
);
iPref
.
SetBearerSet
(
KCommDbBearerUnknown
/*PSD*/
);
aSocketServ
=
RSocketServ
();
aSocketServ
.
Connect
();
RConnection
*
aConnection
=
new
RConnection
();
aConnection
->
Open
(
aSocketServ
);
aConnection
->
Start
(
iPref
);
User
::
LeaveIfError
(
sock
.
Open
(
aSocketServ
,
KAfInet
,
KSockStream
,
KProtocolInetTcp
));
User
::
LeaveIfError
(
aConnection
->
GetIntSetting
(
_L
(
"IAP
\\
Id"
),
iapId
));
/* Get IP information from the socket */
TSoInetInterfaceInfo
ifinfo
;
TPckg
<
TSoInetInterfaceInfo
>
ifinfopkg
(
ifinfo
);
TSoInetIfQuery
ifquery
;
TPckg
<
TSoInetIfQuery
>
ifquerypkg
(
ifquery
);
/* To find out which interfaces are using our current IAP, we
* must enumerate and go through all of them and make a query
* by name for each. */
User
::
LeaveIfError
(
sock
.
SetOpt
(
KSoInetEnumInterfaces
,
KSolInetIfCtrl
));
while
(
sock
.
GetOpt
(
KSoInetNextInterface
,
KSolInetIfCtrl
,
ifinfopkg
)
==
KErrNone
)
{
ifquery
.
iName
=
ifinfo
.
iName
;
TInt
err
=
sock
.
GetOpt
(
KSoInetIfQueryByName
,
KSolInetIfQuery
,
ifquerypkg
);
/* IAP ID is index 1 of iZone */
if
(
err
==
KErrNone
&&
ifquery
.
iZone
[
1
]
==
iapId
)
{
/* We have found an interface using the IAP we are interested in. */
if
(
ifinfo
.
iAddress
.
Address
()
>
0
)
{
/* found a IPv4 address */
su
->
su_sin
.
sin_addr
.
s_addr
=
htonl
(
ifinfo
.
iAddress
.
Address
());
sa_global
->
su_sin
.
sin_addr
.
s_addr
=
su
->
su_sin
.
sin_addr
.
s_addr
;
sa_global
->
su_family
=
su
->
su_family
=
AF_INET
;
sa_global
->
su_len
=
su
->
su_len
=
28
;
*
ifindex
=
iapId
;
return
(
void
*
)
aConnection
;
}
}
else
if
(
err
!=
KErrNone
)
break
;
}
sock
.
Close
();
}
/* Deinitialize the access point in use.
*
* @param aconn Pointer to connection object
*
* @return 0 if successful.
*/
extern
"C"
int
su_localinfo_ap_deinit
(
void
*
aconn
)
{
RConnection
*
aConnection
=
(
RConnection
*
)
aconn
;
aConnection
->
Stop
();
aConnection
->
Close
();
delete
aConnection
;
return
0
;
}
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