File: func_str.h

package info (click to toggle)
arpalert 2.0.3-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,332 kB
  • ctags: 415
  • sloc: ansic: 4,185; sh: 447; makefile: 153; perl: 28
file content (40 lines) | stat: -rw-r--r-- 998 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * Copyright (c) 2005-2010 Thierry FOURNIER
 * $Id: func_str.h 365 2006-10-25 14:36:18Z  $
 *
 */

#ifndef __FUNC_STR_H__
#define __FUNC_STR_H__

#include <net/if.h>
#include <netinet/if_ether.h>
#include <netinet/in.h>
#ifdef __FreeBSD__
#   define ETHER_ADDR_OCTET octet
#else
#   define ETHER_ADDR_OCTET ether_addr_octet
#endif

// translate binary data mac to string data mac
// void data_tomac(struct ether_addr, char *);
#define MAC_TO_STR(a, b) \
	sprintf((b), "%02x:%02x:%02x:%02x:%02x:%02x", \
	        (a).ETHER_ADDR_OCTET[0], \
	        (a).ETHER_ADDR_OCTET[1], \
	        (a).ETHER_ADDR_OCTET[2], \
	        (a).ETHER_ADDR_OCTET[3], \
	        (a).ETHER_ADDR_OCTET[4], \
	        (a).ETHER_ADDR_OCTET[5])

// convert hex string to int
//   @param: hexa string terminated by \0
//   @return: hexa int conv
//            -1: error
int strhex_to_int(char *hex);

// translate string data mac to binary data mac
// return -1 if error
int str_to_mac(char *, struct ether_addr *);

#endif