root/src/router/openlldp/src/lldp_neighbor.c

Revision 8348, 1.8 kB (checked in by BrainSlayer, 2 years ago)

no debug crap

Line 
1 /*******************************************************************
2  *
3  * OpenLLDP Neighbor
4  *
5  * Licensed under a dual GPL/Proprietary license. 
6  * See LICENSE file for more info.
7  *
8  * File: lldp_neighbor.c
9  *
10  * Authors: Jason Peterson (condurre@users.sourceforge.net)
11  *
12  *******************************************************************/
13
14 #include <stdint.h>
15 #include <sys/types.h>
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <errno.h>
19
20 #include <sys/utsname.h>
21 #include <unistd.h>
22
23 #include <string.h>
24
25 #include "lldp_debug.h"
26 #include "lldp_neighbor.h"
27
28 int get_sys_desc() {
29  
30   int retval;
31   struct utsname sysinfo;
32
33   bzero(&lldp_systemdesc[0], 512);
34  
35   retval = uname(&sysinfo);
36
37   if (retval < 0) {
38    
39     debug_printf(DEBUG_NORMAL, "Call to uname failed!\n");
40     exit(0);   
41    
42   }
43
44   debug_printf(DEBUG_NORMAL, "sysinfo.machine: %s\n", sysinfo.machine); 
45   debug_printf(DEBUG_NORMAL, "sysinfo.sysname: %s\n", sysinfo.sysname);
46   debug_printf(DEBUG_NORMAL, "sysinfo.release: %s\n", sysinfo.release);
47
48   strcpy(lldp_systemdesc, sysinfo.machine);
49   strcat(lldp_systemdesc, "/");
50   strcat(lldp_systemdesc, "DD-WRT Linux"); 
51   strcat(lldp_systemdesc, " ");
52   strcat(lldp_systemdesc, sysinfo.release);
53
54   debug_printf(DEBUG_NORMAL, "lldp_systemdesc: %s\n", lldp_systemdesc);
55
56   return(0);
57  
58 }
59
60 int get_sys_fqdn() {
61
62 int retval;
63
64 bzero(&lldp_systemname[0], 512);
65
66 retval = gethostname(lldp_systemname, 255);
67
68 if (retval < 0)
69         {
70         debug_printf(DEBUG_NORMAL, "gethostname() failed! retval = %d.\n", retval);
71         }
72
73 strcat(lldp_systemname, ".");
74
75 retval = getdomainname(&lldp_systemname[strlen(lldp_systemname)], 255 - strlen(lldp_systemname));
76
77 if (retval < 0)
78         {
79         debug_printf(DEBUG_NORMAL, "getdomainname() failed! retval = %d.\n", retval);
80         }
81
82 debug_printf(DEBUG_NORMAL, "lldp_systemname: %s\n", lldp_systemname);
83
84 return(0);
85
86 }
Note: See TracBrowser for help on using the browser.