Add support for new sockaddr_storage struct

In order to handle ipv6 requests, a new struct
is being used instead of an array to store ipv6
info

CRs-Fixed: 817295
Change-Id: I030d4206c01724f08b311697f0bbefb1f9fd10e6
This commit is contained in:
Dante Russo 2015-04-02 15:23:07 -07:00 committed by Gerrit - the friendly Code Review server
parent 7fc64a6c2f
commit 9336256027
4 changed files with 62 additions and 4 deletions

View file

@ -148,7 +148,7 @@ typedef struct {
AGpsExtType type; AGpsExtType type;
AGpsStatusValue status; AGpsStatusValue status;
uint32_t ipv4_addr; uint32_t ipv4_addr;
char ipv6_addr[16]; struct sockaddr_storage addr;
char ssid[SSID_BUF_SIZE]; char ssid[SSID_BUF_SIZE];
char password[SSID_BUF_SIZE]; char password[SSID_BUF_SIZE];
} AGpsExtStatus; } AGpsExtStatus;

View file

@ -91,6 +91,7 @@ static int loc_agps_open(const char* apn);
static int loc_agps_closed(); static int loc_agps_closed();
static int loc_agps_open_failed(); static int loc_agps_open_failed();
static int loc_agps_set_server(AGpsType type, const char *hostname, int port); static int loc_agps_set_server(AGpsType type, const char *hostname, int port);
static int loc_agps_open_with_apniptype( const char* apn, ApnIpType apnIpType);
static const AGpsInterface sLocEngAGpsInterface = static const AGpsInterface sLocEngAGpsInterface =
{ {
@ -99,7 +100,8 @@ static const AGpsInterface sLocEngAGpsInterface =
loc_agps_open, loc_agps_open,
loc_agps_closed, loc_agps_closed,
loc_agps_open_failed, loc_agps_open_failed,
loc_agps_set_server loc_agps_set_server,
loc_agps_open_with_apniptype
}; };
static int loc_xtra_init(GpsXtraCallbacks* callbacks); static int loc_xtra_init(GpsXtraCallbacks* callbacks);
@ -694,6 +696,50 @@ static int loc_agps_open(const char* apn)
return ret_val; return ret_val;
} }
/*===========================================================================
FUNCTION loc_agps_open_with_apniptype
DESCRIPTION
This function is called when on-demand data connection opening is successful.
It should inform ARM 9 about the data open result.
DEPENDENCIES
NONE
RETURN VALUE
0
SIDE EFFECTS
N/A
===========================================================================*/
static int loc_agps_open_with_apniptype(const char* apn, ApnIpType apnIpType)
{
ENTRY_LOG();
AGpsType agpsType = AGPS_TYPE_SUPL;
AGpsBearerType bearerType;
switch (apnIpType) {
case APN_IP_IPV4:
bearerType = AGPS_APN_BEARER_IPV4;
break;
case APN_IP_IPV6:
bearerType = AGPS_APN_BEARER_IPV6;
break;
case APN_IP_IPV4V6:
bearerType = AGPS_APN_BEARER_IPV4V6;
break;
default:
bearerType = AGPS_APN_BEARER_INVALID;
break;
}
int ret_val = loc_eng_agps_open(loc_afw_data, agpsType, apn, bearerType);
EXIT_LOG(%d, ret_val);
return ret_val;
}
/*=========================================================================== /*===========================================================================
FUNCTION loc_agps_closed FUNCTION loc_agps_closed

View file

@ -762,11 +762,11 @@ int AgpsStateMachine::sendRsrcRequest(AGpsStatusValue action) const
if (s == NULL) { if (s == NULL) {
nifRequest.ipv4_addr = INADDR_NONE; nifRequest.ipv4_addr = INADDR_NONE;
nifRequest.ipv6_addr[0] = 0; memset(&nifRequest.addr, 0, sizeof(nifRequest.addr));
nifRequest.ssid[0] = '\0'; nifRequest.ssid[0] = '\0';
nifRequest.password[0] = '\0'; nifRequest.password[0] = '\0';
} else { } else {
s->setIPAddresses(nifRequest.ipv4_addr, (char*)nifRequest.ipv6_addr); s->setIPAddresses(nifRequest.addr);
s->setWifiInfo(nifRequest.ssid, nifRequest.password); s->setWifiInfo(nifRequest.ssid, nifRequest.password);
} }

View file

@ -276,6 +276,7 @@ struct Subscriber {
inline virtual ~Subscriber() {} inline virtual ~Subscriber() {}
virtual void setIPAddresses(uint32_t &v4, char* v6) = 0; virtual void setIPAddresses(uint32_t &v4, char* v6) = 0;
virtual void setIPAddresses(struct sockaddr_storage& addr) = 0;
inline virtual void setWifiInfo(char* ssid, char* password) inline virtual void setWifiInfo(char* ssid, char* password)
{ ssid[0] = 0; password[0] = 0; } { ssid[0] = 0; password[0] = 0; }
@ -316,6 +317,9 @@ struct BITSubscriber : public Subscriber {
inline virtual void setIPAddresses(uint32_t &v4, char* v6) inline virtual void setIPAddresses(uint32_t &v4, char* v6)
{ v4 = ID; memcpy(v6, mIPv6Addr, sizeof(mIPv6Addr)); } { v4 = ID; memcpy(v6, mIPv6Addr, sizeof(mIPv6Addr)); }
inline virtual void setIPAddresses(struct sockaddr_storage& addr)
{ addr.ss_family = AF_INET6;/*todo: convert mIPv6Addr into addr */ }
virtual Subscriber* clone() virtual Subscriber* clone()
{ {
return new BITSubscriber(mStateMachine, ID, mIPv6Addr); return new BITSubscriber(mStateMachine, ID, mIPv6Addr);
@ -340,6 +344,9 @@ struct ATLSubscriber : public Subscriber {
inline virtual void setIPAddresses(uint32_t &v4, char* v6) inline virtual void setIPAddresses(uint32_t &v4, char* v6)
{ v4 = INADDR_NONE; v6[0] = 0; } { v4 = INADDR_NONE; v6[0] = 0; }
inline virtual void setIPAddresses(struct sockaddr_storage& addr)
{ addr.ss_family = AF_INET6; }
inline virtual Subscriber* clone() inline virtual Subscriber* clone()
{ {
return new ATLSubscriber(ID, mStateMachine, mLocAdapter, return new ATLSubscriber(ID, mStateMachine, mLocAdapter,
@ -372,6 +379,9 @@ struct WIFISubscriber : public Subscriber {
inline virtual void setIPAddresses(uint32_t &v4, char* v6) {} inline virtual void setIPAddresses(uint32_t &v4, char* v6) {}
inline virtual void setIPAddresses(struct sockaddr_storage& addr)
{ addr.ss_family = AF_INET6; }
inline virtual void setWifiInfo(char* ssid, char* password) inline virtual void setWifiInfo(char* ssid, char* password)
{ {
if (NULL != mSSID) if (NULL != mSSID)
@ -405,6 +415,8 @@ struct DSSubscriber : public Subscriber {
mIsInactive = false; mIsInactive = false;
} }
inline virtual void setIPAddresses(uint32_t &v4, char* v6) {} inline virtual void setIPAddresses(uint32_t &v4, char* v6) {}
inline virtual void setIPAddresses(struct sockaddr_storage& addr)
{ addr.ss_family = AF_INET6; }
virtual Subscriber* clone() virtual Subscriber* clone()
{return new DSSubscriber(mStateMachine, ID);} {return new DSSubscriber(mStateMachine, ID);}
virtual bool notifyRsrcStatus(Notification &notification); virtual bool notifyRsrcStatus(Notification &notification);