6 #ifndef __IPNETWORK_FUNCTIONS_H__
7 #define __IPNETWORK_FUNCTIONS_H__
13 #include "IpNetworkInfo.H"
26 if (error_msg !=
"") {
27 printf(
"error: %s\n", error_msg.c_str());
30 printf(
"ipnetwork command syntax help:\n");
33 if (specific ==
"" || specific ==
"check") {
34 printf(
" check <<v4|v6>=<startAddr>-<endAddr>> "
35 "[<v4|v6>=<startAddr>-<endAddr> ...]\n");
39 if (specific ==
"" || specific ==
"create") {
40 printf(
" create <v4|v6>=<startAddr>-<endAddr> <-o organization> "
42 " [-reserve reserveType [-comment reserveComment]]\n"
43 " [-a asn] [-contact type=value ...] \n"
45 "<v4|v6>=<startAddr>-<endAddr>,hostname[,hostname ...] ...]\n"
46 " [-ds <v4|v6>=<startAddr>-<endAddr> "
47 "<keyTag> <alg> <digestType> <digest>] ");
51 if (specific ==
"" || specific ==
"delete") {
52 printf(
" delete <-roid repository-id>\n");
56 if (specific ==
"" || specific ==
"info") {
57 printf(
" info <<v4|v6>=<startAddr>-<endAddr>> [-roid repository-id]\n");
61 if (specific ==
"" || specific ==
"renew") {
62 printf(
" renew <-roid repository-id> <-expdate expDate> "
63 "[-period time:unit]\n");
67 if (specific ==
"" || specific ==
"transfer") {
68 printf(
" transfer <-op [query|request]> <-roid repository-id>\n");
72 if (specific ==
"" || specific ==
"update") {
73 printf(
" update <roid> [-add-contact type=value ...]\n"
74 " [-rem-contact type=value ...] [-o organization] "
75 "[-t allocationType] [-a asn] \n"
76 " [-creation-date yyyy-mm-ddThh:mm:ss.0Z]\n"
78 "<v4|v6>=<startAddr>-<endAddr>,hostname[,hostname ...] ...]\n"
79 " [-add-ds <v4|v6>=<startAddr>-<endAddr> "
80 "<keyTag> <alg> <digestType> <digest>] \n"
82 "<v4|v6>=<startAddr>-<endAddr>,hostname[,hostname ...] ...]\n"
83 " [-rem-ds <v4|v6>=<startAddr>-<endAddr> "
84 "<keyTag> <alg> <digestType> <digest>] \n"
85 " [-aggregate <roid>[,hostname,hostname ...]]\n");
89 if (error_msg !=
"") {
103 string cmd_name =
"check";
108 while (!args.empty()) {
109 if (args[0].substr(0, 1) ==
"v") {
117 args.erase(args.begin());
133 printf(
"ranges to be checked:\n");
135 for (
unsigned int i = 0; i < ipRanges.size(); i++) {
136 printf(
" (%s) from [%s] to [%s]\n",
137 ipRanges[i].get_version().c_str(),
138 ipRanges[i].get_ipBegin().c_str(),
139 ipRanges[i].get_ipEnd().c_str());
157 string cmd_name =
"create";
163 bool hasIpRange =
false;
164 bool hasOrganization =
false;
166 while (!args.empty()) {
167 if (args[0].substr(0, 1) ==
"v") {
183 args.erase(args.begin());
186 }
else if (args[0] ==
"-o") {
188 if (hasOrganization) {
193 hasOrganization =
true;
196 args.erase(args.begin());
203 args.erase(args.begin());
205 }
else if (args[0] ==
"-t") {
207 args.erase(args.begin());
214 args.erase(args.begin());
216 }
else if (args[0] ==
"-reserve") {
217 args.erase(args.begin());
224 args.erase(args.begin());
226 }
else if (args[0] ==
"-comment") {
227 args.erase(args.begin());
233 string comment = args[0];
234 args.erase(args.begin());
242 }
else if (args[0] ==
"-a") {
244 args.erase(args.begin());
250 if (atoi(args[0].c_str()) <= 0) {
255 cmd->
set_asn(atoi(args[0].c_str()));
256 args.erase(args.begin());
258 }
else if (args[0] ==
"-contact") {
260 args.erase(args.begin());
274 args.erase(args.begin());
276 }
else if (args[0] ==
"-rev-ns") {
278 args.erase(args.begin());
293 string tmp1 = nameservers;
297 revDns.nameservers.push_back(tmp1);
307 args.erase(args.begin());
309 }
else if (args[0] ==
"-ds") {
331 if (!hasOrganization) {
337 printf(
"range to be created:\n");
338 printf(
" (%s) from [%s] to [%s]\n",
339 ipRange.get_version().c_str(),
340 ipRange.get_ipBegin().c_str(),
341 ipRange.get_ipEnd().c_str());
346 printf(
"asn: [%d]\n", cmd->
get_asn());
349 map< string, string, less<string> > contacts = cmd->
get_contacts();
350 map< string, string, less<string> >::const_iterator cit;
352 for (cit = contacts.begin(); cit != contacts.end(); cit++) {
353 printf(
"contact %s: %s\n", (*cit).first.c_str(), (*cit).second.c_str());
356 printf(
"reverse nameservers:\n");
359 for (
unsigned int i = 0; i < revNs.size(); i++) {
360 printf(
" range (%s) from [%s] to [%s]:\n",
361 revNs[i].ipRange.get_version().c_str(),
362 revNs[i].ipRange.get_ipBegin().c_str(),
363 revNs[i].ipRange.get_ipEnd().c_str());
365 for (
unsigned int j = 0; j < revNs[i].nameservers.size(); j++) {
366 printf(
" nameserver: [%s]\n", revNs[i].nameservers[j].c_str());
385 string cmd_name =
"delete";
391 bool hasRoid =
false;
393 while (!args.empty()) {
394 if (args[0] ==
"-roid") {
404 args.erase(args.begin());
411 args.erase(args.begin());
424 printf(
"roid: [%s]\n", cmd->
get_roid().c_str());
441 string cmd_name =
"info";
447 bool hasIpRange =
false;
449 while (!args.empty()) {
450 if (args[0].substr(0, 1) ==
"v") {
466 args.erase(args.begin());
469 }
else if (args[0] ==
"-roid") {
471 args.erase(args.begin());
478 args.erase(args.begin());
493 printf(
"range to get info:\n");
494 printf(
" (%s) from [%s] to [%s]\n",
495 ipRange.get_version().c_str(),
496 ipRange.get_ipBegin().c_str(),
497 ipRange.get_ipEnd().c_str());
500 printf(
"roid: [%s]\n", cmd->
get_roid().c_str());
518 string cmd_name =
"renew";
524 bool hasRoid =
false;
525 bool hasExpDate =
false;
527 while (!args.empty()) {
528 if (args[0] ==
"-roid") {
538 args.erase(args.begin());
545 args.erase(args.begin());
547 }
else if (args[0] ==
"-expdate") {
557 args.erase(args.begin());
564 args.erase(args.begin());
566 }
else if (args[0] ==
"-period") {
568 args.erase(args.begin());
582 args.erase(args.begin());
600 printf(
"roid : [%s]\n", cmd->
get_roid().c_str());
601 printf(
"expDate: [%s]\n", cmd->
get_expDate().c_str());
604 printf(
"period : [%d %s]\n", cmd->
get_period().time,
623 string cmd_name =
"transfer";
629 bool hasRoid =
false;
632 while (!args.empty()) {
633 if (args[0] ==
"-roid") {
643 args.erase(args.begin());
650 args.erase(args.begin());
652 }
else if (args[0] ==
"-op") {
662 args.erase(args.begin());
668 if (args[0] !=
"query" && args[0] !=
"request") {
674 args.erase(args.begin());
691 printf(
"roid: [%s]\n", cmd->
get_roid().c_str());
709 string cmd_name =
"update";
719 args.erase(args.begin());
721 bool hasOrganization =
false;
722 bool hasAllocType =
false;
723 bool hasContactsAdd =
false;
724 bool hasContactsRem =
false;
725 bool hasReverseDnsAdd =
false;
726 bool hasReverseDnsRem =
false;
727 bool hasReverseDsAdd =
false;
728 bool hasReverseDsRem =
false;
729 bool hasAggregate =
false;
730 bool hasCreationDate =
false;
732 while (!args.empty()) {
733 if (args[0] ==
"-add-contact") {
735 hasContactsAdd =
true;
736 args.erase(args.begin());
750 args.erase(args.begin());
752 }
else if (args[0] ==
"-rem-contact") {
754 hasContactsRem =
true;
755 args.erase(args.begin());
769 args.erase(args.begin());
771 }
else if (args[0] ==
"-o") {
773 if (hasOrganization) {
778 hasOrganization =
true;
781 args.erase(args.begin());
788 args.erase(args.begin());
790 }
else if (args[0] ==
"-t") {
800 args.erase(args.begin());
807 args.erase(args.begin());
809 }
else if (args[0] ==
"-a") {
811 args.erase(args.begin());
817 unsigned int asn = strtoul(args[0].c_str(), NULL, 10);
819 args.erase(args.begin());
821 }
else if (args[0] ==
"-add-rev-ns") {
823 hasReverseDnsAdd =
true;
824 args.erase(args.begin());
839 string tmp1 = nameservers;
843 revDns.nameservers.push_back(tmp1);
853 args.erase(args.begin());
855 }
else if (args[0] ==
"-rem-rev-ns") {
856 hasReverseDnsRem =
true;
858 args.erase(args.begin());
873 string tmp1 = nameservers;
877 revDns.nameservers.push_back(tmp1);
887 args.erase(args.begin());
889 }
else if (args[0] ==
"-add-ds") {
899 hasReverseDsAdd =
true;
901 }
else if (args[0] ==
"-rem-ds") {
911 hasReverseDsRem =
true;
913 }
else if (args[0] ==
"-aggregate") {
914 args.erase(args.begin());
920 string aggregateRoid;
921 string aggregateHostnames;
928 cmd->setAggregateRoid(aggregateRoid);
931 if (aggregateHostnames !=
"") {
932 string tmp1 = aggregateHostnames;
936 cmd->insertAggregateHostname(tmp1);
946 args.erase(args.begin());
948 }
else if (args[0] ==
"-creation-date") {
950 if (hasCreationDate) {
955 hasCreationDate =
true;
958 args.erase(args.begin());
964 cmd->setCreationDate(args[0]);
965 args.erase(args.begin());
973 if (!hasOrganization && !hasContactsAdd && !hasContactsRem &&
974 !hasAllocType && !hasReverseDnsAdd && !hasReverseDnsRem &&
975 hasReverseDsAdd ==
false && hasReverseDsRem ==
false &&
976 hasAggregate ==
false && !hasCreationDate &&
982 printf(
"IP Network to be updated: [%s]\n", cmd->
get_roid().c_str());
984 printf(
"allocation type: [%s]\n", cmd->
get_allocType().c_str());
986 map< string, string, less<string> >::const_iterator cit;
987 map< string, string, less<string> > contacts;
991 for (cit = contacts.begin(); cit != contacts.end(); cit++) {
992 printf(
"contact to add %s: %s\n",
993 (*cit).first.c_str(), (*cit).second.c_str());
998 for (cit = contacts.begin(); cit != contacts.end(); cit++) {
999 printf(
"contact to remove %s: %s\n",
1000 (*cit).first.c_str(), (*cit).second.c_str());
1003 vector<ReverseDns> reverseDns;
1007 for (
unsigned int i = 0; i < reverseDns.size(); i++) {
1008 IpRange ipRange = reverseDns[i].ipRange;
1009 printf(
"reverse DNS to add: [%s] from [%s] to [%s]\n",
1010 ipRange.get_version().c_str(),
1011 ipRange.get_ipBegin().c_str(),
1012 ipRange.get_ipEnd().c_str());
1013 vector<string> nameservers = reverseDns[i].nameservers;
1015 for (
unsigned int j = 0; j < nameservers.size(); j++) {
1016 printf(
" nameserver [%s]\n", nameservers[j].c_str());
1022 for (
unsigned int i = 0; i < reverseDns.size(); i++) {
1023 IpRange ipRange = reverseDns[i].ipRange;
1024 printf(
"reverse DNS to remove: [%s] from [%s] to [%s]\n",
1025 ipRange.get_version().c_str(),
1026 ipRange.get_ipBegin().c_str(),
1027 ipRange.get_ipEnd().c_str());
1028 vector<string> nameservers = reverseDns[i].nameservers;
1030 for (
unsigned int j = 0; j < nameservers.size(); j++) {
1031 printf(
" nameserver [%s]\n", nameservers[j].c_str());
1051 if (!args.empty() && !(args[0] ==
"help")) {
1052 if (args[0] ==
"check") {
1053 args.erase(args.begin());
1056 }
else if (args[0] ==
"create") {
1057 args.erase(args.begin());
1060 }
else if (args[0] ==
"delete") {
1061 args.erase(args.begin());
1064 }
else if (args[0] ==
"info") {
1065 args.erase(args.begin());
1068 }
else if (args[0] ==
"renew") {
1069 args.erase(args.begin());
1072 }
else if (args[0] ==
"transfer") {
1073 args.erase(args.begin());
1076 }
else if (args[0] ==
"update") {
1077 args.erase(args.begin());
1088 #endif //__IPNETWORK_FUNCTIONS_H__
string get_operation() const
Returns operation.
Definition: IpNetworkTransferCmd.H:45
EPP IpNetworkUpdate Class.
map< string, string, less< string > > get_contacts_rem() const
Returns map of other contacts to be removed.
Definition: IpNetworkUpdateCmd.H:224
void set_period(const int time, const string &unit)
Sets period.
Definition: IpNetworkRenewCmd.H:74
void set_asn(const unsigned int &asn)
Sets asn.
Definition: IpNetworkUpdateCmd.H:95
string get_roid() const
Returns repository object ID.
Definition: IpNetworkTransferCmd.H:63
string get_roid() const
Returns repository object ID.
Definition: IpNetworkDeleteCmd.H:41
EPP IpNetworkRenewCmd Class.
Definition: IpNetworkRenewCmd.H:22
int cmd_ipnetwork_transfer(vector< string > &args)
ipnetwork transfer command function
Definition: IpNetworkFunctions.H:621
void set_organization(const string &organization)
Sets organization.
Definition: IpNetworkCreateCmd.H:61
EPP IpNetworkTransfer Class.
IpNetworkInfoCmd * get_command()
Returns raw pointer to the command.
Definition: IpNetworkInfo.H:48
int get_asn() const
Returns asn.
Definition: IpNetworkCreateCmd.H:88
EPP IpNetworkCheckCmd Class.
Definition: IpNetworkCheckCmd.H:21
EPP IpNetworkInfo Class.
Definition: IpNetworkInfoCmd.H:11
static int split(string input, string &first, string &second, string splitter, bool relaxed=false)
Definition: SheppStrUtil.H:120
RegistrationPeriod get_period() const
Returns period.
Definition: IpNetworkRenewCmd.H:84
void add_dsInfo(const ReverseDSInfo &ds_info)
Adds DS information.
Definition: IpNetworkCreateCmd.H:188
void insert_dsInfo_rem(const ReverseDSInfo &ds_info)
Inserts a reverse DS to be removed.
Definition: IpNetworkUpdateCmd.H:177
int cmd_ipnetwork_update(vector< string > &args)
ipnetwork update command function
Definition: IpNetworkFunctions.H:707
string get_organization() const
Returns organization associated with the ip range.
Definition: IpNetworkCreateCmd.H:70
IpNetworkDeleteCmd * get_command()
Returns raw pointer to the command.
Definition: IpNetworkDelete.H:54
void set_ipRange(const IpRange &ipRange)
Sets ip range.
Definition: IpNetworkInfoCmd.H:26
string get_allocType() const
Returns allocation type.
Definition: IpNetworkUpdateCmd.H:86
void set_operation(const string &op)
Sets operation.
Definition: IpNetworkTransferCmd.H:36
IpNetworkCreateCmd * get_command()
Returns raw pointer to the command.
Definition: IpNetworkCreate.H:54
EPP IpNetworkRenew Class.
IpNetworkCheckCmd * get_command()
Returns raw pointer to the command.
Definition: IpNetworkCheck.H:54
void set_expDate(const string &expDate)
Sets expiration date.
Definition: IpNetworkRenewCmd.H:55
void insert_contact_add(const string &type, const string &identification)
Inserts a contact to be added.
Definition: IpNetworkUpdateCmd.H:196
EPP IpNetworkCheck Class.
Definition: IpNetworkCheck.H:21
void insert_reverseDns(const ReverseDns &reverseDns)
Sets reverse dns.
Definition: IpNetworkCreateCmd.H:170
EPP IpNetworkDelete Class.
Definition: IpNetworkDelete.H:21
Describes IpRange structure.
Definition: CommonData.H:192
EPP IpNetworkDelete Class.
void set_organization(const string &organization)
Sets organization.
Definition: IpNetworkUpdateCmd.H:59
void set_roid(const string &roid)
Sets repository object ID.
Definition: IpNetworkTransferCmd.H:54
void set_allocType(const string &allocType)
Sets allocation type.
Definition: IpNetworkUpdateCmd.H:77
EPP IpNetworkDelete Class.
Definition: IpNetworkDeleteCmd.H:17
void set_roid(const string &roid)
Sets repository object ID.
Definition: IpNetworkInfoCmd.H:44
EPP IpNetworkRenew Class.
Definition: IpNetworkRenew.H:21
void set_reserveType(const string &reserveType)
Sets reservation type.
Definition: IpNetworkCreateCmd.H:133
void insert_ipRange(const IpRange &ipRange)
Add an ip range.
Definition: IpNetworkCheckCmd.H:36
IpRange get_ipRange() const
Returns ip range.
Definition: IpNetworkCreateCmd.H:52
static int parse_iprange(const string &input, IpRange &ipRange)
reads an IpRange object from args
Definition: SheppObjSet.H:26
vector< ReverseDns > get_reverseDns_rem() const
Returns all the reverse DNS to be removed.
Definition: IpNetworkUpdateCmd.H:150
int cmd_ipnetwork_create(vector< string > &args)
ipnetwork create command function
Definition: IpNetworkFunctions.H:155
map< string, string, less< string > > get_contacts_add() const
Returns map of other contacts to be added.
Definition: IpNetworkUpdateCmd.H:205
EPP IpNetworkUpdateCmd Class.
Definition: IpNetworkUpdateCmd.H:26
void set_reserveComment(const string &reserveComment)
Sets reservation comments.
Definition: IpNetworkCreateCmd.H:115
int process_action(Action &act)
Send and EPP Action.
Definition: SheppCommandFunctions.H:871
IpNetworkTransferCmd * get_command()
Returns raw pointer to the command.
Definition: IpNetworkTransfer.H:54
EPP IpNetworkCreate Class.
string get_expDate() const
Returns expiration date.
Definition: IpNetworkRenewCmd.H:64
void set_roid(const string &roid)
Sets repository object ID.
Definition: IpNetworkUpdateCmd.H:41
EPP IpNetworkCheck Class.
vector< ReverseDns > get_reverseDns_add() const
Returns all the reverse DNS to be added.
Definition: IpNetworkUpdateCmd.H:132
map< string, string, less< string > > get_contacts() const
Returns map of other contacts.
Definition: IpNetworkCreateCmd.H:161
void set_ipRange(const IpRange &ipRange)
Sets ip range.
Definition: IpNetworkCreateCmd.H:43
vector< IpRange > get_ipRanges() const
Returns list of ip range.
Definition: IpNetworkCheckCmd.H:45
void set_roid(const string &roid)
Sets repository object ID.
Definition: IpNetworkDeleteCmd.H:32
int cmd_ipnetwork_renew(vector< string > &args)
ipnetwork renew command function
Definition: IpNetworkFunctions.H:516
void set_allocType(const string &allocType)
Sets allocation type.
Definition: IpNetworkCreateCmd.H:97
void set_roid(const string &roid)
Sets repository object ID.
Definition: IpNetworkRenewCmd.H:37
EPP IpNetworkCreateCmd Class.
Definition: IpNetworkCreateCmd.H:28
int cmd_ipnetwork(vector< string > &args)
main ipnetwork command
Definition: IpNetworkFunctions.H:1048
EPP IpNetworkTransfer Class.
Definition: IpNetworkTransfer.H:21
EPP IpNetworkTransferCmd Class.
Definition: IpNetworkTransferCmd.H:21
EPP IpNetworkInfo Class.
Definition: IpNetworkInfo.H:15
int cmd_ipnetwork_delete(vector< string > &args)
ipnetwork check delete function
Definition: IpNetworkFunctions.H:383
void insert_dsInfo_add(const ReverseDSInfo &ds_info)
Inserts a reverse DS to be added.
Definition: IpNetworkUpdateCmd.H:159
vector< ReverseDns > get_reversesDns() const
Returns reverses dns.
Definition: IpNetworkCreateCmd.H:179
EPP command-line shell client command functions include file.
string get_roid() const
Returns repository object ID.
Definition: IpNetworkRenewCmd.H:46
void insert_reverseDNS_add(const ReverseDns &reverseDns)
Inserts a reverse DNS to be added.
Definition: IpNetworkUpdateCmd.H:123
static int quote_gathering(vector< string > &words, string &gather)
Gathers command-line arguments bounded by quotes in a string.
Definition: SheppStrUtil.H:152
string get_allocType() const
Returns allocation type.
Definition: IpNetworkCreateCmd.H:106
string get_roid() const
Returns repository object ID.
Definition: IpNetworkUpdateCmd.H:50
IpNetworkRenewCmd * get_command()
Returns raw pointer to the command.
Definition: IpNetworkRenew.H:54
int cmd_ipnetwork_help(string error_msg, string specific="")
print ipnetwork command usage info
Definition: IpNetworkFunctions.H:24
int cmd_ipnetwork_check(vector< string > &args)
ipnetwork check command function
Definition: IpNetworkFunctions.H:101
bool asn_changed() const
Returns asn_changed.
Definition: IpNetworkUpdateCmd.H:114
string get_roid() const
Returns repository object ID.
Definition: IpNetworkInfoCmd.H:53
IpRange get_ipRange() const
Returns ip range.
Definition: IpNetworkInfoCmd.H:35
void insert_contact_rem(const string &type, const string &identification)
Inserts a contact to be removed.
Definition: IpNetworkUpdateCmd.H:215
void insert_reverseDNS_rem(const ReverseDns &reverseDns)
Inserts a reverse DNS to be removed.
Definition: IpNetworkUpdateCmd.H:141
EPP IpNetworkUpdate Class.
Definition: IpNetworkUpdate.H:21
int cmd_ipnetwork_info(vector< string > &args)
ipnetwork info command function
Definition: IpNetworkFunctions.H:439
void set_asn(const int asn)
Sets asn.
Definition: IpNetworkCreateCmd.H:79
static int dsInfo(DSInfo &ds, vector< string > &words, string &error_msg)
fills a DSInfo based on input command line
Definition: SheppObjSet.H:182
void insert_contact(const string &type, const string &identification)
Inserts a contact in the map of other contacts.
Definition: IpNetworkCreateCmd.H:152
Reverse DSInfo Class.
Definition: ReverseDSInfo.H:16
IpNetworkUpdateCmd * get_command()
Returns raw pointer to the command.
Definition: IpNetworkUpdate.H:54
string get_organization() const
Returns organization associated with the ip network.
Definition: IpNetworkUpdateCmd.H:68
EPP IpNetworkCreate Class.
Definition: IpNetworkCreate.H:21