2
* Copyright (C) 1998-2000 Luca Deri <deri@ntop.org>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
void usage(char *progName) {
24
printf("Usage: %s <MAC ADDRESS [17 chars]> "
25
"<symbolic name> <ntop.db file>\n", progName);
26
printf("Example: %s 08:00:09:B4:AA:81 \"Luca's Macintosh\" "
27
"/usr/people/luca/ntop/ntop.db\n", progName);
31
int main(int argc, char *argv[])
34
datum key_data, data_data;
40
if((strlen(argv[1]) != 17)
41
|| (argv[1][2] != ':')
42
|| (argv[1][5] != ':')
43
|| (argv[1][8] != ':')
44
|| (argv[1][11] != ':')
45
|| (argv[1][14] != ':')) {
46
printf("Wrong MAC Address format. Example: 08:00:09:B4:AA:81\n");
50
gdbm_file = gdbm_open (argv[3], 0, GDBM_WRCREAT, 00664, NULL);
52
if(gdbm_file == NULL) {
53
printf("Database open failed: %s\n", gdbm_strerror(gdbm_errno));
57
key_data.dptr = argv[1];
58
key_data.dsize = strlen(key_data.dptr)+1;
59
data_data.dptr = argv[2];
60
data_data.dsize = strlen(data_data.dptr)+1;
62
if(gdbm_store(gdbm_file, key_data, data_data, GDBM_REPLACE) != 0)
63
printf("Error while adding data: %s\n", gdbm_strerror(gdbm_errno));
65
gdbm_close(gdbm_file);