summaryrefslogtreecommitdiffstats
path: root/avahi-core/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2005-11-16 01:15:46 +0000
committerLennart Poettering <lennart@poettering.net>2005-11-16 01:15:46 +0000
commita3d45b39608418e261f34b3b3286b80e4878d25c (patch)
tree0743b13f2386f4e108dc8e6d17fc0d3cf18e4791 /avahi-core/util.c
parent6ed9be1191edab688976f5ea7ddf1e382ef6f1d1 (diff)
* when calculating a random jitter time for time events, use the same jitter in
every 10s timespans. This should increase the probability that multiple responses can be merged into a single packet, and thus decreases network traffic. * add _workstation._tcp services in RUNNING state, not earlier * an important bugfix which fixes the entry group state automatons * remove obsolete debug messages * minor other cleanups git-svn-id: file:///home/lennart/svn/public/avahi/trunk@980 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-core/util.c')
-rw-r--r--avahi-core/util.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/avahi-core/util.c b/avahi-core/util.c
index a5e9f52..b1925f0 100644
--- a/avahi-core/util.c
+++ b/avahi-core/util.c
@@ -66,29 +66,38 @@ void avahi_hexdump(const void* p, size_t size) {
}
}
-
-char *avahi_format_mac_address(const uint8_t* mac, size_t size) {
- char *r, *t;
+char *avahi_format_mac_address(char *r, size_t l, const uint8_t* mac, size_t size) {
+ char *t = r;
unsigned i;
static const char hex[] = "0123456789abcdef";
- if (!(t = r = avahi_new(char, size > 0 ? size*3 : 1)))
- return NULL;
-
+ assert(r);
+ assert(l > 0);
+ assert(mac);
+
if (size <= 0) {
*r = 0;
return r;
}
for (i = 0; i < size; i++) {
+ if (l < 3)
+ break;
+
*(t++) = hex[*mac >> 4];
*(t++) = hex[*mac & 0xF];
*(t++) = ':';
+ l -= 3;
+
mac++;
}
- *(--t) = 0;
+ if (t > r)
+ *(t-1) = 0;
+ else
+ *r = 0;
+
return r;
}