From 9336256027d86d6530698e4abf9c2234339ab80c Mon Sep 17 00:00:00 2001 From: Dante Russo Date: Thu, 2 Apr 2015 15:23:07 -0700 Subject: [PATCH] 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 --- core/gps_extended_c.h | 2 +- loc_api/libloc_api_50001/loc.cpp | 48 ++++++++++++++++++++++- loc_api/libloc_api_50001/loc_eng_agps.cpp | 4 +- loc_api/libloc_api_50001/loc_eng_agps.h | 12 ++++++ 4 files changed, 62 insertions(+), 4 deletions(-) diff --git a/core/gps_extended_c.h b/core/gps_extended_c.h index 183fa411..27deb442 100644 --- a/core/gps_extended_c.h +++ b/core/gps_extended_c.h @@ -148,7 +148,7 @@ typedef struct { AGpsExtType type; AGpsStatusValue status; uint32_t ipv4_addr; - char ipv6_addr[16]; + struct sockaddr_storage addr; char ssid[SSID_BUF_SIZE]; char password[SSID_BUF_SIZE]; } AGpsExtStatus; diff --git a/loc_api/libloc_api_50001/loc.cpp b/loc_api/libloc_api_50001/loc.cpp index 4076ce3e..505fc940 100644 --- a/loc_api/libloc_api_50001/loc.cpp +++ b/loc_api/libloc_api_50001/loc.cpp @@ -91,6 +91,7 @@ static int loc_agps_open(const char* apn); static int loc_agps_closed(); static int loc_agps_open_failed(); 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 = { @@ -99,7 +100,8 @@ static const AGpsInterface sLocEngAGpsInterface = loc_agps_open, loc_agps_closed, loc_agps_open_failed, - loc_agps_set_server + loc_agps_set_server, + loc_agps_open_with_apniptype }; static int loc_xtra_init(GpsXtraCallbacks* callbacks); @@ -694,6 +696,50 @@ static int loc_agps_open(const char* apn) 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 diff --git a/loc_api/libloc_api_50001/loc_eng_agps.cpp b/loc_api/libloc_api_50001/loc_eng_agps.cpp index d6cc1369..5016b5c4 100644 --- a/loc_api/libloc_api_50001/loc_eng_agps.cpp +++ b/loc_api/libloc_api_50001/loc_eng_agps.cpp @@ -762,11 +762,11 @@ int AgpsStateMachine::sendRsrcRequest(AGpsStatusValue action) const if (s == NULL) { nifRequest.ipv4_addr = INADDR_NONE; - nifRequest.ipv6_addr[0] = 0; + memset(&nifRequest.addr, 0, sizeof(nifRequest.addr)); nifRequest.ssid[0] = '\0'; nifRequest.password[0] = '\0'; } else { - s->setIPAddresses(nifRequest.ipv4_addr, (char*)nifRequest.ipv6_addr); + s->setIPAddresses(nifRequest.addr); s->setWifiInfo(nifRequest.ssid, nifRequest.password); } diff --git a/loc_api/libloc_api_50001/loc_eng_agps.h b/loc_api/libloc_api_50001/loc_eng_agps.h index 055d955b..2d689cee 100644 --- a/loc_api/libloc_api_50001/loc_eng_agps.h +++ b/loc_api/libloc_api_50001/loc_eng_agps.h @@ -276,6 +276,7 @@ struct Subscriber { inline virtual ~Subscriber() {} 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) { ssid[0] = 0; password[0] = 0; } @@ -316,6 +317,9 @@ struct BITSubscriber : public Subscriber { inline virtual void setIPAddresses(uint32_t &v4, char* v6) { 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() { return new BITSubscriber(mStateMachine, ID, mIPv6Addr); @@ -340,6 +344,9 @@ struct ATLSubscriber : public Subscriber { inline virtual void setIPAddresses(uint32_t &v4, char* v6) { v4 = INADDR_NONE; v6[0] = 0; } + inline virtual void setIPAddresses(struct sockaddr_storage& addr) + { addr.ss_family = AF_INET6; } + inline virtual Subscriber* clone() { 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(struct sockaddr_storage& addr) + { addr.ss_family = AF_INET6; } + inline virtual void setWifiInfo(char* ssid, char* password) { if (NULL != mSSID) @@ -405,6 +415,8 @@ struct DSSubscriber : public Subscriber { mIsInactive = false; } 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() {return new DSSubscriber(mStateMachine, ID);} virtual bool notifyRsrcStatus(Notification ¬ification);