~ubuntu-branches/ubuntu/raring/iproute/raring-proposed

« back to all changes in this revision

Viewing changes to ip/xfrm_monitor.c

  • Committer: Bazaar Package Importer
  • Author(s): Fabio M. Di Nitto
  • Date: 2006-11-14 15:18:53 UTC
  • mto: (3.1.1 etch) (1.1.7 upstream) (23.1.1 sid)
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: james.westby@ubuntu.com-20061114151853-4pojonfwjxhzx7z9
Tags: upstream-20061002
ImportĀ upstreamĀ versionĀ 20061002

Show diffs side-by-side

added added

removed removed

Lines of Context:
103
103
 
104
104
        if (oneline)
105
105
                fprintf(fp, "\n");
 
106
        fflush(fp);
106
107
 
107
108
        return 0;
108
109
}
115
116
        if (timestamp)
116
117
                print_timestamp(fp);
117
118
 
 
119
        if (n->nlmsg_type == XFRM_MSG_NEWSA ||
 
120
            n->nlmsg_type == XFRM_MSG_DELSA ||
 
121
            n->nlmsg_type == XFRM_MSG_UPDSA ||
 
122
            n->nlmsg_type == XFRM_MSG_EXPIRE) {
 
123
                xfrm_state_print(who, n, arg);
 
124
                return 0;
 
125
        }
 
126
        if (n->nlmsg_type == XFRM_MSG_NEWPOLICY ||
 
127
            n->nlmsg_type == XFRM_MSG_DELPOLICY ||
 
128
            n->nlmsg_type == XFRM_MSG_UPDPOLICY ||
 
129
            n->nlmsg_type == XFRM_MSG_POLEXPIRE) {
 
130
                xfrm_policy_print(who, n, arg);
 
131
                return 0;
 
132
        }
 
133
 
118
134
        if (n->nlmsg_type == XFRM_MSG_ACQUIRE) {
119
135
                xfrm_acquire_print(who, n, arg);
120
136
                return 0;
121
137
        }
122
 
        if (n->nlmsg_type == XFRM_MSG_EXPIRE) {
123
 
                xfrm_state_print(who, n, arg);
124
 
                return 0;
125
 
        }
126
 
        if (n->nlmsg_type == XFRM_MSG_POLEXPIRE) {
127
 
                xfrm_policy_print(who, n, arg);
128
 
                return 0;
129
 
        }
130
138
        if (n->nlmsg_type == XFRM_MSG_FLUSHSA) {
131
139
                /* XXX: Todo: show proto in xfrm_usersa_flush */
132
140
                fprintf(fp, "Flushed state\n");
138
146
        }
139
147
        if (n->nlmsg_type != NLMSG_ERROR && n->nlmsg_type != NLMSG_NOOP &&
140
148
            n->nlmsg_type != NLMSG_DONE) {
141
 
                fprintf(fp, "Unknown message: %08x %08x %08x\n",
 
149
                fprintf(fp, "Unknown message: %08d 0x%08x 0x%08x\n",
142
150
                        n->nlmsg_len, n->nlmsg_type, n->nlmsg_flags);
143
151
        }
144
152
        return 0;
145
153
}
146
154
 
 
155
extern struct rtnl_handle rth;
 
156
 
147
157
int do_xfrm_monitor(int argc, char **argv)
148
158
{
149
 
        struct rtnl_handle rth;
150
159
        char *file = NULL;
151
160
        unsigned groups = ~((unsigned)0); /* XXX */
152
161
        int lacquire=0;
153
162
        int lexpire=0;
 
163
        int lpolicy=0;
 
164
        int lsa=0;
 
165
 
 
166
        rtnl_close(&rth);
154
167
 
155
168
        while (argc > 0) {
156
169
                if (matches(*argv, "file") == 0) {
162
175
                } else if (matches(*argv, "expire") == 0) {
163
176
                        lexpire=1;
164
177
                        groups = 0;
 
178
                } else if (matches(*argv, "SA") == 0) {
 
179
                        lsa=1;
 
180
                        groups = 0;
 
181
                } else if (matches(*argv, "policy") == 0) {
 
182
                        lpolicy=1;
 
183
                        groups = 0;
165
184
                } else if (matches(*argv, "help") == 0) {
166
185
                        usage();
167
186
                } else {
175
194
                groups |= XFRMGRP_ACQUIRE;
176
195
        if (lexpire)
177
196
                groups |= XFRMGRP_EXPIRE;
 
197
        if (lsa)
 
198
                groups |= XFRMGRP_SA;
 
199
        if (lpolicy)
 
200
                groups |= XFRMGRP_POLICY;
178
201
 
179
202
        if (file) {
180
203
                FILE *fp;
188
211
 
189
212
        //ll_init_map(&rth);
190
213
 
 
214
        if (rtnl_open_byproto(&rth, groups, NETLINK_XFRM) < 0)
 
215
                exit(1);
 
216
 
191
217
        if (rtnl_listen(&rth, xfrm_accept_msg, (void*)stdout) < 0)
192
218
                exit(2);
193
219