aboutsummaryrefslogtreecommitdiffstats
path: root/src/ipaccess/ipaccess-find.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipaccess/ipaccess-find.c')
-rw-r--r--src/ipaccess/ipaccess-find.c54
1 files changed, 17 insertions, 37 deletions
diff --git a/src/ipaccess/ipaccess-find.c b/src/ipaccess/ipaccess-find.c
index bea4b77ad..3f9bf4140 100644
--- a/src/ipaccess/ipaccess-find.c
+++ b/src/ipaccess/ipaccess-find.c
@@ -21,37 +21,16 @@
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
-#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
-#include <osmocore/select.h>
-#include <osmocore/timer.h>
+#include <osmocom/core/select.h>
+#include <osmocom/core/timer.h>
#include <openbsc/ipaccess.h>
#include <openbsc/gsm_data.h>
-static const char *idtag_names[] = {
- [IPAC_IDTAG_SERNR] = "Serial Number",
- [IPAC_IDTAG_UNITNAME] = "Unit Name",
- [IPAC_IDTAG_LOCATION1] = "Location 1",
- [IPAC_IDTAG_LOCATION2] = "Location 2",
- [IPAC_IDTAG_EQUIPVERS] = "Equipment Version",
- [IPAC_IDTAG_SWVERSION] = "Software Version",
- [IPAC_IDTAG_IPADDR] = "IP Address",
- [IPAC_IDTAG_MACADDR] = "MAC Address",
- [IPAC_IDTAG_UNIT] = "Unit ID",
-};
-
-static const char *ipac_idtag_name(int tag)
-{
- if (tag >= ARRAY_SIZE(idtag_names))
- return "unknown";
-
- return idtag_names[tag];
-}
-
static int udp_sock(const char *ifname)
{
int fd, rc, bc = 1;
@@ -125,15 +104,15 @@ static int bcast_find(int fd)
static int parse_response(unsigned char *buf, int len)
{
- u_int8_t t_len;
- u_int8_t t_tag;
- u_int8_t *cur = buf;
+ uint8_t t_len;
+ uint8_t t_tag;
+ uint8_t *cur = buf;
while (cur < buf + len) {
t_len = *cur++;
t_tag = *cur++;
- printf("%s='%s' ", ipac_idtag_name(t_tag), cur);
+ printf("%s='%s' ", ipaccess_idtag_name(t_tag), cur);
cur += t_len;
}
@@ -162,7 +141,7 @@ static int read_response(int fd)
return parse_response(buf+6, len-6);
}
-static int bfd_cb(struct bsc_fd *bfd, unsigned int flags)
+static int bfd_cb(struct osmo_fd *bfd, unsigned int flags)
{
if (flags & BSC_FD_READ)
return read_response(bfd->fd);
@@ -173,21 +152,21 @@ static int bfd_cb(struct bsc_fd *bfd, unsigned int flags)
return 0;
}
-static struct timer_list timer;
+static struct osmo_timer_list timer;
static void timer_cb(void *_data)
{
- struct bsc_fd *bfd = _data;
+ struct osmo_fd *bfd = _data;
bfd->when |= BSC_FD_WRITE;
- bsc_schedule_timer(&timer, 5, 0);
+ osmo_timer_schedule(&timer, 5, 0);
}
int main(int argc, char **argv)
{
- struct bsc_fd bfd;
- char *ifname;
+ struct osmo_fd bfd;
+ char *ifname = NULL;
int rc;
printf("ipaccess-find (C) 2009 by Harald Welte\n");
@@ -196,9 +175,10 @@ int main(int argc, char **argv)
if (argc < 2) {
fprintf(stdout, "you might need to specify the outgoing\n"
" network interface, e.g. ``%s eth0''\n", argv[0]);
+ } else {
+ ifname = argv[1];
}
- ifname = argv[1];
bfd.cb = bfd_cb;
bfd.when = BSC_FD_READ | BSC_FD_WRITE;
bfd.fd = udp_sock(ifname);
@@ -207,17 +187,17 @@ int main(int argc, char **argv)
exit(1);
}
- bsc_register_fd(&bfd);
+ osmo_fd_register(&bfd);
timer.cb = timer_cb;
timer.data = &bfd;
- bsc_schedule_timer(&timer, 5, 0);
+ osmo_timer_schedule(&timer, 5, 0);
printf("Trying to find ip.access BTS by broadcast UDP...\n");
while (1) {
- rc = bsc_select_main(0);
+ rc = osmo_select_main(0);
if (rc < 0)
exit(3);
}