6 #ifndef __ASN_FUNCTIONS_H__
7 #define __ASN_FUNCTIONS_H__
26 if (error_msg !=
"") {
27 printf(
"error: %s\n", error_msg.c_str());
30 printf(
"asn command syntax help:\n");
33 if (specific ==
"" || specific ==
"check") {
34 printf(
" check <asn> [asn ...]\n");
37 if (specific ==
"" || specific ==
"create") {
38 printf(
" create <asn> <-o organization> <-contact type=value> "
39 "[-contact type=value ...]\n"
40 " [-as-in \"value\" ...] [-as-out \"value\" ...]\n");
43 if (specific ==
"" || specific ==
"delete") {
44 printf(
" delete <asn>\n");
47 if (specific ==
"" || specific ==
"info") {
48 printf(
" info <asn>\n");
51 if (specific ==
"" || specific ==
"renew") {
52 printf(
" renew <asn> <-expdate expDate> [-period time:unit]\n");
55 if (specific ==
"" || specific ==
"transfer") {
56 printf(
" transfer <asn> <-op [query|request]>\n");
59 if (specific ==
"" || specific ==
"update") {
60 printf(
" update <asn> [-add-contact type=value ...]\n"
61 " [-rem-contact type=value ...] [-o organization]"
62 " [-creation-date yyyy-mm-ddThh:mm:ss.0Z]\n"
63 " [-as-in-add \"value\" ...] [-as-in-rem \"value\" ...]\n"
64 " [-as-out-add \"value\" ...] [-as-out-rem \"value\" ...]\n");
68 if (error_msg !=
"") {
82 string cmd_name =
"check";
91 while (!args.empty()) {
92 int asn = atoi(args[0].c_str());
95 args.erase(args.begin());
97 return cmd_asn_help(
"invalid ASN: '" + args[0] +
"'", cmd_name);
103 printf(
"ASNs to be checked:\n");
104 list<int>::const_iterator asn;
105 for (asn = asns.begin(); asn != asns.end(); asn++) {
106 printf(
" [%d]\n", (*asn));
124 string cmd_name =
"create";
133 int asn = atoi(args[0].c_str());
135 return cmd_asn_help(
"invalid ASN: '" + args[0] +
"'", cmd_name);
138 args.erase(args.begin());
140 bool hasOrganization =
false;
141 bool hasContacts =
false;
143 while (!args.empty()) {
144 if (args[0] ==
"-contact") {
147 args.erase(args.begin());
149 return cmd_asn_help(
"contact parameter missing", cmd_name);
159 args.erase(args.begin());
160 }
else if (args[0] ==
"-o") {
162 if (hasOrganization) {
163 return cmd_asn_help(
"only one organization allowed per command",
166 hasOrganization =
true;
168 args.erase(args.begin());
170 return cmd_asn_help(
"organization parameter missing", cmd_name);
173 args.erase(args.begin());
174 }
else if (args[0] ==
"-as-in") {
175 args.erase(args.begin());
177 return cmd_asn_help(
"as-in parameter missing", cmd_name);
180 string asIn = args[0];
181 args.erase(args.begin());
187 cmd->insert_as_in(asIn);
189 }
else if (args[0] ==
"-as-out") {
190 args.erase(args.begin());
192 return cmd_asn_help(
"as-out parameter missing", cmd_name);
195 string asOut = args[0];
196 args.erase(args.begin());
205 return cmd_asn_help(
"invalid syntax near \"" + args[0] +
"\"",
210 if (!hasOrganization) {
211 return cmd_asn_help(
"no organization specified", cmd_name);
219 printf(
"ASN to be created: [%d]\n", cmd->
get_asn());
222 map< string, string, less<string> > contacts = cmd->
get_contacts();
223 map< string, string, less<string> >::const_iterator cit;
224 for (cit = contacts.begin(); cit != contacts.end(); cit++) {
225 printf(
"contact %s: %s\n", (*cit).first.c_str(), (*cit).second.c_str());
243 string cmd_name =
"delete";
248 if (args.size() != 1) {
249 return cmd_asn_help(
"exactly one ASN must be specified", cmd_name);
252 int asn = atoi(args[0].c_str());
254 return cmd_asn_help(
"invalid ASN: '" + args[0] +
"'", cmd_name);
260 printf(
"ASN to be deleted: [%d]\n", cmd->
get_asn());
277 string cmd_name =
"info";
282 if (args.size() != 1) {
283 return cmd_asn_help(
"exactly one ASN must be specified", cmd_name);
286 int asn = atoi(args[0].c_str());
288 return cmd_asn_help(
"invalid ASN: '" + args[0] +
"'", cmd_name);
294 printf(
"ASN to get info: [%d]\n", cmd->
get_asn());
311 string cmd_name =
"renew";
320 int asn = atoi(args[0].c_str());
322 return cmd_asn_help(
"invalid ASN: '" + args[0] +
"'", cmd_name);
325 args.erase(args.begin());
328 bool hasExpDate =
false;
330 while (!args.empty()) {
331 if (args[0] ==
"-expdate") {
334 return cmd_asn_help(
"only one expDate allowed per command",
339 args.erase(args.begin());
344 args.erase(args.begin());
345 }
else if (args[0] ==
"-period") {
347 args.erase(args.begin());
349 return cmd_asn_help(
"period parameter missing", cmd_name);
359 args.erase(args.begin());
361 return cmd_asn_help(
"invalid syntax near \"" + args[0] +
"\"",
372 printf(
"asn : [%d]\n", cmd->
get_asn());
373 printf(
"expDate: [%s]\n", cmd->
get_expDate().c_str());
375 printf(
"period : [%d %s]\n", cmd->
get_period().time,
394 string cmd_name =
"transfer";
406 int asn = atoi(args[0].c_str());
408 return cmd_asn_help(
"invalid ASN: '" + args[0] +
"'", cmd_name);
411 args.erase(args.begin());
413 while (!args.empty()) {
414 if (args[0] ==
"-op") {
417 return cmd_asn_help(
"only one operation allowed per command",
422 args.erase(args.begin());
424 return cmd_asn_help(
"operation parameter missing", cmd_name);
427 if (args[0] !=
"query" && args[0] !=
"request") {
428 return cmd_asn_help(
"invalid operation '" + args[0] +
"'",
433 args.erase(args.begin());
435 return cmd_asn_help(
"invalid syntax near \"" + args[0] +
"\"",
441 return cmd_asn_help(
"no operation specified", cmd_name);
445 printf(
"asn : [%d]\n", cmd->
get_asn());
463 string cmd_name =
"update";
472 int asn = atoi(args[0].c_str());
474 return cmd_asn_help(
"invalid ASN: '" + args[0] +
"'", cmd_name);
477 args.erase(args.begin());
479 bool hasOrganization =
false;
480 bool hasContactsAdd =
false;
481 bool hasContactsRem =
false;
482 bool hasCreationDate =
false;
483 bool hasAsIn =
false;
484 bool hasAsOut =
false;
486 while (!args.empty()) {
487 if (args[0] ==
"-add-contact") {
489 hasContactsAdd =
true;
490 args.erase(args.begin());
492 return cmd_asn_help(
"add-contact parameter missing", cmd_name);
502 args.erase(args.begin());
503 }
else if (args[0] ==
"-rem-contact") {
505 hasContactsRem =
true;
506 args.erase(args.begin());
508 return cmd_asn_help(
"rem-contact parameter missing", cmd_name);
518 args.erase(args.begin());
519 }
else if (args[0] ==
"-o") {
521 if (hasOrganization) {
522 return cmd_asn_help(
"only one organization allowed per command",
525 hasOrganization =
true;
527 args.erase(args.begin());
529 return cmd_asn_help(
"organization parameter missing", cmd_name);
532 args.erase(args.begin());
533 }
else if (args[0] ==
"-creation-date") {
534 if (hasCreationDate) {
535 return cmd_asn_help(
"only one creation-date allowed per command",
538 hasCreationDate =
true;
540 args.erase(args.begin());
542 return cmd_asn_help(
"organization parameter missing", cmd_name);
544 cmd->set_creation_date(args[0]);
545 args.erase(args.begin());
547 }
else if (args[0] ==
"-as-in-add") {
548 args.erase(args.begin());
550 return cmd_asn_help(
"as-in-add parameter missing", cmd_name);
553 string asIn = args[0];
554 args.erase(args.begin());
557 return cmd_asn_help(
"error setting as-in-add", cmd_name);
563 }
else if (args[0] ==
"-as-in-rem") {
564 args.erase(args.begin());
566 return cmd_asn_help(
"as-in-rem parameter missing", cmd_name);
569 string asIn = args[0];
570 args.erase(args.begin());
573 return cmd_asn_help(
"error setting as-in-rem", cmd_name);
579 }
else if (args[0] ==
"-as-out-add") {
580 args.erase(args.begin());
582 return cmd_asn_help(
"as-out-add parameter missing", cmd_name);
585 string asOut = args[0];
586 args.erase(args.begin());
589 return cmd_asn_help(
"error setting as-out-add", cmd_name);
595 }
else if (args[0] ==
"-as-out-rem") {
596 args.erase(args.begin());
598 return cmd_asn_help(
"as-out-rem parameter missing", cmd_name);
601 string asOut = args[0];
602 args.erase(args.begin());
605 return cmd_asn_help(
"error setting as-out-rem", cmd_name);
612 return cmd_asn_help(
"invalid syntax near \"" + args[0] +
"\"",
617 if (!hasOrganization && !hasContactsAdd && !hasContactsRem &&
618 !hasCreationDate && !hasAsIn && !hasAsOut) {
623 printf(
"ASN to be updated: [%d]\n", cmd->
get_asn());
626 map< string, string, less<string> >::const_iterator cit;
627 map< string, string, less<string> > contacts;
630 for (cit = contacts.begin(); cit != contacts.end(); cit++) {
631 printf(
"contact to add %s: %s\n",
632 (*cit).first.c_str(), (*cit).second.c_str());
636 for (cit = contacts.begin(); cit != contacts.end(); cit++) {
637 printf(
"contact to remove %s: %s\n",
638 (*cit).first.c_str(), (*cit).second.c_str());
642 for (
int i = 0; i < asInAdd.size(); i++) {
643 printf(
"as-in to add: %s\n", asInAdd[i].c_str());
647 for (
int i = 0; i < asInRem.size(); i++) {
648 printf(
"as-in to remove: %s\n", asInRem[i].c_str());
652 for (
int i = 0; i < asOutAdd.size(); i++) {
653 printf(
"as-out to add: %s\n", asOutAdd[i].c_str());
657 for (
int i = 0; i < asOutRem.size(); i++) {
658 printf(
"as-out to remove: %s\n", asOutRem[i].c_str());
677 if (!args.empty() && !(args[0] ==
"help")) {
678 if (args[0] ==
"check") {
679 args.erase(args.begin());
681 }
else if (args[0] ==
"create") {
682 args.erase(args.begin());
684 }
else if (args[0] ==
"delete") {
685 args.erase(args.begin());
687 }
else if (args[0] ==
"info") {
688 args.erase(args.begin());
690 }
else if (args[0] ==
"renew") {
691 args.erase(args.begin());
693 }
else if (args[0] ==
"transfer") {
694 args.erase(args.begin());
696 }
else if (args[0] ==
"update") {
697 args.erase(args.begin());
707 #endif //__ASN_FUNCTIONS_H__
void set_asn(const int asn)
Sets asn.
Definition: AsnRenewCmd.H:37
void set_asn(const int asn)
Sets asn.
Definition: AsnUpdateCmd.H:40
string get_expDate() const
Returns expiration date.
Definition: AsnRenewCmd.H:64
map< string, string, less< string > > get_contacts_add() const
Returns map of other contacts to be added.
Definition: AsnUpdateCmd.H:96
void insert_contact_rem(const string &type, const string &identification)
Inserts a contact to be removed.
Definition: AsnUpdateCmd.H:106
EPP AsnUpdate Class.
Definition: AsnUpdate.H:20
void insert_contact(const string &type, const string &identification)
Inserts a contact in the map of other contacts.
Definition: AsnCreateCmd.H:77
void set_organization(const string &organization)
Sets organization.
Definition: AsnCreateCmd.H:58
EPP AsnTransferCmd Class.
Definition: AsnTransferCmd.H:17
static int split(string input, string &first, string &second, string splitter, bool relaxed=false)
Definition: SheppStrUtil.H:120
void set_expDate(const string &expDate)
Sets expiration date.
Definition: AsnRenewCmd.H:55
AsnCreateCmd * get_command()
Returns raw pointer to the command.
Definition: AsnCreate.H:54
EPP AsnDelete Class.
Definition: AsnDeleteCmd.H:17
int get_asn() const
Returns asn.
Definition: AsnInfoCmd.H:41
vector< string > get_as_in_add() const
Returns list of all AS input policies to be added.
Definition: AsnUpdateCmd.H:133
EPP AsnCheck Class.
Definition: AsnCheck.H:21
int get_asn() const
Returns asn.
Definition: AsnRenewCmd.H:46
AsnUpdateCmd * get_command()
Returns raw pointer to the command.
Definition: AsnUpdate.H:53
int cmd_asn_create(vector< string > &args)
asn create command function
Definition: AsnFunctions.H:122
void set_asn(const int asn)
Sets asn.
Definition: AsnTransferCmd.H:50
void insert_as_out_add(const string &policy)
Inserts an AS output policy to be added.
Definition: AsnUpdateCmd.H:160
void set_organization(const string &organization)
Sets organization.
Definition: AsnUpdateCmd.H:58
EPP AsnUpdate Class.
Definition: AsnUpdateCmd.H:25
int cmd_asn_renew(vector< string > &args)
asn renew command function
Definition: AsnFunctions.H:309
EPP AsnCheck Class.
Definition: AsnCheckCmd.H:17
void add_asn(const int asn)
Sets asn.
Definition: AsnCheckCmd.H:32
void set_asn(const int asn)
Sets asn.
Definition: AsnDeleteCmd.H:32
vector< string > get_as_in_rem() const
Returns list of all AS input policies to be removed.
Definition: AsnUpdateCmd.H:151
void set_operation(const string &op)
Sets operation.
Definition: AsnTransferCmd.H:32
EPP AsnCreate Class.
Definition: AsnCreateCmd.H:25
int cmd_asn_update(vector< string > &args)
asn update command function
Definition: AsnFunctions.H:461
int get_asn() const
Returns asn.
Definition: AsnTransferCmd.H:59
void insert_as_in_add(const string &policy)
Inserts an AS input policy to be added.
Definition: AsnUpdateCmd.H:124
void insert_as_out_rem(const string &policy)
Inserts an AS output policy to be removed.
Definition: AsnUpdateCmd.H:178
RegistrationPeriod get_period() const
Returns period.
Definition: AsnRenewCmd.H:84
int process_action(Action &act)
Send and EPP Action.
Definition: SheppCommandFunctions.H:871
map< string, string, less< string > > get_contacts() const
Returns map of other contacts.
Definition: AsnCreateCmd.H:86
list< int > get_asn_list() const
Returns asn.
Definition: AsnCheckCmd.H:41
int cmd_asn_delete(vector< string > &args)
asn check delete function
Definition: AsnFunctions.H:241
int cmd_asn_help(string error_msg, string specific="")
print asn command usage info
Definition: AsnFunctions.H:24
AsnTransferCmd * get_command()
Returns raw pointer to the command.
Definition: AsnTransfer.H:54
EPP AsnCreate Class.
Definition: AsnCreate.H:21
void insert_as_in_rem(const string &policy)
Inserts an AS input policy to be removed.
Definition: AsnUpdateCmd.H:142
void set_period(const int time, const string &unit)
Sets period.
Definition: AsnRenewCmd.H:74
AsnInfoCmd * get_command()
Returns raw pointer to the command.
Definition: AsnInfo.H:54
string get_operation() const
Returns operation.
Definition: AsnTransferCmd.H:41
EPP AsnInfo Class.
Definition: AsnInfoCmd.H:17
EPP AsnRenew Class.
Definition: AsnRenew.H:21
EPP command-line shell client command functions include file.
void insert_contact_add(const string &type, const string &identification)
Inserts a contact to be added.
Definition: AsnUpdateCmd.H:87
void set_asn(const int asn)
Sets asn.
Definition: AsnInfoCmd.H:32
static int quote_gathering(vector< string > &words, string &gather)
Gathers command-line arguments bounded by quotes in a string.
Definition: SheppStrUtil.H:152
int get_asn() const
Returns asn.
Definition: AsnUpdateCmd.H:49
AsnDeleteCmd * get_command()
Returns raw pointer to the command.
Definition: AsnDelete.H:53
string get_organization() const
Returns organization associated with the asn.
Definition: AsnCreateCmd.H:67
void insert_as_out(const string &as_out)
Sets output routing policy.
Definition: AsnCreateCmd.H:100
EPP AsnRenew Class.
Definition: AsnRenewCmd.H:22
AsnCheckCmd * get_command()
Returns raw pointer to the command.
Definition: AsnCheck.H:54
int get_asn() const
Returns asn.
Definition: AsnCreateCmd.H:49
map< string, string, less< string > > get_contacts_rem() const
Returns map of other contacts to be removed.
Definition: AsnUpdateCmd.H:115
int cmd_asn(vector< string > &args)
main asn command
Definition: AsnFunctions.H:674
EPP AsnDelete Class.
Definition: AsnDelete.H:20
void set_asn(const int asn)
Sets asn.
Definition: AsnCreateCmd.H:40
int get_asn() const
Returns asn.
Definition: AsnDeleteCmd.H:41
int cmd_asn_info(vector< string > &args)
asn info command function
Definition: AsnFunctions.H:275
AsnRenewCmd * get_command()
Returns raw pointer to the command.
Definition: AsnRenew.H:54
int cmd_asn_check(vector< string > &args)
asn check command function
Definition: AsnFunctions.H:80
string get_organization() const
Returns organization associated with the asn.
Definition: AsnUpdateCmd.H:67
EPP AsnTransfer Class.
Definition: AsnTransfer.H:21
int cmd_asn_transfer(vector< string > &args)
asn transfer command function
Definition: AsnFunctions.H:392
EPP AsnInfo Class.
Definition: AsnInfo.H:21