rspro_util: Add rspro_IpAddr2str() to get stringified version of IpAddr_t
Change-Id: Ic6cccb00d1d65bdab84178acb1e0525e11bc1315
This commit is contained in:
parent
92bd881c23
commit
0eaa0ef796
|
@ -1,5 +1,8 @@
|
||||||
|
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
#include <asn_application.h>
|
#include <asn_application.h>
|
||||||
#include <der_encoder.h>
|
#include <der_encoder.h>
|
||||||
|
|
||||||
|
@ -114,6 +117,20 @@ void rspro_comp_id_retrieve(struct app_comp_id *out, const ComponentIdentity_t *
|
||||||
string_fromOCTET_STRING_ARRAY(out->fw_version, in->fwVersion);
|
string_fromOCTET_STRING_ARRAY(out->fw_version, in->fwVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *rspro_IpAddr2str(const IpAddress_t *in)
|
||||||
|
{
|
||||||
|
static char buf[128];
|
||||||
|
|
||||||
|
switch (in->present) {
|
||||||
|
case IpAddress_PR_ipv4:
|
||||||
|
return inet_ntop(AF_INET, in->choice.ipv4.buf, buf, sizeof(buf));
|
||||||
|
case IpAddress_PR_ipv6:
|
||||||
|
return inet_ntop(AF_INET6, in->choice.ipv6.buf, buf, sizeof(buf));
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void fill_ip4_port(IpPort_t *out, uint32_t ip, uint16_t port)
|
static void fill_ip4_port(IpPort_t *out, uint32_t ip, uint16_t port)
|
||||||
{
|
{
|
||||||
uint32_t ip_n = htonl(ip);
|
uint32_t ip_n = htonl(ip);
|
||||||
|
|
|
@ -38,3 +38,4 @@ RsproPDU_t *rspro_gen_TpduCard2Modem(const BankSlot_t *bank, const ClientSlot_t
|
||||||
const uint8_t *tpdu, unsigned int tpdu_len);
|
const uint8_t *tpdu, unsigned int tpdu_len);
|
||||||
|
|
||||||
void rspro_comp_id_retrieve(struct app_comp_id *out, const ComponentIdentity_t *in);
|
void rspro_comp_id_retrieve(struct app_comp_id *out, const ComponentIdentity_t *in);
|
||||||
|
const char *rspro_IpAddr2str(const IpAddress_t *in);
|
||||||
|
|
Loading…
Reference in New Issue