#include "config.h"
#include "intl.h"
+#include "util.h"
#include "util-ank.h"
#include "net-support.h"
#include "version.h"
}
}
-static int parse_lla(char *str, unsigned char *addr)
+static int parse_lla(char *str, char *addr)
{
int len=0;
len = parse_hex(hexa, (unsigned char*)&m.addr.data);
if (len >= 0) {
- struct ma_info *ma = malloc(sizeof(m));
-
+ struct ma_info *ma = xmalloc(sizeof(m));
memcpy(ma, &m, sizeof(m));
ma->addr.bytelen = len;
ma->addr.bitlen = len<<3;
void read_igmp(struct ma_info **result_p)
{
- struct ma_info m;
+ struct ma_info m, *ma = NULL;
char buf[256];
FILE *fp = fopen(_PATH_PROCNET_IGMP, "r");
if (!fp)
return;
memset(&m, 0, sizeof(m));
- fgets(buf, sizeof(buf), fp);
+ if (fgets(buf, sizeof(buf), fp))
+ /* eat line */;
m.addr.family = AF_INET;
m.addr.bitlen = 32;
m.addr.bytelen = 4;
while (fgets(buf, sizeof(buf), fp)) {
- struct ma_info *ma = malloc(sizeof(m));
-
if (buf[0] != '\t') {
sscanf(buf, "%d%s", &m.index, m.name);
continue;
sscanf(buf, "%08x%d", (__u32*)&m.addr.data, &m.users);
- ma = malloc(sizeof(m));
+ ma = xmalloc(sizeof(m));
memcpy(ma, &m, sizeof(m));
maddr_ins(result_p, ma);
}
len = parse_hex(hexa, (unsigned char*)&m.addr.data);
if (len >= 0) {
- struct ma_info *ma = malloc(sizeof(m));
-
+ struct ma_info *ma = xmalloc(sizeof(m));
memcpy(ma, &m, sizeof(m));
ma->addr.bytelen = len;