diff options
Diffstat (limited to 'support/dktools/itaether.c')
-rw-r--r-- | support/dktools/itaether.c | 229 |
1 files changed, 229 insertions, 0 deletions
diff --git a/support/dktools/itaether.c b/support/dktools/itaether.c new file mode 100644 index 0000000000..3671cca3e2 --- /dev/null +++ b/support/dktools/itaether.c @@ -0,0 +1,229 @@ +/* + WARNING: This file was generated by dkct. + Changes you make here will be lost if dkct is run again! + You should modify the original source and run dkct on it. + Original source: itaether.ctr +*/ + +/* +Copyright (C) 2012-2017, Dirk Krause + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above opyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +* Neither the name of the author nor the names of contributors may be used + to endorse or promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/** @file itaether.c The itaether module. +*/ + + +#line 11 "itaether.ctr" + + +#include "dk3all.h" +#include "itadmin.h" + + + + + +#line 19 "itaether.ctr" + + + +/** Keywords used by the module. +*/ +static char const * const itadmin_ethers_c8_kw[] = { +/* 0 */ +"\n", + +/* 1 */ +"w", + +/* 2 */ +"ethers-by-ip", + +/* 3 */ +"ethers-by-mac", + +/* 4 */ +"ethers.ldif", + +/* 5 */ +"dn: cn=", + +/* 6 */ +",ou=ethers,", + +/* 7 */ +"objectClass: ieee802Device", + +/* 8 */ +"objectClass: device", + +/* 9 */ +"objectClass: top", + +/* 10 */ +"cn: ", + +/* 11 */ +"macAddress: ", + +NULL + + +#line 75 "itaether.ctr" +}; + + + + +int +itadmin_ethers_output(itadmin_job *job) +{ + itadmin_host *host; + FILE *f1; + FILE *f2; + int back = 0; + + +#line 88 "itaether.ctr" + f1 = dk3sf_c8_fopen_app( + itadmin_ethers_c8_kw[2], + itadmin_ethers_c8_kw[1], + job->app + ); + if(f1) { + f2 = dk3sf_c8_fopen_app( + itadmin_ethers_c8_kw[3], + itadmin_ethers_c8_kw[1], + job->app + ); + if(f2) { + back = 1; + dk3sto_it_reset(job->i_hoi); + while(NULL != (host = (itadmin_host *)dk3sto_it_next(job->i_hoi))) { + if((host->ipv4) && (host->sn) && (host->maca)) { + itadmin_tool_write_ip(f1, host->ipv4); + fputc('\t', f1); + fputs(host->maca, f1); + fputc('\n', f1); + fputs(host->maca, f2); + fputc('\t', f2); + itadmin_tool_write_ip(f2, host->ipv4); + fputc('\n', f2); + } + } +#if DK3_CHAR_SIZE == 1 + if(!dk3sf_fclose_fn_app(f2, itadmin_ethers_c8_kw[3], job->app)) { + back = 0; + } +#else + if(!dk3sf_fclose_fn_app(f2, NULL, job->app)) { + back = 0; + } +#endif + } else { + } +#if DK3_CHAR_SIZE == 1 + if(!dk3sf_fclose_fn_app(f1, itadmin_ethers_c8_kw[2], job->app)) { + back = 0; + } +#else + if(!dk3sf_fclose_fn_app(f1, NULL, job->app)) { + back = 0; + } +#endif + } else { + } + + +#line 137 "itaether.ctr" + return back; +} + + + +int +itadmin_ethers_ldif_output(itadmin_job *job) +{ + char bu[ITADMIN_CONFIG_LINE_SIZE]; + itadmin_host *host; + FILE *fipo; + int ie; + int back = 0; + + +#line 151 "itaether.ctr" + ie = dk3app_get_encoding(job->app); + if(dk3str_to_c8u_app(bu,sizeof(bu),job->ldapb,ie,job->app)) { + fipo = dk3sf_c8_fopen_app( + itadmin_ethers_c8_kw[4], + itadmin_ethers_c8_kw[1], + job->app + ); + if(fipo) { + back = 1; + dk3sto_it_reset(job->i_hoi); + while(NULL != (host = (itadmin_host *)dk3sto_it_next(job->i_hoi))) { + if((host->ipv4) && (host->sn) && (host->maca)) { + fputs(itadmin_ethers_c8_kw[5], fipo); + itadmin_tool_write_ip(fipo, host->ipv4); + fputs(itadmin_ethers_c8_kw[6], fipo); + fputs(bu, fipo); + fputc('\n', fipo); + fputs(itadmin_ethers_c8_kw[7], fipo); + fputc('\n', fipo); + fputs(itadmin_ethers_c8_kw[8], fipo); + fputc('\n', fipo); + fputs(itadmin_ethers_c8_kw[9], fipo); + fputc('\n', fipo); + fputs(itadmin_ethers_c8_kw[10], fipo); + itadmin_tool_write_ip(fipo, host->ipv4); + fputc('\n', fipo); + fputs(itadmin_ethers_c8_kw[11], fipo); + fputs(host->maca, fipo); + fputc('\n', fipo); fputc('\n', fipo); + } + } +#if DK3_CHAR_SIZE == 1 + if(!dk3sf_fclose_fn_app(fipo, itadmin_ethers_c8_kw[4], job->app)) { + back = 0; + } +#else + if(!dk3sf_fclose_fn_app(fipo, NULL, job->app)) { + back = 0; + } +#endif + } else { + } + } else { + } + + +#line 196 "itaether.ctr" + return back; +} + + |