#### Pre-Submission Checklist
- [x] Commit message has the format required by CONTRIBUTING guide
- [x] Commits are split per component (core, individual modules, libs, utils, ...)
- [x] Each component has a single commit (if not, squash them into one commit)
- [x] No commits to README files for modules (changes must be done to docbook files
in `doc/` subfolder, the README file is autogenerated)
#### Type Of Change
- [ ] Small bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds new functionality)
- [ ] Breaking change (fix or feature that would change existing functionality)
#### Checklist:
- [x] PR should be backported to stable branches
- [x] Tested changes locally
- [ ] Related to issue #XXXX (replace XXXX with an open issue number)
#### Description
The purpose of this pull request is to allow, when generating rpm's, the possibility of history/autocomplete to be seen in the interactive mode of kamcmd.
The proposed solution is to ensure that the readline-devel library is a requirement when building Kamailio, thus ensuring that kamcmd is compiled with this library.
Currently the specfile has as BuildRequires, the pkgconfig library. This library is installed by the readline-devel library (via ncurses-devel dependency), i.e. all existing logic remains unchanged. Furthermore, the readline-devel library is accessible on all distros that use this specfile, namely: Centos, Fedora, OpenSuse, RedHat.
Initially in my testing, I thought I needed to change the Makefile of kamcmd to look at mock path’s (find path of readline.h), but this is not necessary (at least in CentOS).
The possibility of adopting this solution in later branches would be useful, especially in the case of branch 5.6.1.
The tests were performed in a CentOS 7 environment (docker image), following the usual process for generating the rpm's (make rpm). This solution was tested on branch 5.5.4 and on master. In both cases, the history/autocomplete is successfully visible in the interactive mode of kamcmd.
```Shell Script
[root@kamailio-build kamailio]# cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)
[root@kamailio-build kamailio]# uname -a
Linux kamailio-build 5.10.124-linuxkit #1 SMP PREEMPT Thu Jun 30 08:18:26 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
```
I would appreciate if you could evaluate this solution, since the presence of the autocomplete in kamcmd is very useful. Feel free to adopt changes to the proposed solution.
Thanks.
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/3233
-- Commit Summary --
* pkg/kamailio/obs: added readline-devel build dependency
-- File Changes --
M pkg/kamailio/obs/kamailio.spec (4)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/3233.patchhttps://github.com/kamailio/kamailio/pull/3233.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/3233
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/pull/3233(a)github.com>
Module: kamailio
Branch: master
Commit: 8bdee74fa6b68012919ddbb403da372187631bd9
URL: https://github.com/kamailio/kamailio/commit/8bdee74fa6b68012919ddbb403da372…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2022-09-16T16:42:16+02:00
core: helper function to get address family name
---
Modified: src/core/ip_addr.c
Modified: src/core/ip_addr.h
---
Diff: https://github.com/kamailio/kamailio/commit/8bdee74fa6b68012919ddbb403da372…
Patch: https://github.com/kamailio/kamailio/commit/8bdee74fa6b68012919ddbb403da372…
---
diff --git a/src/core/ip_addr.c b/src/core/ip_addr.c
index 77ac233eee..9c91c60e4e 100644
--- a/src/core/ip_addr.c
+++ b/src/core/ip_addr.c
@@ -717,6 +717,22 @@ char* get_proto_name(unsigned int proto)
}
}
+/** get address family name (asciiz).
+ * @param af - address family id
+ * @return string with the adderess family name or "unknown".
+ */
+char* get_af_name(unsigned int af)
+{
+ switch(af) {
+ case AF_INET:
+ return "IPv4";
+ case AF_INET6:
+ return "IPv6";
+ default:
+ return "unknown";
+ }
+}
+
/**
* match ip address with net address and bitmask
diff --git a/src/core/ip_addr.h b/src/core/ip_addr.h
index 4fcdebbe3e..7f910a49ce 100644
--- a/src/core/ip_addr.h
+++ b/src/core/ip_addr.h
@@ -304,6 +304,8 @@ char* get_proto_name(unsigned int proto);
int get_valid_proto_string(unsigned int iproto, int utype, int vtype,
str *sproto);
+char* get_af_name(unsigned int af);
+
#ifdef USE_MCAST
/* Returns 1 if the given address is a multicast address */
int is_mcast(struct ip_addr* ip);