11/*
2- * Copyright (c) 2008, 2009, 2010 Nicira Networks.
2+ * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
2929#include "netdev.h"
3030#include "openflow/openflow.h"
3131#include "packets.h"
32- #include "status.h"
3332#include "stream-ssl.h"
3433#include "vlog.h"
3534
@@ -42,63 +41,16 @@ struct discovery {
4241 regex_t * regex ;
4342 struct dhclient * dhcp ;
4443 int n_changes ;
45- struct status_category * ss_cat ;
4644};
4745
4846static void modify_dhcp_request (struct dhcp_msg * , void * aux );
4947static bool validate_dhcp_offer (const struct dhcp_msg * , void * aux );
5048
5149static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT (60 , 60 );
5250
53- static void
54- discovery_status_cb (struct status_reply * sr , void * d_ )
55- {
56- struct discovery * d = d_ ;
57-
58- status_reply_put (sr , "accept-remote=%s" , d -> re );
59- status_reply_put (sr , "n-changes=%d" , d -> n_changes );
60- if (d -> dhcp ) {
61- status_reply_put (sr , "state=%s" , dhclient_get_state (d -> dhcp ));
62- status_reply_put (sr , "state-elapsed=%u" ,
63- dhclient_get_state_elapsed (d -> dhcp ));
64- if (dhclient_is_bound (d -> dhcp )) {
65- uint32_t ip = dhclient_get_ip (d -> dhcp );
66- uint32_t netmask = dhclient_get_netmask (d -> dhcp );
67- uint32_t router = dhclient_get_router (d -> dhcp );
68-
69- const struct dhcp_msg * cfg = dhclient_get_config (d -> dhcp );
70- uint32_t dns_server ;
71- char * domain_name ;
72- int i ;
73-
74- status_reply_put (sr , "ip=" IP_FMT , IP_ARGS (& ip ));
75- status_reply_put (sr , "netmask=" IP_FMT , IP_ARGS (& netmask ));
76- if (router ) {
77- status_reply_put (sr , "router=" IP_FMT , IP_ARGS (& router ));
78- }
79-
80- for (i = 0 ; dhcp_msg_get_ip (cfg , DHCP_CODE_DNS_SERVER , i ,
81- & dns_server );
82- i ++ ) {
83- status_reply_put (sr , "dns%d=" IP_FMT , i , IP_ARGS (& dns_server ));
84- }
85-
86- domain_name = dhcp_msg_get_string (cfg , DHCP_CODE_DOMAIN_NAME );
87- if (domain_name ) {
88- status_reply_put (sr , "domain=%s" , domain_name );
89- free (domain_name );
90- }
91-
92- status_reply_put (sr , "lease-remaining=%u" ,
93- dhclient_get_lease_remaining (d -> dhcp ));
94- }
95- }
96- }
97-
9851int
9952discovery_create (const char * re , bool update_resolv_conf ,
100- struct dpif * dpif , struct switch_status * ss ,
101- struct discovery * * discoveryp )
53+ struct dpif * dpif , struct discovery * * discoveryp )
10254{
10355 struct discovery * d ;
10456 char local_name [IF_NAMESIZE ];
@@ -133,9 +85,6 @@ discovery_create(const char *re, bool update_resolv_conf,
13385 dhclient_set_max_timeout (d -> dhcp , 3 );
13486 dhclient_init (d -> dhcp , 0 );
13587
136- d -> ss_cat = switch_status_register (ss , "discovery" ,
137- discovery_status_cb , d );
138-
13988 * discoveryp = d ;
14089 return 0 ;
14190
@@ -157,7 +106,6 @@ discovery_destroy(struct discovery *d)
157106 regfree (d -> regex );
158107 free (d -> regex );
159108 dhclient_destroy (d -> dhcp );
160- switch_status_unregister (d -> ss_cat );
161109 free (d -> dpif_name );
162110 free (d );
163111 }
0 commit comments